-
Notifications
You must be signed in to change notification settings - Fork 5
/
SliceEntity.m
73 lines (65 loc) · 2.36 KB
/
SliceEntity.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
classdef SliceEntity < Entity
%UNTITLED7 Summary of this class goes here
% Detailed explanation goes here
properties(SetAccess = ?SliceEntityBuilder)
SliceIdentifier uint64;
end
properties (Constant, Access = private)
ssn = SerialNumber;
% NOTE: Each type of class need to define their own serial number;
% If a serieral number is shared among multiple classes, we can define a common
% super class for them.
end
properties (Access = protected)
seed;
end
properties (SetAccess = {?SliceEntity,?RandomEventDispatcher})
Child; % see also <FlowEntity>.
end
properties(Dependent)
Options;
end
methods (Access = ?SliceEntityBuilder)
function this = SliceEntity(time_arrive, time_serve, src, varargin)
this@Entity(time_arrive,time_serve,src,varargin{2:end});
if length(varargin) >= 1
this.seed = varargin{1};
end
%
% The identifier can be update in the constructor.
id = SliceEntity.ssn.next(length(this));
for i = length(this):-1:1
this(i).SliceIdentifier = id(i);
end
end
end
methods
% You can also directly access _Builder.Options_.
function opt = get.Options(this)
opt = this.Builder.Options;
opt.RandomSeed = this.seed;
end
end
methods (Access = protected)
function newobj = copyElement(this)
newobj = copyElement@Entity(this);
%% Deep Copy Issue
% *Child* is an exterior link. When performing copy, we should not make a copy of this
% object. Instead, the link should be updated by the caller of the _copy_ function. To
% secure the original data, we detach the link in the new copy from the original data.
% See also <Entity>.
if ~isempty(this.Child)
newobj.Child = this.Child.empty();
end
end
end
methods(Static)
function n = getGlobalSliceId()
n = SliceEntity.ssn.ID;
end
function setGlobalSliceId(value)
h = SliceEntity.ssn;
h.ID = value;
end
end
end