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