Gaudi Framework, version v25r0
Home
Generated: Mon Feb 17 2014
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
GaudiCommonSvc
src
AlgContextSvc.cpp
Go to the documentation of this file.
1
// ============================================================================
2
// Include files
3
// ============================================================================
4
// GaudiKernel
5
// ============================================================================
6
#include "
GaudiKernel/MsgStream.h
"
7
#include "
GaudiKernel/ISvcLocator.h
"
8
#include "
GaudiKernel/IIncidentSvc.h
"
9
// ============================================================================
10
// Local
11
// ============================================================================
12
#include "
AlgContextSvc.h
"
13
// ============================================================================
20
// ============================================================================
24
DECLARE_COMPONENT
(
AlgContextSvc
)
25
// ============================================================================
26
// Standard Constructor
27
// ============================================================================
28
AlgContextSvc
::
AlgContextSvc
29
( const
std
::
string
& name ,
30
ISvcLocator
* svc )
31
:
base_class
( name , svc )
32
, m_algorithms ( 0 )
33
, m_inc ( 0 )
34
, m_check ( true )
35
{
36
declareProperty (
"Check"
, m_check ,
"Flag to perform more checks"
);
37
}
38
// ============================================================================
39
// Standard Destructor
40
// ============================================================================
41
AlgContextSvc::~AlgContextSvc
() {}
42
// ============================================================================
43
// standard initialization of the service
44
// ============================================================================
45
StatusCode
AlgContextSvc::initialize
()
46
{
47
// Initialize the base class
48
StatusCode
sc
=
Service::initialize
() ;
49
if
( sc.
isFailure
() ) {
return
sc
; }
50
// Incident Service
51
if
( 0 !=
m_inc
)
52
{
53
m_inc
-> removeListener (
this
) ;
54
m_inc
->
release
() ;
55
m_inc
= 0 ;
56
}
57
// perform more checks?
58
if
(
m_check
)
59
{
60
sc =
Service::service
(
"IncidentSvc"
,
m_inc
,
true
) ;
61
if
( sc.
isFailure
() )
62
{
63
MsgStream
log
(
msgSvc
() ,
name
() ) ;
64
log <<
MSG::ERROR
<<
"Could not locate 'IncidentSvc'"
<< sc <<
endmsg
;
65
return
sc
;
// RETURN
66
}
67
if
( 0 ==
m_inc
)
68
{
69
MsgStream
log
(
msgSvc
() ,
name
() ) ;
70
log <<
MSG::ERROR
<<
"Invalid pointer to IIncindentSvc"
<<
endmsg
;
71
return
StatusCode::FAILURE
;
// RETURN
72
}
73
m_inc
-> addListener (
this
,
IncidentType::BeginEvent
) ;
74
m_inc
-> addListener (
this
,
IncidentType::EndEvent
) ;
75
}
76
if
( !
m_algorithms
.
empty
() )
77
{
78
MsgStream
log
(
msgSvc
() ,
name
() ) ;
79
log <<
MSG::WARNING
80
<<
"Non-empty stack of algorithms #"
81
<<
m_algorithms
.
size
() <<
endmsg
;
82
}
83
return
StatusCode::SUCCESS
;
84
}
85
// ============================================================================
86
// standard finalization of the service @see IService
87
// ============================================================================
88
StatusCode
AlgContextSvc::finalize
()
89
{
90
if
( !
m_algorithms
.
empty
() )
91
{
92
MsgStream
log
(
msgSvc
() ,
name
() ) ;
93
log <<
MSG::WARNING
94
<<
"Non-empty stack of algorithms #"
95
<<
m_algorithms
.
size
() <<
endmsg
;
96
}
97
// Incident Service
98
if
( 0 !=
m_inc
)
99
{
100
m_inc
-> removeListener (
this
) ;
101
m_inc
->
release
() ;
102
m_inc
= 0 ;
103
}
104
// finalize the base class
105
return
Service::finalize
() ;
106
}
107
// ============================================================================
108
// set the currently executing algorithm ("push_back") @see IAlgContextSvc
109
// ============================================================================
110
StatusCode
AlgContextSvc::setCurrentAlg
(
IAlgorithm
* a )
111
{
112
if
( 0 == a )
113
{
114
MsgStream
log
(
msgSvc
() ,
name
() ) ;
115
log <<
MSG::WARNING
<<
"IAlgorithm* points to NULL"
<<
endmsg
;
116
//
117
return
StatusCode::RECOVERABLE
;
// RETURN
118
}
119
m_algorithms
.
push_back
( a ) ;
120
//
121
return
StatusCode::SUCCESS
;
// RETURN
122
}
123
// ============================================================================
124
// remove the algorithm ("pop_back") @see IAlgContextSvc
125
// ============================================================================
126
StatusCode
AlgContextSvc::unSetCurrentAlg
(
IAlgorithm
* a )
127
{
128
if
( 0 == a )
129
{
130
MsgStream
log
(
msgSvc
() ,
name
() ) ;
131
log <<
MSG::WARNING
<<
"IAlgorithm* points to NULL"
<<
endmsg
;
132
//
133
return
StatusCode::RECOVERABLE
;
// RETURN
134
}
135
if
(
m_algorithms
.
empty
() ||
m_algorithms
.
back
() != a )
136
{
137
MsgStream
log
(
msgSvc
() ,
name
() ) ;
138
log <<
MSG::ERROR
<<
"Algorithm stack is invalid"
<<
endmsg
;
139
//
140
return
StatusCode::FAILURE
;
141
}
142
//
143
m_algorithms
.
pop_back
() ;
// POP_BACK
144
//
145
return
StatusCode::SUCCESS
;
146
}
147
// ============================================================================
149
// ============================================================================
150
IAlgorithm
*
AlgContextSvc::currentAlg
()
const
151
{
return
m_algorithms
.
empty
() ? 0 :
m_algorithms
.
back
() ; }
152
// ============================================================================
153
// handle incident @see IIncidentListener
154
// ============================================================================
155
void
AlgContextSvc::handle
(
const
Incident
& )
156
{
157
if
( !
m_algorithms
.
empty
() )
158
{
159
MsgStream
log
(
msgSvc
() ,
name
() ) ;
160
log <<
MSG::ERROR
161
<<
"Non-empty stack of algorithms #"
162
<<
m_algorithms
.
size
() <<
endmsg
;
163
}
164
}
165
// ============================================================================
166
167
168
169
170
// ============================================================================
172
// ============================================================================
Generated at Mon Feb 17 2014 14:37:39 for Gaudi Framework, version v25r0 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004