20 {
22 const auto& reg = Gaudi::PluginService::Details::Registry::instance();
23
24 {
25 const auto& info = reg.getInfo( "GaudiTesting::TestAlg", true );
26 using Traits = Gaudi::PluginService::Details::Traits<
IAlgorithm*(
const std::string&,
ISvcLocator* )>;
27 using FactoryType = typename Traits::FactoryType;
28
29 DEBUG_TRACE( std::cout <<
"DEBUG get factory " << info.library <<
"\n type : " << info.factory.type().name()
30 << "\n exp. : " << typeid( FactoryType ).name() << std::endl );
31 auto alg = std::any_cast<FactoryType>( info.factory )(
"TestAlg", &( *(
gaudi.m_svcLoc ) ) );
32 std::cout <<
"INFO got alg " <<
alg->name()
33 << " with some inputs renounced. Should not \"have\" implicit circular dependencies." << std::endl;
35 if (
alg->sysInitialize().isFailure() )
return 1;
36 DEBUG_TRACE( std::cout <<
"DEBUG finalize " <<
alg->name() << std::endl );
37 if (
alg->sysFinalize().isFailure() )
return 1;
38 DEBUG_TRACE( std::cout <<
"DEBUG FINALIZED " <<
alg->name() << std::endl );
40 alg = std::any_cast<FactoryType>( info.factory )(
"TestAlgBug", &( *(
gaudi.m_svcLoc ) ) );
42 std::cout
43 << "INFO Now check that initialize will fail when there are circular dependencies which should be the case for "
44 <<
alg->name() << std::endl;
45 if ( !
alg->sysInitialize().isFailure() ) {
46 DEBUG_TRACE( std::cout <<
"DEBUG finalize " <<
alg->name() << std::endl );
47 if (
alg->sysFinalize().isFailure() )
return 1;
48 DEBUG_TRACE( std::cout <<
"DEBUG FINALIZED " <<
alg->name() << std::endl );
49 return 1;
50 }
51 std::cout <<
"INFO Good. Initialize of " <<
alg->name() <<
" failed as it should." << std::endl;
53 }
54 std::cout << "INFO Test passed." << std::endl;
55 return 0;
56}
The IAlgorithm is the interface implemented by the Algorithm base class.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...