HiveTestAlgorithm.cpp
Go to the documentation of this file.
4 
5 #include <atomic>
6 
7 DECLARE_ALGORITHM_FACTORY(HiveTestAlgorithm)
8 
9 using namespace std;
10 
12  int m_data;
15 public:
16  MyObject(int d) : m_data(d) {c_instances++;}
17  MyObject(const MyObject& o) : DataObject(), m_data(o.m_data) {c_instances++;}
18  ~MyObject() {d_instances++;}
19  int getData() { return m_data; }
20  static void dump() { cout << "MyObject (C/D): " << c_instances << "/" << d_instances <<endl;}
21 };
22 
25 
30  GaudiAlgorithm(name, pSvcLocator),
31  m_total( 0 ),
32  m_inputs( 0 ),
33  m_outputs( 0 )
34 {
35  declareProperty("Input", m_inputs, "List of required inputs");
36  declareProperty("Output", m_outputs, "List of provided outputs");
37 }
38 
43 {
44 }
45 
48 {
49  info() << ":HiveTestAlgorithm::initialize " << endmsg;
50 
51  return StatusCode::SUCCESS;
52 }
53 
56 {
57  ++m_total;
58  int evt = getContext()->evt();
59 
60  info() << ":HiveTestAlgorithm::getting inputs... " << evt << endmsg;
61 
62  for(vector<string>::iterator i = m_inputs.begin(); i != m_inputs.end(); i++) {
63  MyObject* obj = get<MyObject>(*i);
64  info() << "Got data " << *i << " with value " << obj->getData() << endmsg;
65  }
66 
67  info() << ":HiveTestAlgorithm::registering outputs... " << evt << endmsg;
68 
69  for(vector<string>::iterator i = m_outputs.begin(); i != m_outputs.end(); i++) {
70  put(new MyObject(1000+evt), *i);
71  }
72 
73  return StatusCode::SUCCESS;
74 }
75 
78 {
79  info() << name( ) << ":HiveTestAlgorithm::finalize - total events: " << m_total << endmsg;
81  return StatusCode::SUCCESS;
82 }
83 
85 {
86  return m_inputs;
87 }
88 
90 {
91  return m_outputs;
92 }
93 
94 
static atomic< int > c_instances
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
MyObject(const MyObject &o)
T endl(T...args)
virtual const std::vector< std::string > get_outputs()
STL namespace.
Property * declareProperty(const std::string &name, DataObjectHandle< T > &hndl, const std::string &doc="none") const
T end(T...args)
static void dump()
static atomic< int > d_instances
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
#define DECLARE_ALGORITHM_FACTORY(x)
Definition: Algorithm.h:777
The useful base class for data processing algorithms.
virtual ~HiveTestAlgorithm()
Destructor.
STL class.
#define class
T begin(T...args)
HiveTestAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor(s)
virtual const std::vector< std::string > get_inputs()
std::vector< std::string > m_outputs
std::vector< std::string > m_inputs
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244