|
| 1 | +% Mixin Class for entities that can be associated with additional metadata. |
| 2 | +% |
| 3 | +% The data part of the NIX data model consists of six main elements which all inherit |
| 4 | +% from the MetadataMixin Class: nix.Block, nix.Group, nix.DataArray, nix.Tag, |
| 5 | +% nix.MultiTag and nix.Source. |
| 6 | +% Common to all those entities is an optional property sections which provides a link |
| 7 | +% to one nix.Section entity and therefore makes it possible to annotate the entities |
| 8 | +% with additional metadata. |
| 9 | +% |
| 10 | +% Depends on nix.Entity. |
| 11 | +% |
| 12 | +% See also nix.Section, nix.Block, nix.Group, nix.DataArray, nix.Tag, nix.MultiTag, nix.Source, nix.Entity. |
| 13 | +% |
| 14 | +% |
1 | 15 | % Copyright (c) 2016, German Neuroinformatics Node (G-Node)
|
2 | 16 | %
|
3 | 17 | % All rights reserved.
|
|
7 | 21 | % LICENSE file in the root of the Project.
|
8 | 22 |
|
9 | 23 | classdef MetadataMixIn < handle
|
10 |
| - %MetadataMixIn |
11 |
| - % mixin class for nix entities with metadata |
12 |
| - % depends on |
13 |
| - % - nix.Entity |
14 | 24 |
|
15 | 25 | properties (Abstract, Hidden)
|
16 | 26 | alias
|
17 | 27 | end
|
18 | 28 |
|
19 | 29 | methods
|
20 | 30 | function r = openMetadata(obj)
|
| 31 | + % Retrieves the referenced nix.Section from the invoking nix.Entity. |
| 32 | + % |
| 33 | + % Returns: (nix.Section) The Section or an empty cell, |
| 34 | + % if the Section was not found. |
| 35 | + % |
| 36 | + % Example: getSec = currEntity.openMetadata(); |
| 37 | + % |
| 38 | + % See also nix.Section. |
| 39 | + |
21 | 40 | r = nix.Utils.fetchObj(obj, 'openMetadataSection', @nix.Section);
|
22 | 41 | end
|
23 | 42 |
|
24 |
| - function [] = setMetadata(obj, val) |
25 |
| - if (isempty(val)) |
| 43 | + function [] = setMetadata(obj, idEntity) |
| 44 | + % Set a nix.Section as metadata of the invoking nix.Entity. |
| 45 | + % |
| 46 | + % If metadata was already set, using this method again will |
| 47 | + % replace the reference to the previous Section with a reference |
| 48 | + % to the provided Section. |
| 49 | + % |
| 50 | + % The link to a Section can be removed by handing an empty string |
| 51 | + % to the method. The referenced Section itself will not be removed. |
| 52 | + % |
| 53 | + % idEntity (char/nix.Section): The id of an existing Section, |
| 54 | + % or a valid nix.Section entity. |
| 55 | + % |
| 56 | + % Example: currEntity.setMetadata('some-section-id'); |
| 57 | + % currEntity.setMetadata(currFile.sections{1}); |
| 58 | + % currEntity.setMetadata(''); % remove reference to section |
| 59 | + % |
| 60 | + % See also nix.Section. |
| 61 | + |
| 62 | + if (isempty(idEntity)) |
26 | 63 | fname = strcat(obj.alias, '::setNoneMetadata');
|
27 |
| - nix_mx(fname, obj.nixhandle, val); |
| 64 | + nix_mx(fname, obj.nixhandle, idEntity); |
28 | 65 | else
|
29 |
| - nix.Utils.addEntity(obj, 'setMetadata', val, 'nix.Section'); |
| 66 | + nix.Utils.addEntity(obj, 'setMetadata', idEntity, 'nix.Section'); |
30 | 67 | end
|
31 | 68 | end
|
32 | 69 | end
|
|
0 commit comments