57 {
58 static bool first_call_configure = true;
59 if ( first_call_configure ) { first_call_configure = false; }
60 else { return true; }
61
62
63
64
65
66
67
68 if ( m_outLev <= 3 )
69 std::cout << "efpsc::SC::configure "
70 << "SC configuration started." << std::endl;
71 m_config = new efpsc::Config( config );
72
73
74
75
76 if ( m_outLev <= 2 )
77 std::cout << "efpsc::SC::configure "
78 << "---> Create Pesa Application Manager:" << m_isCreated << std::endl;
79 if ( !m_isCreated )
80 {
81 if ( ( m_config->dllName().size() != 0 ) && ( m_config->factoryName().size() != 0 ) )
82 {
83 m_pesaAppMgr =
84 Gaudi::createApplicationMgr( m_config->dllName(), m_config->factoryName() );
85 if ( m_outLev <= 3 )
86 std::cout << "Gaudi::createApplicationMgr(m_config->dllName(),m_config->factoryName())"
87 << std::endl;
88 }
89 else
90 {
91 m_pesaAppMgr = Gaudi::createApplicationMgr();
92 if ( m_outLev <= 3 ) std::cout << "Gaudi::createApplicationMgr()" << std::endl;
93 }
94 }
95
96
97
98
99 if ( m_outLev <= 2 )
100 std::cout << "efpsc::SC::configure "
101 << "---> Configure Pesa Property Manager" << std::endl;
102 StatusCode sc;
103 SmartIF<IProperty> propMgr( m_pesaAppMgr );
104 SmartIF<IAppMgrUI> appMgr( m_pesaAppMgr );
105 if ( !appMgr.isValid() || !propMgr.isValid() )
106 {
107
108
109 if ( m_outLev <= 5 )
110 std::cout << "efpsc::SC::configure "
111 << "While creating the ApplicationMgr" << std::endl;
112 return false;
113 }
114
115
116 std::string opts = "jobOptions.txt";
117 ::setenv( "efJobPath", "", 1 );
118 if ( m_config->jobOptionsPath().size() != 0 )
119 {
120 opts = m_config->jobOptionsPath();
121 if ( opts.rfind( "/" ) < opts.size() )
122 { ::setenv( "efJobPath", opts.substr( 0, opts.rfind( "/" ) ).c_str(), 1 ); }
123 }
124
125
126
127 if ( m_outLev <= 2 )
128 std::cout << "efpsc::SC::configure "
129 << "---> Pesa JobOptions file is = " << opts << std::endl
130 << " "
131 << "---> Pesa JobOptions path = " << ::getenv( "efJobPath" ) << std::endl;
132 propMgr->setProperty( "JobOptionsPath", opts );
133
134 propMgr->setProperty( "EventLoop", m_nameEventLoopMgr );
135
136
137 if ( m_config->messageSvcType().size() != 0 )
138 { propMgr->setProperty( "MessageSvcType", m_config->messageSvcType() ); }
139
140
141 if ( m_config->evtSel().size() != 0 )
142 { propMgr->setProperty( "EvtSel", m_config->evtSel() ); }
143 else { propMgr->setProperty( "EvtSel", "NONE" ); }
144
145
146
147 if ( m_outLev <= 3 )
148 std::cout << "efpsc::SC::configure "
149 << "finish property set--->start configure" << std::endl;
150 if ( m_outLev <= 2 )
151 std::cout << "efpsc::SC::configure "
152 << "Configuring ApplicationMgr: " << appMgr->FSMState()
153 << " Status : " << sc.getCode() << std::endl;
154
155 if ( opts.substr( opts.length() - 3, 3 ) == ".py" )
156 {
157
158
159
160 if ( m_outLev <= 5 )
161 std::cout << "efpsc::SC::configure "
162 << "Error: Don't support python config files" << std::endl;
163 return false;
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 }
204 else
205 {
206
207
208
209 sc = appMgr->configure();
210 if ( sc.isFailure() )
211 {
212
213
214 if ( m_outLev <= 5 )
215 std::cout << "efpsc::SC::configure "
216 << "While configuring the ApplicationMgr" << std::endl;
217 return false;
218 }
219 }
220
221
222 if ( m_outLev <= 2 )
223 std::cout << "efpsc::SC::configure "
224 << "Configuring ApplicationMgr: " << appMgr->FSMState()
225 << " Status : " << sc.getCode() << std::endl;
226
227 sc = appMgr->initialize();
228
229
230
231 if ( m_outLev <= 2 )
232 std::cout << "efpsc::SC::configure "
233 << "Initialize ApplicationMgr : " << appMgr->FSMState()
234 << " Status : " << sc.getCode() << std::endl;
235 if ( sc.isFailure() )
236 {
237 EFPSC_ERROR(
"efpsc::SC::configure",
"While intializing the ApplicationMgr" );
238 return false;
239 }
240
241
242 std::string value;
243
244 sc = propMgr->getProperty( "EventLoop", value );
245
246 if ( sc.isFailure() )
247 {
248
249 if ( m_outLev <= 4 )
250 std::cout << "efpsc::SC::configure "
251 << "While retrieving Property EventLoop " << std::endl;
252 }
253 else
254 {
255 m_nameEventLoopMgr.assign( value, value.find_first_of( "\"" ) + 1,
256 value.find_last_of( "\"" ) - value.find_first_of( "\"" ) - 1 );
257 }
258
259 SmartIF<ISvcLocator> svcLoc( m_pesaAppMgr );
260 if ( svcLoc.isValid() )
261 {
262
263 if ( m_outLev <= 2 )
264 std::cout << "efpsc::SC::configure "
265 << "Name for EventLoopManager:" << m_nameEventLoopMgr << std::endl;
266 StatusCode sc;
267 IEventProcessor* processingMgr = 0;
268
269 sc = svcLoc->service( m_nameEventLoopMgr, processingMgr );
270 m_eventLoopMgr = processingMgr;
271
272 if ( !sc.isSuccess() )
273 {
274
275 if ( m_outLev <= 5 )
276 std::cout << "efpsc::SC::configure "
277 << "Error Retrieving Processing manager!" << std::endl;
278 return false;
279 }
280 }
281 else
282 {
283
284 if ( m_outLev <= 5 )
285 std::cout << "efpsc::SC::configure "
286 << "Error Retrieving Service Locator!" << std::endl;
287 return false;
288 }
289
290 m_isCreated = true;
291
292 if ( m_outLev <= 3 )
293 std::cout << "efpsc::SC::configure "
294 << "SC configuration finished." << std::endl;
295 return true;
296}
#define EFPSC_ERROR(p, m)