-
Notifications
You must be signed in to change notification settings - Fork 9
/
EpochGroup.m
89 lines (68 loc) · 2.54 KB
/
EpochGroup.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
% Copyright (c) 2012 Howard Hughes Medical Institute.
% All rights reserved.
% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms.
% http://license.janelia.org/license/jfrc_copyright_1_1.html
classdef EpochGroup < handle
properties
outputPath
label
keywords
source
identifier
startTime
userProperties = struct()
parentGroup
childGroups
end
methods
function obj = EpochGroup(parentGroup, startTime)
% Add to the group hierarchy.
obj.parentGroup = parentGroup;
if ~isempty(parentGroup)
parentGroup.childGroups(end + 1) = obj;
end
obj.childGroups = EpochGroup.empty(1, 0);
obj.identifier = System.Guid.NewGuid();
obj.startTime = startTime;
end
function setUserProperty(obj, propName, propValue)
obj.userProperties.(propName) = propValue;
end
function v = userProperty(obj, propName)
v = obj.userProperties.(propName);
end
function g = rootGroup(obj)
if isempty(obj.parentGroup)
g = obj;
else
g = obj.parentGroup.rootGroup();
end
end
function beginPersistence(obj, persistor)
% Convert the keywords and properties to .NET equivalents.
keywordsCA = strtrim(regexp(obj.keywords, ',', 'split'));
if isequal(keywordsCA, {''})
keywordsCA = {};
end
keywordsArray = NET.createArray('System.String', numel(keywordsCA));
for i = 1:numel(keywordsCA)
keywordsArray(i) = keywordsCA{i};
end
propertiesDict = structToDictionary(obj.userProperties);
if isempty(obj.source)
sourceString = '';
else
sourceString = char(obj.source.identifier.ToString());
end
persistor.BeginEpochGroup(obj.label, sourceString, keywordsArray, propertiesDict, obj.identifier, obj.startTime);
end
function endPersistence(obj, persistor) %#ok<MANU>
persistor.EndEpochGroup();
end
function delete(obj)
for i = 1:length(obj.childGroups)
delete(obj.childGroups(i));
end
end
end
end