The Gaudi Framework  master (37c0b60a)
ToolVisitorTest_test.cpp File Reference
#include "GaudiEnv.h"
#include <Gaudi/Algorithm.h>
#include <Gaudi/PluginService.h>
#include <GaudiKernel/Bootstrap.h>
#include <GaudiKernel/IAlgorithm.h>
#include <regex>
#include <typeinfo>
Include dependency graph for ToolVisitorTest_test.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 20 of file ToolVisitorTest_test.cpp.

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;
34  alg->addRef();
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 );
39  alg.reset();
40  alg = std::any_cast<FactoryType>( info.factory )( "TestAlgBug", &( *( gaudi.m_svcLoc ) ) );
41  alg->addRef();
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;
52  alg.reset();
53  }
54  std::cout << "INFO Test passed." << std::endl;
55  return 0;
56 }
std::string
STL class.
GaudiTesting::GaudiEnv
Definition: GaudiEnv.h:37
ISvcLocator
Definition: ISvcLocator.h:46
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:81
IAlgorithm
Definition: IAlgorithm.h:38
std::cout
GaudiPartProp.Check.gaudi
gaudi
Definition: Check.py:42
DEBUG_TRACE
#define DEBUG_TRACE(a)
Definition: GaudiEnv.h:28
std::endl
T endl(T... args)