2 properties (Access=
private)
9 properties (SetAccess=private,GetAccess=protected)
13 function storageDir=getStorageBranchKey(self)
14 storageDir=self.storage.getStorageBranchKey();
17 function storageDir=getStorageLocation(self)
18 storageDir=self.storage.getStorageLocation();
21 function storageRootDir=getStorageLocationRoot(self)
22 storageRootDir=self.storage.getStorageLocationRoot();
26 methods (Access=private)
27 function [SConfData,metaData]=getConfFromStorage(self,confName)
28 [SConfData,metaData]=self.storage.get(confName);
35 function isPositive=isCachedConf(self,confName)
36 isPositive=self.cache.isKey(confName);
38 function putConfToCache(self,varargin)
39 self.cacheConf(varargin{:});
41 function putConfToCacheAndSelect(
self,varargin)
42 self.cacheAndSelectConf(varargin{:});
44 function putConfToStorage(
self,confName,SConfData,metaData)
48 self.storage.put(confName,SConfData,metaData);
52 methods (Access=
protected,Static)
53 function confVersion=getConfVersionFromMetaData(metaData)
54 if ~isfield(metaData,
'version')
57 confVersion=str2double(metaData.version);
60 function metaData=putConfVersionToMetaData(metaData,confVersion)
61 confVersion=num2str(confVersion);
62 metaData.version=confVersion;
66 function otherObj=getCopy(self)
67 otherObj=getArrayFromByteStream(getByteStreamFromArray(self));
69 function isPos=isConfSelected(self,confName)
70 isPos=strcmp(self.curConfName,confName);
72 function storeCachedConf(self,confName)
73 [SConfData,metaData]=getCachedConf(self,confName);
74 self.putConfToStorage(confName,SConfData,metaData)
76 function flushCache(self)
79 function lastRevision=getLastConfVersion(self)
80 lastRevision=self.confPatchRepo.getLastRevision();
82 function self=ConfRepoManagerAnyStorage(storage,varargin)
87 '
mxberry.core.cont.ondisk.IOnDiskBranchedStorage'));
91 [reg,isRegSpec,self.putStorageHook,...
94 'putStorageHook',
'getStorageHook';...
96 @(x)isa(x,
'function_handle'),...
97 @(x)isa(x,
'function_handle')},...
100 'mxberry.core.struct.AStructChangeTracker')});
103 self.confPatchRepo=reg{1};
105 self.confPatchRepo=...
106 StructChangeTrackerEmptyPlug();
109 self.storage=storage;
113 function editConf(
self,confName)
114 fileName=
self.storage.getFileNameByKey(confName);
118 function selectConf(
self,confName,varargin)
120 [~,prop]=
mxberry.
core.parseparams(varargin,{
'reloadIfSelected'},0);
122 isReloadedIfSelected=prop{2};
123 if ~(islogical(isReloadedIfSelected)&&numel(isReloadedIfSelected)==1)
125 'reloadedIfSelected is expected to be a logical scalar');
128 isReloadedIfSelected=
true;
131 if isReloadedIfSelected||~(isReloadedIfSelected||
self.isCachedConf(confName))
132 if ~
self.storage.isKey(confName)
134 'configuration %s does not exist in the repository',...
138 [SConf,metaData]=
self.getConfFromStorage(confName);
139 self.cacheAndSelectConf(confName,SConf,metaData);
141 self.curConfName=confName;
145 function isPositive=isParam(
self,paramName)
147 paramName=[
'.',paramName];
150 self.getCurConf(),paramName);
153 function resVal=getParam(
self,paramName,varargin)
158 {
'skipCache';
false;@(x)islogical(x)&&isscalar(x)},0);
161 self.reCacheCurConf();
169 'the requested parameter does not exist');
170 newMeObj=newMeObj.addCause(meObj);
175 function setParam(
self,paramName,paramValue,varargin)
176 [~,prop]=
mxberry.
core.parseparams(varargin,{
'writedepth'},0);
179 isWriteToDisk=strcmpi(prop{2},
'disk');
183 paramName=[
'.',paramName];
186 curConfName=
self.getCurConfName(); %#ok<*PROPLC,*PROP>
187 [curConf,metaData]=
self.getCurConf();
191 self.cacheAndSelectConf(curConfName,SConf,metaData);
193 self.putConfToStorage(curConfName,SConf,metaData);
197 function putConf(
self,confName,SConf,varargin)
198 [restArgList,~,isSelected]=
mxberry.
core.parseparext(varargin,...
199 {
'selectConf';
true;
'islogical(x)&&isscalar(x)'});
201 self.putConfInternal(confName,SConf,restArgList{:});
204 self.curConfName=confName;
209 function [SConf,confVersion,metaData]=getConf(
self,confName)
210 [SConf,confVersion,metaData]=
self.getConfInternal(confName);
213 function copyConf(
self,fromConfName,toConfName)
214 [SConf,metaData]=
self.getConfInternal(fromConfName);
215 self.putConf(toConfName,SConf,metaData);
218 function destFileName=copyConfFile(
self,destFolderName,varargin)
219 [reg,~,isDestFile]=
mxberry.
core.parseparext(varargin,...
220 {
'destIsFile';
false;
'isscalar(x)&&islogical(x)'},...
221 'regCheckList',{
'isstring(x)'},...
222 'regDefList',{
self.getCurConfName()});
225 fullFileName=
self.storage.getFileNameByKey(confName);
226 %make sure that
"/" at the end of folder path doesn
't matter 228 destFileName=destFolderName; 230 [~,fileName,ext]=fileparts(fullFileName); 231 if strcmp(destFolderName(end),filesep) 232 destFolderName=destFolderName(1:end-1); 234 if ~mxberry.io.isdir(destFolderName) 235 mxberry.io.mkdir(destFolderName); 237 destFileName=[destFolderName,filesep,fileName,ext]; 239 copyfile(fullFileName,destFileName); 242 function removeAll(self) 244 self.storage.removeAll(); 246 function confNameList=getConfNameList(self) 247 confNameList=self.getConfNameListInternal(); 249 function confName=getCurConfName(self) 250 import mxberry.core.throwerror; 251 if isempty(self.curConfName) 252 throwerror('wrongActionSequence
',... 253 'Current configuration is not selected
'); 256 confName=self.curConfName; 259 function [SConf,metaData]=getCurConf(self) 260 curConfName=self.getCurConfName(); 261 [SConf,metaData]=self.getCachedConf(curConfName); 264 function isPositive=isConf(self,confName) 265 isPositive=self.storage.isKey(confName); 267 function removeConf(self,confName) 268 if self.cache.isKey(confName) 269 self.cache.remove(confName); 272 self.storage.remove(confName); 274 function setConfPatchRepo(self,confPatchRepo) 275 self.confPatchRepo=confPatchRepo; 277 function updateConf(self,confName) 278 self.updateConfInternal(confName); 280 function updateAll(self) 281 self.updateAllInternal(); 284 methods (Access=protected) 285 function confNameList=getCachedConfNames(self) 286 confNameList=self.cache.keys(); 289 function updateAllInternal(self) 290 confNameList=self.getConfNameListInternal(); 291 nConfs=length(confNameList); 293 confName=confNameList{iConf}; 294 self.updateConfInternal(confName); 298 function confNameList=getConfNameListInternal(self) 299 import mxberry.core.throwerror; 301 confNameList=self.storage.getKeyList(); 303 if ~isempty(strfind(meObj.identifier,':badKeyValuePair
')) 304 newMeObj=throwerror('badConfRepo
',... 305 ['configuration repository contains the
',... 306 'inconsistent configurations
']); 307 newMeObj=addCause(newMeObj,meObj); 314 function updateConfInternal(self,confName) 315 [SConf,oldConfVersion,metaData]=self.getConfInternal(confName); 316 [SConf,confVersion,metaData]=self.updateConfStructInternal(... 317 SConf,oldConfVersion,metaData); 318 if (confVersion>oldConfVersion)||isnan(oldConfVersion) 319 self.putConfInternal(confName,SConf,confVersion,metaData); 322 function [SConf,confVersion,metaData]=updateConfStructInternal(self,SConf,confVersion,metaData) 323 [SConf,confVersion]=self.confPatchRepo.applyAllLaterPatches(SConf,confVersion); 324 metaData=self.putConfVersionToMetaData(metaData,confVersion); 328 function [SConf,confVersion,metaData]=getConfInternal(self,confName) 329 import mxberry.core.throwerror; 331 if self.isCachedConf(confName) 332 [SConf,metaData]=self.getCachedConf(confName); 335 [SConf,metaData]=self.getConfFromStorage(confName); 337 if ~isempty(strfind(meObj.identifier,':noRecord
')) 338 newMeObj=throwerror('noConfiguration
',... 339 'configuration %s does not exist
',confName); 341 newMeObj=addCause(newMeObj,meObj); 348 confVersion=self.getConfVersionFromMetaData(metaData); 351 function putConfInternal(self,confName,SConf,confVersion,metaData) 357 confVersion=self.confPatchRepo.getLastRevision(); 360 metaData=self.putConfVersionToMetaData(metaData,confVersion); 362 self.cacheConf(confName,SConf,metaData); 363 self.putConfToStorage(confName,SConf,metaData); 367 methods (Access=protected) 368 function cacheAndSelectConf(self,confName,SConf,metaData) 369 self.cacheConf(confName,SConf,metaData); 370 self.curConfName=confName; 372 function cacheConf(self,confName,SConf,metaData) 373 self.cache(confName)={SConf,metaData}; 375 function [SConf,metaData]=getCachedConf(self,confName) 376 import mxberry.core.throwerror; 377 isCached=self.isCachedConf(confName); 379 res=self.cache(confName); 383 throwerror('noKey
',... 384 'configuration %s is not cached
',confName); 387 function reCacheCurConf(self) 388 curConfName=self.getCurConfName(); 389 [conf,metaData]=self.getConfFromStorage(curConfName); 390 self.cacheAndSelectConf(curConfName,conf,metaData); 392 function initCache(self) 393 self.cache=containers.Map; function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function parseparext(in args, in propNameValMat, in varargin)
PARSEPAREXT behaves in the same way as mxberry.core.parseparams but returns property values in a more...
function checkvar(in x, in typeSpec, in varargin)
CHECKVAR checks a generic condition provided by typeSpec string in the following format: 'isnumeric(x...
HANDLEOBJECTCLONER provides some simple functionality for clonable objects.
function updateleaves(in SData, in fUpdateFunc)
UPDATELEAVES applies the specified function to each structure leave value and returns the updated str...