line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------------------------ |
2
|
|
|
|
|
|
|
# OBJET : "Classe abstraite" des modules de CTM |
3
|
|
|
|
|
|
|
# APPLICATION : Control-M |
4
|
|
|
|
|
|
|
# AUTEUR : Yoann Le Garff |
5
|
|
|
|
|
|
|
# DATE DE CREATION : 09/05/2014 |
6
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------------------------ |
7
|
|
|
|
|
|
|
# USAGE / AIDE |
8
|
|
|
|
|
|
|
# perldoc CTM::Base |
9
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------------------------ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#-> BEGIN |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----> ** initialisation ** |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package CTM::Base; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
14
|
use 5.6.1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
20
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use constant { |
23
|
1
|
|
|
|
|
219
|
_baseClass => 'CTM::Base', |
24
|
|
|
|
|
|
|
_baseMainClass => 'CTM::Base::MainClass', |
25
|
|
|
|
|
|
|
_baseSubClass => 'CTM::Base::SubClass', |
26
|
|
|
|
|
|
|
_rootClassEM => 'CTM::ReadEM', |
27
|
|
|
|
|
|
|
_rootClassEMPrivate => '_CTM::ReadEM', |
28
|
|
|
|
|
|
|
_rootClassServer => 'CTM::ReadServer', |
29
|
|
|
|
|
|
|
_rootClassServerPrivate => '_CTM::ReadServer', |
30
|
|
|
|
|
|
|
_verboseObjProperty => 'verbose', |
31
|
|
|
|
|
|
|
_workingObjProperty => '_working', |
32
|
|
|
|
|
|
|
_errorsObjProperty => '_errors', |
33
|
|
|
|
|
|
|
_DBIObjProperty => '_DBI', |
34
|
|
|
|
|
|
|
_sessionIsConnectedObjProperty => '_sessionIsConnected', |
35
|
|
|
|
|
|
|
_paramsObjProperty => '_params', |
36
|
|
|
|
|
|
|
_subClassDatasObjProperty => '_datas', |
37
|
|
|
|
|
|
|
_nbSessionsInstancedClassProperty => 'nbSessionsInstanced', |
38
|
|
|
|
|
|
|
_nbSessionsConnectedClassProperty => 'nbSessionsConnected', |
39
|
|
|
|
|
|
|
_currentBIMServicesModuleLastName => 'WorkOnCurrentBIMServices', |
40
|
|
|
|
|
|
|
_currentBIMServicesBaseMethod => 'getCurrentBIMServices', |
41
|
|
|
|
|
|
|
_currentBIMServicesWorkMethod => 'workOnCurrentBIMServices', |
42
|
|
|
|
|
|
|
_alarmsModuleLastName => 'WorkOnAlarms', |
43
|
|
|
|
|
|
|
_alarmsBaseMethod => 'getAlarms', |
44
|
|
|
|
|
|
|
_alarmsWorkMethod => 'workOnAlarms', |
45
|
|
|
|
|
|
|
_exceptionAlertsModuleLastName => 'WorkOnExceptionAlerts', |
46
|
|
|
|
|
|
|
_exceptionAlertsBaseMethod => 'getExceptionAlerts', |
47
|
|
|
|
|
|
|
_exceptionAlertsWorkMethod => 'workOnExceptionAlerts', |
48
|
|
|
|
|
|
|
_componentsModuleLastName => 'WorkOnComponents', |
49
|
|
|
|
|
|
|
_componentsBaseMethod => 'getComponents', |
50
|
|
|
|
|
|
|
_componentsWorkMethod => 'workOnComponents' |
51
|
1
|
|
|
1
|
|
4
|
}; |
|
1
|
|
|
|
|
1
|
|
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
51
|
use Carp qw/ |
54
|
|
|
|
|
|
|
carp |
55
|
|
|
|
|
|
|
croak |
56
|
1
|
|
|
1
|
|
4
|
/; |
|
1
|
|
|
|
|
1
|
|
57
|
1
|
|
|
|
|
6
|
use Hash::Util qw/ |
58
|
|
|
|
|
|
|
lock_hash |
59
|
|
|
|
|
|
|
unlock_hash |
60
|
|
|
|
|
|
|
lock_value |
61
|
|
|
|
|
|
|
unlock_value |
62
|
1
|
|
|
1
|
|
683
|
/; |
|
1
|
|
|
|
|
2423
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#----> ** variables de classe ** |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
our $VERSION = 0.181; |
67
|
|
|
|
|
|
|
our $AUTOLOAD; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#----> ** fonctions privees (mais accessibles a l'utilisateur pour celles qui ne sont pas des references) ** |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _myErrorMessage($$) { |
72
|
1
|
|
|
1
|
|
3
|
my ($subroutine, $message) = @_; |
73
|
1
|
|
|
|
|
4
|
return "'" . $subroutine . "()' : " . $message; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _myUsageMessage($$) { |
77
|
0
|
|
|
0
|
|
0
|
my ($namespace, $properties) = @_; |
78
|
0
|
|
|
|
|
0
|
return 'USAGE : ' . (split /::/, $namespace)[-1] . '(' . $properties . ').'; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#----> ** methodes protegees ** |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _invokeVerbose { |
84
|
0
|
|
|
0
|
|
0
|
my ($self, $subroutine, $message) = @_; |
85
|
0
|
0
|
|
|
|
0
|
if (caller->isa(__PACKAGE__)) { |
86
|
0
|
0
|
|
|
|
0
|
printf STDERR "VERBOSE - '%s()' : %s", $subroutine, $message if ($self->{+_verboseObjProperty}); |
87
|
|
|
|
|
|
|
} else { |
88
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage((caller 0)[3], "tentative d'utilisation d'une methode protegee.")); |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
0
|
return 0; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#-> accesseurs/mutateurs |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _setObjProperty { |
96
|
0
|
|
|
0
|
|
0
|
my ($self, $property, $value) = @_; |
97
|
0
|
0
|
|
|
|
0
|
if (caller->isa(__PACKAGE__)) { |
98
|
0
|
|
|
|
|
0
|
my $action = exists $self->{$property}; |
99
|
0
|
0
|
|
|
|
0
|
$action ? unlock_value(%{$self}, $property) : unlock_hash(%{$self}); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
100
|
0
|
|
|
|
|
0
|
$self->{$property} = $value; |
101
|
0
|
0
|
|
|
|
0
|
$action ? lock_value(%{$self}, $property) : lock_hash(%{$self}); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
102
|
0
|
|
|
|
|
0
|
return 1; |
103
|
|
|
|
|
|
|
} else { |
104
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage((caller 0)[3], "tentative d'utilisation d'une methode protegee.")); |
105
|
|
|
|
|
|
|
} |
106
|
0
|
|
|
|
|
0
|
return 0; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _isWorking { |
110
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
111
|
0
|
0
|
|
|
|
0
|
if (caller->isa(__PACKAGE__)) { |
112
|
0
|
|
|
|
|
0
|
return $self->{+_workingObjProperty}; |
113
|
|
|
|
|
|
|
} else { |
114
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage((caller 0)[3], "tentative d'utilisation d'une methode protegee.")); |
115
|
|
|
|
|
|
|
} |
116
|
0
|
|
|
|
|
0
|
return 0; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _tagAtWork { |
120
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
121
|
0
|
0
|
|
|
|
0
|
if (caller->isa(__PACKAGE__)) { |
122
|
0
|
|
|
|
|
0
|
return $self->_setObjProperty(+_workingObjProperty, 1); |
123
|
|
|
|
|
|
|
} else { |
124
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage((caller 0)[3], "tentative d'utilisation d'une methode protegee.")); |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
0
|
return 0; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _tagAtRest { |
130
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
131
|
0
|
0
|
|
|
|
0
|
if (caller->isa(__PACKAGE__)) { |
132
|
0
|
|
|
|
|
0
|
return $self->_setObjProperty(+_workingObjProperty, 0); |
133
|
|
|
|
|
|
|
} else { |
134
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage((caller 0)[3], "tentative d'utilisation d'une methode protegee.")); |
135
|
|
|
|
|
|
|
} |
136
|
0
|
|
|
|
|
0
|
return 0; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub _addError { |
140
|
2
|
|
|
2
|
|
3
|
my ($self, $value) = @_; |
141
|
2
|
50
|
|
|
|
8
|
if (caller->isa(__PACKAGE__)) { |
142
|
2
|
|
|
|
|
2
|
unlock_value(%{$self}, _errorsObjProperty); |
|
2
|
|
|
|
|
6
|
|
143
|
2
|
|
|
|
|
8
|
unshift @{$self->getErrors()}, $value; |
|
2
|
|
|
|
|
11
|
|
144
|
2
|
|
|
|
|
3
|
lock_value(%{$self}, _errorsObjProperty); |
|
2
|
|
|
|
|
6
|
|
145
|
2
|
|
|
|
|
15
|
return 1; |
146
|
|
|
|
|
|
|
} else { |
147
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage((caller 0)[3], "tentative d'utilisation d'une methode protegee.")); |
148
|
|
|
|
|
|
|
} |
149
|
0
|
|
|
|
|
0
|
return 0; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#----> ** methodes publiques ** |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#-> accesseurs/mutateurs |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub getProperty { |
157
|
0
|
|
|
0
|
0
|
0
|
my ($self, $property) = @_; |
158
|
0
|
|
|
|
|
0
|
my $subName = (caller 0)[3]; |
159
|
0
|
0
|
|
|
|
0
|
croak(_myErrorMessage($subName, _myUsageMessage('$obj->' . $subName, '$definedPropertyName'))) unless (defined $property); |
160
|
0
|
|
|
|
|
0
|
$self->unshiftError(); |
161
|
0
|
0
|
|
|
|
0
|
return $self->{$property} if (exists $self->{$property}); |
162
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage($subName, "propriete ('" . $property . "') inexistante.")); |
163
|
0
|
|
|
|
|
0
|
return 0; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub setPublicProperty { |
167
|
0
|
|
|
0
|
0
|
0
|
my ($self, $property, $value) = @_; |
168
|
0
|
|
|
|
|
0
|
my $subName = (caller 0)[3]; |
169
|
0
|
0
|
|
|
|
0
|
croak(_myErrorMessage($subName, _myUsageMessage('$obj->' . $subName, '$definedPropertyName, $definedValue'))) unless (defined $property); |
170
|
0
|
|
|
|
|
0
|
$self->unshiftError(); |
171
|
0
|
0
|
|
|
|
0
|
unless (exists $self->{$property}) { |
|
|
0
|
|
|
|
|
|
172
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage($subName, "tentative de creation d'une propriete ('" . $property . "').")); |
173
|
|
|
|
|
|
|
} elsif (substr($property, 0, 1) eq '_') { |
174
|
0
|
|
|
|
|
0
|
carp(_myErrorMessage($subName, "tentative de modication d'une propriete ('" . $property . "') protegee ou privee.")); |
175
|
|
|
|
|
|
|
} else { |
176
|
0
|
|
|
|
|
0
|
return $self->_setObjProperty($property, $value); |
177
|
|
|
|
|
|
|
} |
178
|
0
|
|
|
|
|
0
|
return 0; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub getErrors { |
182
|
2
|
|
|
2
|
0
|
4
|
return shift->{+_errorsObjProperty}; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub getError { |
186
|
0
|
|
|
0
|
0
|
0
|
my ($self, $arrayItem) = @_; |
187
|
0
|
0
|
0
|
|
|
0
|
return $self->getErrors()->[(defined $arrayItem && $arrayItem =~ /^[\+\-]?\d+$/) ? $arrayItem : 0]; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub countErrors { |
191
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
192
|
0
|
|
|
|
|
0
|
return scalar @{$self->getErrors()}; |
|
0
|
|
|
|
|
0
|
|
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub unshiftError { |
196
|
1
|
|
|
1
|
0
|
6
|
return shift->_addError(undef); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub clearErrors { |
200
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
201
|
0
|
|
|
|
|
|
unlock_value(%{$self}, _errorsObjProperty); |
|
0
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
@{$self->getErrors()} = (); |
|
0
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
lock_value(%{$self}, _errorsObjProperty); |
|
0
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
return 1; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
#-> Perl BuiltIn |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub AUTOLOAD { |
210
|
0
|
|
|
0
|
|
|
my $self = shift; |
211
|
0
|
0
|
|
|
|
|
if ($AUTOLOAD) { |
212
|
|
|
|
|
|
|
# no strict qw/refs/; |
213
|
0
|
|
|
|
|
|
(my $called = $AUTOLOAD) =~ s/.*:://; |
214
|
0
|
0
|
|
|
|
|
croak("'" . $AUTOLOAD . "()' est introuvable.") unless (exists $self->{$called}); |
215
|
0
|
|
|
|
|
|
return $self->{$called}; |
216
|
|
|
|
|
|
|
} |
217
|
0
|
|
|
|
|
|
return undef; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
1; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
#-> END |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
__END__ |