www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcprefs/mbcprefs.m

    function p = mbcprefs(varargin)
%MBCPREFS Constructor for an mbcprefs object
%
%  P=MBCPREFS creates a preferences object which gives access to an
%  interface for accessing and creating application preferences.
%
%  P=MBCPREFS(PREFSET) creates an object and attaches to the given
%  preferences set
%
%  P=MBCPREFS('CustomPrefDir', PATH) forces MBC to use the specified folder
%  for storing preferences.  This option is used in testing to ensure that
%  multiple MATLAB instances are not writing to and deleting the same
%  preference files.

%  Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc.


p.version = 1;
p = class(p,'mbcprefs');

INIT_CMD = 'init';
if nargin
    i = find( strncmp( 'CustomPrefDir',varargin,13 ) );
    if ~isempty(i)
        pr_datastore('property', 'FileLocation', varargin{i+1});
        varargin(i:i+1) = [];
    end
end

% check the persistent storage is initialised
if ~isempty(varargin)
    if pr_datastore('isprefset', varargin{1})
        pr_datastore(INIT_CMD,varargin{1});
    else
        warning(message('mbc:mbcprefs:InvalidArgument', varargin{ 1 }));
        pr_datastore(INIT_CMD);
    end
else
    pr_datastore(INIT_CMD);
end