Skip to content

Commit 2c364ea

Browse files
committed
SourcesMixIn + implementation for Tag
1 parent f2f0a74 commit 2c364ea

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

+nix/Dynamic.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
end
1717
end
1818

19-
methods (Access = protected)
19+
methods (Hidden = true)
2020
function add_dyn_attr(obj, prop, mode)
2121
if nargin < 3
2222
mode = 'r';

+nix/SourcesMixIn.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
classdef SourcesMixIn < handle
2+
%SourcesMixIn
3+
% mixin class for nix entities that can be related with sources
4+
5+
methods
6+
function obj = SourcesMixIn()
7+
obj.add_dyn_relation('sources', @nix.Source);
8+
end
9+
10+
function [] = add_source(obj, add_this)
11+
obj.sourcesCache = nix.Utils.add_entity(obj, ...
12+
add_this, 'nix.Source', 'Tag::addSource', obj.sourcesCache);
13+
end;
14+
15+
function delCheck = remove_source(obj, del)
16+
[delCheck, obj.sourcesCache] = nix.Utils.delete_entity(obj, ...
17+
del, 'nix.Source', 'Tag::removeSource', obj.sourcesCache);
18+
end;
19+
20+
function retObj = open_source(obj, id_or_name)
21+
retObj = nix.Utils.open_entity(obj, ...
22+
'Tag::openSource', id_or_name, @nix.Source);
23+
end;
24+
end
25+
26+
end
27+

+nix/Tag.m

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
classdef Tag < nix.NamedEntity & nix.MetadataMixIn
1+
classdef Tag < nix.NamedEntity & nix.MetadataMixIn & nix.SourcesMixIn
22
%Tag nix Tag object
33

44
properties (Access = protected)
@@ -8,8 +8,9 @@
88

99
methods
1010
function obj = Tag(h)
11-
11+
[email protected](h); % this should be first
1212
13+
1314

1415
% assign dynamic properties
1516
obj.add_dyn_attr('position', 'rw');
@@ -19,7 +20,6 @@
1920
% assign relations
2021
obj.add_dyn_relation('references', @nix.DataArray);
2122
obj.add_dyn_relation('features', @nix.Feature);
22-
obj.add_dyn_relation('sources', @nix.Source);
2323
end;
2424

2525
% ------------------
@@ -69,25 +69,6 @@
6969
% see mkarray.cc(42)
7070
data = permute(tmp, length(size(tmp)):-1:1);
7171
end;
72-
73-
% ------------------
74-
% Sources methods
75-
% ------------------
76-
77-
function [] = add_source(obj, add_this)
78-
obj.sourcesCache = nix.Utils.add_entity(obj, ...
79-
add_this, 'nix.Source', 'Tag::addSource', obj.sourcesCache);
80-
end;
81-
82-
function delCheck = remove_source(obj, del)
83-
[delCheck, obj.sourcesCache] = nix.Utils.delete_entity(obj, ...
84-
del, 'nix.Source', 'Tag::removeSource', obj.sourcesCache);
85-
end;
86-
87-
function retObj = open_source(obj, id_or_name)
88-
retObj = nix.Utils.open_entity(obj, ...
89-
'Tag::openSource', id_or_name, @nix.Source);
90-
end;
9172

9273
end;
9374
end

0 commit comments

Comments
 (0)