The Gaudi Framework
master (a36dfcab)
Toggle main menu visibility
Loading...
Searching...
No Matches
ToolVisitorTest_test.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#include "
GaudiEnv.h
"
12
#include <
Gaudi/Algorithm.h
>
13
#include <
Gaudi/PluginService.h
>
14
#include <
GaudiKernel/Bootstrap.h
>
15
#include <
GaudiKernel/IAlgorithm.h
>
16
17
#include <regex>
18
#include <typeinfo>
19
20
int
main
() {
21
GaudiTesting::GaudiEnv
gaudi;
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
}
Bootstrap.h
GaudiEnv.h
DEBUG_TRACE
#define DEBUG_TRACE(a)
Definition
GaudiEnv.h:28
Algorithm.h
IAlgorithm.h
PluginService.h
main
int main()
Definition
ToolVisitorTest_test.cpp:20
GaudiTesting::GaudiEnv
Definition
GaudiEnv.h:37
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition
IAlgorithm.h:37
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
GaudiTestSuite
src
ToolVisitorTest
ToolVisitorTest_test.cpp
Generated on
for The Gaudi Framework by
1.17.0