|
| 1 | +% Mixin Class for entities that can be associated with a nix.Source entity. |
| 2 | +% |
| 3 | +% In order to describe the provenance of data some entities of the NIX data model |
| 4 | +% can be associated with nix.Source entities. This class serves as a base class |
| 5 | +% for those. |
| 6 | +% |
| 7 | +% See also nix.Source, nix.Group, nix.DataArray, nix.Tag, nix.MultiTag. |
| 8 | +% |
| 9 | +% |
1 | 10 | % Copyright (c) 2016, German Neuroinformatics Node (G-Node)
|
2 | 11 | %
|
3 | 12 | % All rights reserved.
|
|
7 | 16 | % LICENSE file in the root of the Project.
|
8 | 17 |
|
9 | 18 | classdef SourcesMixIn < handle
|
10 |
| - % SourcesMixIn |
11 |
| - % mixin class for nix entities that can be related with sources |
12 | 19 |
|
13 | 20 | properties (Abstract, Hidden)
|
14 | 21 | alias
|
|
20 | 27 | end
|
21 | 28 |
|
22 | 29 | function r = sourceCount(obj)
|
| 30 | + % Get the number of direct child nix.Sources. |
| 31 | + % |
| 32 | + % Returns: (uint) The number of child Sources. |
| 33 | + % |
| 34 | + % Example: sc = currEntity.sourceCount(); |
| 35 | + % |
| 36 | + % See also nix.Source. |
| 37 | + |
23 | 38 | r = nix.Utils.fetchEntityCount(obj, 'sourceCount');
|
24 | 39 | end
|
25 | 40 |
|
26 |
| - % hasSource supports only check by id, not by name |
27 | 41 | function r = hasSource(obj, idEntity)
|
| 42 | + % Check if a nix.Source exists as a direct child of the invoking Entity. |
| 43 | + % |
| 44 | + % idEntity (char/nix.Source): ID of the Source or the Source itself. |
| 45 | + % |
| 46 | + % Returns: (logical) True if the Source exists, false otherwise. |
| 47 | + % |
| 48 | + % Example: check = currEntity.hasSource('some-source-id'); |
| 49 | + % check = currFile.blocks{1}.tags{1}.hasSource(newSourceEntity); |
| 50 | + % |
| 51 | + % See also nix.Source. |
| 52 | + |
28 | 53 | has = nix.Utils.parseEntityId(idEntity, 'nix.Source');
|
29 | 54 | r = nix.Utils.fetchHasEntity(obj, 'hasSource', has);
|
30 | 55 | end
|
31 | 56 |
|
32 |
| - function [] = addSource(obj, entity) |
33 |
| - nix.Utils.addEntity(obj, 'addSource', entity, 'nix.Source'); |
| 57 | + function [] = addSource(obj, idEntity) |
| 58 | + % Add an existing nix.Source to the referenced list of the invoking Entity. |
| 59 | + % |
| 60 | + % idEntity (char/nix.Source): The ID of an existing Source, |
| 61 | + % or a nix.Source entity. |
| 62 | + % |
| 63 | + % Example: currEntity.addSource('23bb8a99-1812-4bc6-a52c-45e96864756b'); |
| 64 | + % currFile.blocks{1}.groups{1}.addSource(newSourceEntity); |
| 65 | + % |
| 66 | + % See also nix.Source. |
| 67 | + |
| 68 | + nix.Utils.addEntity(obj, 'addSource', idEntity, 'nix.Source'); |
34 | 69 | end
|
35 | 70 |
|
36 | 71 | function [] = addSources(obj, entityArray)
|
| 72 | + % Set the list of referenced Sources for the invoking Entity. |
| 73 | + % |
| 74 | + % Previously referenced Sources that are not in the |
| 75 | + % references cell array will be removed. |
| 76 | + % |
| 77 | + % entityArray ([nix.Source]): A cell array of nix.Sources. |
| 78 | + % |
| 79 | + % Example: currEntity.addSources({source1, source2}); |
| 80 | + % |
| 81 | + % See also nix.Source. |
| 82 | + |
37 | 83 | nix.Utils.addEntityArray(obj, 'addSources', entityArray, 'nix.Source');
|
38 | 84 | end
|
39 | 85 |
|
40 |
| - function r = removeSource(obj, del) |
41 |
| - r = nix.Utils.deleteEntity(obj, 'removeSource', del, 'nix.Source'); |
| 86 | + function r = removeSource(obj, idEntity) |
| 87 | + % Removes the reference to a nix.Source from the invoking Entity. |
| 88 | + % |
| 89 | + % This method removes the association between the Source and the |
| 90 | + % Entity, the Source itself will not be removed from the file. |
| 91 | + % |
| 92 | + % idEntity (char/nix.Source): id of the Source to be removed |
| 93 | + % or the Source itself. |
| 94 | + % |
| 95 | + % Returns: (logical) True if the reference to the Source |
| 96 | + % has been removed, false otherwise. |
| 97 | + % |
| 98 | + % Example: check = currEntity.removeSource('23bb8a99-1812-4bc6-a52c'); |
| 99 | + % check = currFile.blocks{1}.groups{1}.removeSource(newSourceEntity); |
| 100 | + % |
| 101 | + % See also nix.Source. |
| 102 | + |
| 103 | + r = nix.Utils.deleteEntity(obj, 'removeSource', idEntity, 'nix.Source'); |
42 | 104 | end
|
43 | 105 |
|
44 | 106 | function r = openSource(obj, idName)
|
| 107 | + % Retrieves an existing Source from the invoking Entity. |
| 108 | + % |
| 109 | + % idName (char): Name or ID of the Source. |
| 110 | + % |
| 111 | + % Returns: (nix.Source) The nix.Source or an empty cell, |
| 112 | + % if the Source was not found. |
| 113 | + % |
| 114 | + % Example: getSource = currEntity.openSource('23bb8a99-1812-4bc6-a52c'); |
| 115 | + % getSource = currFile.blocks{1}.tags{1}.openSource('subTrial2'); |
| 116 | + % |
| 117 | + % See also nix.Source. |
| 118 | + |
45 | 119 | r = nix.Utils.openEntity(obj, 'openSource', idName, @nix.Source);
|
46 | 120 | end
|
47 | 121 |
|
48 | 122 | function r = openSourceIdx(obj, index)
|
| 123 | + % Retrieves an existing nix.Source from the invoking Entity, |
| 124 | + % accessed by index. |
| 125 | + % |
| 126 | + % index (double): The index of the Source to read. |
| 127 | + % |
| 128 | + % Returns: (nix.Source) The Source at the given index. |
| 129 | + % |
| 130 | + % Example: getSource = currEntity.openSourceIdx(1); |
| 131 | + % |
| 132 | + % See also nix.Source. |
| 133 | + |
49 | 134 | idx = nix.Utils.handleIndex(index);
|
50 | 135 | r = nix.Utils.openEntity(obj, 'openSourceIdx', idx, @nix.Source);
|
51 | 136 | end
|
52 | 137 |
|
53 | 138 | function r = filterSources(obj, filter, val)
|
| 139 | + % Get a filtered cell array of all Source entities |
| 140 | + % referenced by the invoking Entity. |
| 141 | + % |
| 142 | + % filter (nix.Filter): The nix.Filter to be applied. |
| 143 | + % val (char): Value that is applied with the selected |
| 144 | + % filter. |
| 145 | + % |
| 146 | + % Returns: ([nix.Source]) A cell array of Sources filtered according |
| 147 | + % to the applied nix.Filter. |
| 148 | + % |
| 149 | + % Example: getSources = currEntity.filterSources(... |
| 150 | + % nix.Filter.type, 'ephys_data'); |
| 151 | + % |
| 152 | + % See also nix.Source, nix.Filter. |
| 153 | + |
54 | 154 | r = nix.Utils.filter(obj, 'sourcesFiltered', filter, val, @nix.Source);
|
55 | 155 | end
|
56 | 156 | end
|
|
0 commit comments