|
1 |
| -classdef Section < nix.Entity |
| 1 | +classdef Section < nix.NamedEntity |
2 | 2 | %SECTION Metadata Section class
|
3 | 3 | % NIX metadata section
|
4 | 4 |
|
| 5 | + properties (Access = protected) |
| 6 | + % namespace reference for nix-mx functions |
| 7 | + alias = 'Section' |
| 8 | + end |
| 9 | + |
5 | 10 | properties(Hidden)
|
6 |
| - info |
7 |
| - sectionsCache |
8 | 11 | propsCache
|
9 | 12 | end;
|
10 | 13 |
|
11 | 14 | properties(Dependent)
|
12 |
| - name |
13 |
| - type |
14 |
| - id |
15 |
| - repository |
16 |
| - mapping |
17 |
| - |
18 |
| - sections |
19 |
| - properties_cell |
20 |
| - properties_map |
| 15 | + allProperties |
| 16 | + allPropertiesMap |
21 | 17 | end;
|
22 | 18 |
|
23 | 19 | methods
|
24 | 20 | function obj = Section(h)
|
25 |
| - |
26 |
| - obj.info = nix_mx('Section::describe', obj.nix_handle); |
27 |
| - |
28 |
| - obj.sectionsCache.lastUpdate = 0; |
29 |
| - obj.sectionsCache.data = {}; |
30 |
| - obj.propsCache.lastUpdate = 0; |
31 |
| - obj.propsCache.data = {}; |
32 |
| - end; |
33 |
| - |
34 |
| - function name = get.name(section) |
35 |
| - name = section.info.name; |
36 |
| - end; |
37 |
| - |
38 |
| - function id = get.id(section) |
39 |
| - id = section.info.id; |
40 |
| - end; |
41 |
| - |
42 |
| - function type = get.type(section) |
43 |
| - type = section.info.type; |
44 |
| - end; |
45 |
| - |
46 |
| - function repository = get.repository(section) |
47 |
| - repository = section.info.repository; |
48 |
| - end; |
49 |
| - |
50 |
| - function mapping = get.mapping(section) |
51 |
| - mapping = section.info.mapping; |
| 21 | + |
| 22 | + |
| 23 | + % assign dynamic properties |
| 24 | + obj.add_dyn_attr('repository', 'rw'); |
| 25 | + obj.add_dyn_attr('mapping', 'rw'); |
| 26 | + |
| 27 | + % assign relations |
| 28 | + obj.add_dyn_relation('sections', @nix.Section); |
| 29 | + |
| 30 | + obj.propsCache = nix.CacheStruct(); |
52 | 31 | end;
|
53 | 32 |
|
54 | 33 | function section = parent(obj)
|
55 |
| - sh = nix_mx('Section::parent', obj.nix_handle); |
56 |
| - if sh ~= 0 |
57 |
| - section = nix.Section(sh); |
58 |
| - else |
59 |
| - section = {}; |
| 34 | + handle = nix_mx('Section::parent', obj.nix_handle); |
| 35 | + section = {}; |
| 36 | + if handle ~= 0 |
| 37 | + section = nix.Section(handle); |
60 | 38 | end;
|
61 | 39 | end;
|
62 | 40 |
|
63 | 41 | function section = link(obj)
|
64 |
| - sh = nix_mx('Section::link', obj.nix_handle); |
65 |
| - if sh ~= 0 |
66 |
| - section = nix.Section(sh); |
67 |
| - else |
68 |
| - section = {}; |
| 42 | + handle = nix_mx('Section::link', obj.nix_handle); |
| 43 | + section = {}; |
| 44 | + if handle ~= 0 |
| 45 | + section = nix.Section(handle); |
69 | 46 | end;
|
70 | 47 | end;
|
71 | 48 |
|
72 | 49 | % ----------------
|
73 | 50 | % Section methods
|
74 | 51 | % ----------------
|
75 | 52 |
|
76 |
| - function sections = get.sections(obj) |
77 |
| - [obj.sectionsCache, sections] = nix.Utils.fetchObjList(obj.updatedAt, ... |
78 |
| - 'Section::sections', obj.nix_handle, obj.sectionsCache, @nix.Section); |
79 |
| - end |
80 |
| - |
81 | 53 | function retObj = open_section(obj, id_or_name)
|
82 | 54 | handle = nix_mx('Section::openSection', obj.nix_handle, id_or_name);
|
83 | 55 | retObj = {};
|
|
94 | 66 | % Property methods
|
95 | 67 | % ----------------
|
96 | 68 |
|
97 |
| - function props = get.properties_cell(obj) |
| 69 | + function props = get.allProperties(obj) |
98 | 70 | [obj.propsCache, props] = nix.Utils.fetchPropList(obj.updatedAt, ...
|
99 | 71 | 'Section::properties', obj.nix_handle, obj.propsCache);
|
100 | 72 | end
|
101 | 73 |
|
102 |
| - function p_map = get.properties_map(obj) |
| 74 | + function p_map = get.allPropertiesMap(obj) |
103 | 75 | p_map = containers.Map();
|
104 |
| - props = obj.properties_cell; |
| 76 | + props = obj.allProperties; |
105 | 77 |
|
106 | 78 | for i=1:length(props)
|
107 | 79 | p_map(props{i}.name) = cell2mat(props{i}.values);
|
|
0 commit comments