Skip to content

Commit a01c165

Browse files
committed
[Matlab] Remove Property NamedEntity inheritance
Closes #161. As in the NIX model Property now inherits from Entity and not from NamedEntity.
1 parent 5edad2d commit a01c165

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

+nix/Property.m

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
% modification, are permitted under the terms of the BSD License. See
4848
% LICENSE file in the root of the Project.
4949

50-
classdef Property < nix.NamedEntity
50+
classdef Property < nix.Entity
5151

5252
properties (Hidden)
5353
alias = 'Property' % namespace for Property nix backend function access.
@@ -59,9 +59,12 @@
5959

6060
methods
6161
function obj = Property(h)
62-
obj@nix.NamedEntity(h);
62+
obj = obj@nix.Entity(h);
6363

6464
% assign dynamic properties
65+
nix.Dynamic.addProperty(obj, 'id', 'r');
66+
nix.Dynamic.addProperty(obj, 'name', 'r');
67+
nix.Dynamic.addProperty(obj, 'definition', 'rw');
6568
nix.Dynamic.addProperty(obj, 'unit', 'rw');
6669
nix.Dynamic.addProperty(obj, 'datatype', 'r');
6770
end
@@ -113,6 +116,26 @@
113116
fname = strcat(obj.alias, '::deleteValues');
114117
nix_mx(fname, obj.nixhandle);
115118
end
119+
120+
function r = compare(obj, entity)
121+
% Checks two NIX entities of the same class for equality.
122+
%
123+
% The name property is the first comparison. If they are the same,
124+
% the ids of the entities will be compared.
125+
%
126+
% Returns: (double) 0 if both entities are equal.
127+
% > or < 0 if the entities are different.
128+
%
129+
% Example: check = currSource.compare(otherSource);
130+
131+
if (~isa(obj, class(entity)))
132+
err.identifier = 'NIXMX:InvalidArgument';
133+
err.message = 'Only entities of the same class can be compared.';
134+
error(err);
135+
end
136+
fname = strcat(obj.alias, '::compare');
137+
r = nix_mx(fname, obj.nixhandle, entity.nixhandle);
138+
end
116139
end
117140

118141
end

0 commit comments

Comments
 (0)