www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcfoundation/@DCTManager/getMBCManager.m
function manager = getMBCManager() %GETMBCMANAGER Method for getting the persistent DCT manager % % MANAGER = GETMBCMANAGER() returns a DCTManager that contains a % persistent configuration that is saved in an MBC preference % Copyright 2006-2012 The MathWorks, Inc. persistent hPersistentManager if isempty(hPersistentManager) || ~ishandle(hPersistentManager) manager = i_getManagerFromPref; % Add a listener that will update the preferences when the % configuration is changed. manager.Listeners = [manager.Listeners; ... handle.listener(manager, manager.findprop('Configuration'), 'PropertyPostSet', @i_setManagerPref)]; hPersistentManager = manager; end manager = hPersistentManager; % Create a new DCTManager from the saved data in preferences function manager = i_getManagerFromPref P = mbcprefs('mbc'); if ispref(P, 'DCTManager') manager_struct = getpref(P, 'DCTManager'); config = manager_struct.Configuration; elseif mbcfoundation.DCTManager.isDCTAvailable() % Use the default config from Matlab. This choice is not saved config = parallel.defaultClusterProfile; else config = 'local'; end % To make sure the constructor is called, we need to go through the % uddDispatcher. dispatcher = xregGui.uddDispatcher; manager = dispatcher.feval(@mbcfoundation.DCTManager, config); % Save DCTManager data to preferences. function i_setManagerPref(~, evt) P = mbcprefs('mbc'); if ~ispref(P, 'DCTManager') addpref(P, 'DCTManager'); end manager_struct.Configuration = evt.NewValue; setpref(P, 'DCTManager', manager_struct);