Calculations/Dipolar Gas Simulator/+Simulator/@Calculator/Calculator.m

74 lines
2.5 KiB
Matlab

classdef Calculator < handle & matlab.mixin.Copyable
properties (Access = private)
CalculatorDefaults = struct('OrderParameter', 1, ...
'PhaseCoherence', 1, ...
'CutoffType', 'Cylindrical');
end
properties (Access = public)
OrderParameter;
PhaseCoherence;
CutoffType;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%- Methods
methods
function this = Calculator(varargin)
this.OrderParameter = this.CalculatorDefaults.OrderParameter;
this.PhaseCoherence = this.CalculatorDefaults.PhaseCoherence;
this.CutoffType = this.CalculatorDefaults.CutoffType;
end
function restoreDefaults(this)
this.OrderParameter = this.PotentialDefaults.OrderParameter;
this.PhaseCoherence = this.CalculatorDefaults.PhaseCoherence;
this.CutoffType = this.CalculatorDefaults.CutoffType;
end
end % - lifecycle
% methods
% end % - setters and getters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%- Methods
methods(Access = protected)
function cp = copyElement(this)
% Shallow copy object
cp = copyElement@matlab.mixin.Copyable(this);
% Forces the setter to redefine the function handles to the new copied object
pl = properties(this);
for k = 1:length(pl)
sc = superclasses(this.(pl{k}));
if any(contains(sc,{'matlab.mixin.Copyable'}))
cp.(pl{k}) = this.(pl{k}).copy();
end
end
end
end
methods (Static)
% Creates an Instance of Class, ensures singleton behaviour (that there
% can only be one Instance of this class
function singleObj = getInstance(varargin)
% Creates an Instance of Class, ensures singleton behaviour
persistent localObj;
if isempty(localObj) || ~isvalid(localObj)
localObj = Simulator.Calculator(varargin{:});
end
singleObj = localObj;
end
end
end