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
GaudiKernel
GaudiKernel
Service.h
Go to the documentation of this file.
1
// $Id: Service.h,v 1.23 2008/06/02 14:20:37 marcocle Exp $
2
// ============================================================================
3
#ifndef GAUDIKERNEL_SERVICE_H
4
#define GAUDIKERNEL_SERVICE_H
5
// ============================================================================
6
// Include files
7
// ============================================================================
8
#include "
GaudiKernel/IService.h
"
9
#include "
GaudiKernel/ISvcLocator.h
"
10
#include "
GaudiKernel/ServiceLocatorHelper.h
"
11
#include "
GaudiKernel/IProperty.h
"
12
#include "
GaudiKernel/IStateful.h
"
13
#include "
GaudiKernel/PropertyMgr.h
"
14
#include "
GaudiKernel/Property.h
"
15
#include "
GaudiKernel/IAuditorSvc.h
"
16
#include "
GaudiKernel/CommonMessaging.h
"
17
#include "
GaudiKernel/SmartIF.h
"
18
// ============================================================================
19
#include <
vector
>
20
// ============================================================================
21
// Forward declarations
22
// ============================================================================
23
class
IMessageSvc
;
24
class
ISvcManager
;
25
class
ServiceManager
;
26
// ============================================================================
34
class
GAUDI_API
Service
:
public
CommonMessaging
<implements3<IService, IProperty, IStateful> > {
35
public
:
36
friend
class
ServiceManager
;
37
40
virtual
unsigned
long
release
();
41
43
virtual
const
std::string
&
name
()
const
;
44
45
// State machine implementation
46
virtual
StatusCode
configure
() {
return
StatusCode::SUCCESS
; }
47
virtual
StatusCode
initialize
();
48
virtual
StatusCode
start
();
49
virtual
StatusCode
stop
();
50
virtual
StatusCode
finalize
();
51
virtual
StatusCode
terminate
() {
return
StatusCode::SUCCESS
; }
52
virtual
Gaudi::StateMachine::State
FSMState
()
const
{
return
m_state; }
53
virtual
Gaudi::StateMachine::State
targetFSMState
()
const
{
return
m_targetState; }
54
virtual
StatusCode
reinitialize
();
55
virtual
StatusCode
restart
();
56
58
virtual
StatusCode
sysInitialize();
60
virtual
StatusCode
sysStart();
62
virtual
StatusCode
sysStop();
64
virtual
StatusCode
sysFinalize();
66
virtual
StatusCode
sysReinitialize();
68
virtual
StatusCode
sysRestart();
69
70
// Default implementations for ISetProperty
71
virtual
StatusCode
setProperty
(
const
Property
& p);
72
virtual
StatusCode
setProperty
(
const
std::string
&
s
);
73
virtual
StatusCode
setProperty
(
const
std::string
& n,
const
std::string
& v);
74
virtual
StatusCode
getProperty
(
Property
* p)
const
;
75
virtual
const
Property
&
getProperty
(
const
std::string
&
name
)
const
;
76
virtual
StatusCode
getProperty
(
const
std::string
& n,
std::string
& v )
const
;
77
virtual
const
std::vector<Property*>
& getProperties( )
const
;
78
119
template
<
class
TYPE>
120
StatusCode
setProperty
121
(
const
std::string
&
name
,
122
const
TYPE& value )
123
{
return
Gaudi::Utils::setProperty
( m_propertyMgr , name , value ) ; }
124
126
Service
(
const
std::string
& name,
ISvcLocator
* svcloc);
128
SmartIF<ISvcLocator>
&
serviceLocator
()
const
;
129
133
StatusCode
setProperties();
134
137
template
<
class
T>
138
StatusCode
service
(
const
std::string
& name,
const
T*& psvc,
bool
createIf =
true
)
const
{
139
ISvcLocator
& svcLoc = *
serviceLocator
();
140
SmartIF<T>
ptr(
141
ServiceLocatorHelper
(svcLoc, *
this
).
service
(name, !createIf,
// quiet
142
createIf));
143
if
(ptr.
isValid
()) {
144
psvc = ptr.
get
();
145
const_cast<
T*
>
(psvc)->
addRef
();
146
return
StatusCode::SUCCESS
;
147
}
148
// else
149
psvc = 0;
150
return
StatusCode::FAILURE
;
151
}
152
153
template
<
class
T>
154
StatusCode
service
(
const
std::string
& name, T*& psvc,
bool
createIf =
true
)
const
{
155
ISvcLocator
& svcLoc = *
serviceLocator
();
156
SmartIF<T>
ptr(
157
ServiceLocatorHelper
(svcLoc, *
this
).
service
(name, !createIf,
// quiet
158
createIf));
159
if
(ptr.
isValid
()) {
160
psvc = ptr.
get
();
161
psvc->addRef();
162
return
StatusCode::SUCCESS
;
163
}
164
// else
165
psvc = 0;
166
return
StatusCode::FAILURE
;
167
}
168
171
template
<
class
T>
172
StatusCode
service
(
const
std::string
& svcType,
const
std::string
& svcName,
173
T*& psvc)
const
{
174
return
service
(svcType +
"/"
+ svcName, psvc);
175
}
176
// ==========================================================================
205
template
<
class
T>
206
Property
* declareProperty
207
(
const
std::string
& name ,
208
T& property ,
209
const
std::string
& doc =
"none"
)
const
210
{
211
return
m_propertyMgr -> declareProperty ( name , property , doc ) ;
212
}
213
// ==========================================================================
222
Property
* declareRemoteProperty
223
(
const
std::string
& name ,
224
IProperty
* rsvc ,
225
const
std::string
& rname =
""
)
const
226
{
227
return
m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname ) ;
228
}
229
// ==========================================================================
233
SmartIF<IAuditorSvc>
& auditorSvc()
const
;
234
235
protected
:
237
virtual
~
Service
();
239
IntegerProperty
m_outputLevel
;
241
Gaudi::StateMachine::State
m_state
;
243
Gaudi::StateMachine::State
m_targetState
;
244
246
int
outputLevel
()
const
{
return
m_outputLevel.value(); }
247
248
private
:
250
std::string
m_name
;
252
mutable
SmartIF<ISvcLocator>
m_svcLocator
;
253
SmartIF<ISvcManager>
m_svcManager
;
255
PropertyMgr
*
m_propertyMgr
;
256
257
void
setServiceManager(
ISvcManager
* ism);
258
260
mutable
SmartIF<IAuditorSvc>
m_pAuditorSvc
;
261
BooleanProperty
m_auditInit
;
262
bool
m_auditorInitialize
;
263
bool
m_auditorStart
;
264
bool
m_auditorStop
;
265
bool
m_auditorFinalize
;
266
bool
m_auditorReinitialize
;
267
bool
m_auditorRestart
;
268
270
void
initOutputLevel(
Property
& prop);
271
};
272
273
#endif // GAUDIKERNEL_SERVICE_H
Generated at Wed Nov 28 2012 12:17:14 for Gaudi Framework, version v23r5 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004