In the following piece of code, the destructor of class TdcTestResult
is called at the end of function add
, and so method variable mTdcTestResults
will become empty again.
How can I make the instance of TdcTestResult
inside mTdcTestResults
persistent?
classdef Tdc
properties % (Access = private)
mTestRun = TdcTestRun;
mTestResults = [];
end
methods(Access = public)
function add(obj, componentSerialNumber, testName, testVersion, paramName, unitOfMeasureCode, paramScale, paramLimitTypeCode, paramLowerLimit, paramUpperLimit, responseValue, folderPath, isFailed, isOverridden, overriddenReason)
if(nargin > 0)
obj.mTestResults = [obj.mTestResults TdcTestResult];
obj.mTestResults(end).set(componentSerialNumber, testName, testVersion, paramName, unitOfMeasureCode, paramScale, paramLimitTypeCode, paramLowerLimit, paramUpperLimit, responseValue, folderPath, isFailed, isOverridden, overriddenReason);
obj.mTestRun.addTestResult(obj.mTestResults(end));
end
end
end
end