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