forked from jgte/orb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnrtdm_product.m
More file actions
89 lines (88 loc) · 2.71 KB
/
nrtdm_product.m
File metadata and controls
89 lines (88 loc) · 2.71 KB
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
%This object defines details of the product
classdef nrtdm_product
properties(GetAccess = 'private', SetAccess = 'private')
sep_index
debug
end
properties(Dependent)
category
name
sat
field
file
end
properties(GetAccess = 'public', SetAccess = 'private')
str
end
methods(Static)
function test
if exist(nrtdm.config_dir,'dir')
disp([mfilename,':WARNING: cannot find NRTDM config dir: ',nrtdm.config_dir,'. Skipping test.'])
return
end
%TODO: complete this test
end
end
methods
function obj=nrtdm_product(product_name,debug)
if ~exist('debug','var') || isempty(debug)
debug=false;
end
if (debug); disp(['start:',current_method]); end
%initialize
obj.str=product_name;
obj.debug=debug;
obj.sep_index=strfind(product_name,'/');
%sanity
if (numel(obj.sep_index) < 1) || (numel(obj.sep_index) > 2)
error([mfilename,'Can not handle product ''',obj.str,'''.'])
end
if numel(obj.sep_index)==1
obj.sep_index=[obj.sep_index,length(product_name)+1];
end
if (obj.debug); disp(['end :',current_method]); end
end
function out=get.category(obj)
if (obj.debug); disp(['start:',current_method]); end
out=obj.str(1:obj.sep_index(1)-1);
if (obj.debug); disp(['end :',current_method,':',out]); end
end
function out=get.name(obj)
if (obj.debug); disp(['start:',current_method]); end
out=obj.str(obj.sep_index(1)+1:obj.sep_index(2)-1);
if (obj.debug); disp(['end :',current_method,':',out]); end
end
function out=get.sat(obj)
if (obj.debug); disp(['start:',current_method]); end
out=obj.str(1:min(strfind(obj.str,'_')-1));
if (obj.debug); disp(['end :',current_method,':',out]); end
end
function out=get.field(obj)
if (obj.debug); disp(['start:',current_method]); end
if obj.sep_index(2)>length(obj.str)
out=0;
else
out=obj.str(obj.sep_index(2)+1:end);
field_index=strfind(out,'-');
if isempty(field_index)
out=str2double(out);
else
out=str2double(out(1:field_index-1)):str2double(out(field_index+1:end));
end
end
if (obj.debug); disp(['end :',current_method,':',num2str(out)]); end
end
function out=get.file(obj)
if (obj.debug); disp(['start:',current_method]); end
out=fullfile(nrtdm.config_dir,[obj.category,'.products.txt']);
if ~exist(out,'file')
error([mfilename,': Cannot find metadata files ''',out,'''.'])
end
if (obj.debug); disp(['end :',current_method,':',out]); end
end
end
end
function out=current_method
s=dbstack;
out=s(2).name;
end