ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthToolSupport
AsgExampleTools
util
hello.cxx
Go to the documentation of this file.
1
// hello.cxx
2
3
// David Adams
4
// January 2014
5
//
6
// Demo main program to use AsgHelloTool in a
7
// standlone environment.
8
9
#include <string>
10
#include <iostream>
11
#include "
AsgExampleTools/AsgHelloTool.h
"
12
#include <
AsgMessaging/MessageCheck.h
>
13
14
using
std::string;
15
using
std::cout;
16
using
std::endl;
17
18
int
main
() {
19
using namespace
asg::msgUserCode;
20
ANA_CHECK_SET_TYPE
(
int
);
21
22
23
const
string
myname =
"hello: "
;
24
cout << myname <<
"Begin."
<< endl;
25
AsgHelloTool
htool(
"myhello"
);
26
ANA_CHECK
( htool.setProperty(
"Message"
,
"Hello from ASG."
) );
27
ANA_CHECK
( htool.setProperty(
"OutputLevel"
, MSG::DEBUG) );
28
cout << myname <<
"Initialize"
<< endl;
29
ANA_CHECK
( htool.
initialize
());
30
cout << myname <<
"Show properties"
<< endl;
31
htool.
print
();
32
cout << myname <<
"Extract property"
<< endl;
33
const
string
* message = htool.
getProperty
<
string
>(
"Message"
);
34
if
( ! message ) {
35
cout << myname <<
"Couldn't extract property from the tool"
<< endl;
36
return
1;
37
}
38
htool.
getProperty
<
string
>(
"UnknownProperty"
);
39
htool.
getProperty
<
int
>(
"Message"
);
40
cout << myname <<
"The \"Message\" property of the tool: "
<< *message << endl;
41
cout << myname <<
"Run 10 times"
<< endl;
42
string
line =
"---------------------------------------------------"
;
43
cout << line << endl;
44
for
(
int
i=0; i<10; ++i ) {
45
if
( i == 3 ) {
46
ANA_CHECK
( htool.setProperty(
"OutputLevel"
, MSG::INFO) );
47
}
48
htool.
talk
();
49
}
50
cout << line << endl;
51
cout << myname <<
"Check failure:"
<< endl;
52
ANA_CHECK
( StatusCode (StatusCode::FAILURE));
53
cout << myname <<
"End of failure check"
<< endl;
54
cout << myname <<
"End."
<< endl;
55
return
0;
56
}
AsgHelloTool.h
MessageCheck.h
macros for messaging and checking status codes
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
AsgHelloTool
Definition
AsgHelloTool.h:17
AsgHelloTool::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition
AsgHelloTool.cxx:15
AsgHelloTool::talk
virtual int talk() const
Definition
AsgHelloTool.cxx:24
AsgHelloTool::print
virtual void print() const
Print the state of the tool.
Definition
AsgHelloTool.cxx:40
asg::AsgTool::getProperty
const T * getProperty(const std::string &name) const
Get one of the tool's properties.
main
int main()
Definition
hello.cxx:18
Generated on
for ATLAS Offline Software by
1.17.0