line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package xDT::RecordType; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19
|
use v5.10; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
15
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
xDT::RecordType - The record type of a xDT record. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Quick summary of what the module does. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Perhaps a little code snippet. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use xDT::RecordType; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $record_type = xDT::RecordType->new($id); |
19
|
|
|
|
|
|
|
# or |
20
|
|
|
|
|
|
|
my $record_type = xDT::RecordType->new($id, $config_file); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
say $record_type->get_labels()->{en}; |
23
|
|
|
|
|
|
|
say $record_type->get_accessor(); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 CONSTANTS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 LENGTH |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The maximum length of a record type identifier. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 END_RECORD_ID |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
ID of records at the end of an object. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use constant { |
38
|
1
|
|
|
|
|
574
|
LENGTH => 4, |
39
|
|
|
|
|
|
|
END_RECORD_ID => 8003, |
40
|
1
|
|
|
1
|
|
7622
|
}; |
|
1
|
|
|
|
|
3
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 id |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Unique identifier of this record type. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has id => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
isa => 'Str', |
53
|
|
|
|
|
|
|
required => 1, |
54
|
|
|
|
|
|
|
reader => 'get_id', |
55
|
|
|
|
|
|
|
trigger => \&_check_id, |
56
|
|
|
|
|
|
|
documentation => q{Unique identifier of this record type.}, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 labels |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The human readable labels of this record type. Language is used as key value. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has labels => ( |
66
|
|
|
|
|
|
|
is => 'ro', |
67
|
|
|
|
|
|
|
isa => 'Maybe[HashRef[Str]]', |
68
|
|
|
|
|
|
|
reader => 'get_labels', |
69
|
|
|
|
|
|
|
documentation => q{The human readable labels of this record type. Language is used as key value.}, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 accessor |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Short string for easy access to this record via xDT::Object. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has accessor => ( |
79
|
|
|
|
|
|
|
is => 'ro', |
80
|
|
|
|
|
|
|
isa => 'Str', |
81
|
|
|
|
|
|
|
required => 1, |
82
|
|
|
|
|
|
|
lazy => 1, |
83
|
|
|
|
|
|
|
reader => 'get_accessor', |
84
|
|
|
|
|
|
|
default => sub { shift->get_id }, |
85
|
|
|
|
|
|
|
documentation => q{Short string for easy access to this record via xDT::Object.}, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 length |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Max length of this record type. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
has length => ( |
95
|
|
|
|
|
|
|
is => 'ro', |
96
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
97
|
|
|
|
|
|
|
reader => 'get_length', |
98
|
|
|
|
|
|
|
documentation => q{Max length of this record type.}, |
99
|
|
|
|
|
|
|
); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 type |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Corresponds to xDT record type string. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has type => ( |
108
|
|
|
|
|
|
|
is => 'ro', |
109
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
110
|
|
|
|
|
|
|
reader => 'get_type', |
111
|
|
|
|
|
|
|
documentation => q{Corresponds to xDT record type string.}, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 is_object_end |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Checks if this record type is an ending record |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub is_object_end { |
123
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
return $self->get_id == END_RECORD_ID; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 get_id |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns the id of this record type. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 get_labels |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns the labels of this record type. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 get_accessor |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Returns the accessor of this record type. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 get_length |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns the maximum length of this recourd type. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 build_from_arrayref |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Constructs a C<RecordType> from a arrayref containing configurations. |
155
|
|
|
|
|
|
|
This method will propagate the hashref, that contains the provided id, to the C<new> method. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub build_from_arrayref { |
160
|
0
|
|
0
|
0
|
1
|
|
my $id = shift // die 'Error: parameter $id missing.'; |
161
|
0
|
|
|
|
|
|
my $arrayref = shift; |
162
|
0
|
|
|
|
|
|
my $config; |
163
|
|
|
|
|
|
|
|
164
|
0
|
0
|
|
|
|
|
($config) = grep { $_->{id} eq $id } @$arrayref |
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
if ($arrayref); |
166
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
$config = { id => $id, accessor => $id } unless ($config); |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
return xDT::RecordType->new($config); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub _check_id { |
174
|
0
|
|
|
0
|
|
|
my ($self, $id) = @_; |
175
|
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
die(sprintf("Error: attribute 'id' has length %d (should be %d).", length $id, LENGTH)) |
177
|
|
|
|
|
|
|
unless (length $id == LENGTH); |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 AUTHOR |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Christoph Beger, C<< <christoph.beger at medizin.uni-leipzig.de> >> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; # End of xDT::RecordType |