MatrixBerryCore
StaticPropStorage.m
Go to the documentation of this file.
1 classdef StaticPropStorage<handle
2  methods (Static,Access=private)
3  function [propVal,isThere]=setGetProp(isFlushed,isPresenceChecked,branchName,propName,propVal)
4  import mxberry.core.throwerror;
5  persistent branchStorage;
6  if isempty(branchStorage)
7  branchStorage=containers.Map;
8  end
9  if nargin>2
10  if ~branchStorage.isKey(branchName) || isFlushed
11  branchStorage(branchName)=containers.Map();
12  end
13  if nargin>4
14  propStorage=branchStorage(branchName);
15  propStorage(propName)=propVal; %#ok<NASGU>
16  end
17  end
18  if nargout>0
19  try
20  propStorage=branchStorage(branchName);
21  if nargout>1&&isPresenceChecked
22  isThere=propStorage.isKey(propName);
23  if isThere
24  propVal=propStorage(propName);
25  else
26  propVal=[];
27  end
28  else
29  propVal=propStorage(propName);
30  isThere=true;
31  end
32  catch meObj
33  if ~isempty(strfind(meObj.identifier,':NoKey'))
34  newMeObj=throwerror('noProp',...
35  'property %s is missing',propName);
36  newMeObj=addCause(newMeObj,meObj);
37  throw(newMeObj);
38  else
39  rethrow(meObj);
40  end
41  end
42  end
43  end
44  end
45 
46  methods (Static,Access=protected)
47  function [propVal,isThere]=getPropInternal(branchName,propName,isPresenceChecked)
48  if nargin<3
49  isPresenceChecked=false;
50  end
51  [propVal,isThere]=...
52  mxberry.core.obj.StaticPropStorage.setGetProp(...
53  false,isPresenceChecked,branchName,propName);
54  end
55  function setPropInternal(branchName,propName,propVal)
56  mxberry.core.obj.StaticPropStorage.setGetProp(...
57  false,false,branchName,propName,propVal);
58  end
59  function flushInternal(branchName)
60  mxberry.core.obj.StaticPropStorage.setGetProp(true,false,...
61  branchName);
62  end
63  end
64 
65 end
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...