ATLAS Offline Software
Loading...
Searching...
No Matches
CBNode.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef IOVSVC_CBNODE_H
6#define IOVSVC_CBNODE_H
7
8/*****************************************************************************
9 *
10 * CBNode.h
11 * IOVSvc
12 *
13 * Author: Charles Leggett
14 *
15 * Tree node structure for callback function trigger tree
16 *
17 *****************************************************************************/
18
19#include <set>
20#include <string>
21
23#include "SGTools/CallBackID.h"
24#include <atomic>
25
26namespace SG {
27 class DataProxy;
28}
29
30class CBNode {
31public:
32
34
35 class nodeOrder {
36 public:
37 bool operator() ( const CBNode &n1, const CBNode &n2 ) const {
38 if ( n1.level() != n2.level() ) {
39 return ( n1.level() < n2.level() );
40 } else {
41 return ( n1.serial() < n2.serial() );
42 }
43 }
44
45 bool operator() ( const CBNode *n1, const CBNode *n2 ) const {
46 if ( n1->level() != n2->level() ) {
47 return ( n1->level() < n2->level() );
48 } else {
49 return ( n1->serial() < n2->serial() );
50 }
51 }
52 };
53
54 typedef std::set<CBNode*, CBNode::nodeOrder> nodeSet;
55 typedef std::vector<const CBNode*> constNodeVec;
56
57 CBNode() = delete;
58 CBNode(const std::string& name, CBNode* parent);
59 CBNode(const SG::DataProxy* proxy, const std::string& name, CBNode* parent);
60 CBNode(BFCN* fcn, const CallBackID& cb, CBNode* parent);
61 ~CBNode();
62
63 void addParent(CBNode* parent);
64 void addChild(CBNode* child);
65
66 bool delParent(CBNode* parent);
67 bool delChild(CBNode* child);
68
69 const nodeSet& children() { return m_children; }
70 const nodeSet& parents() { return m_parents; }
71 constNodeVec children() const { return constNodeVec (m_children.begin(), m_children.end()); }
72 constNodeVec parents() const { return constNodeVec (m_parents.begin(), m_parents.end()); }
73
74 const std::string& name() const { return m_name; }
75 int level() const { return m_level; }
76 void setLevel(int l) { m_level = l; }
77
78 bool trigger() const { return m_trig; }
79 void setTrigger(bool b) { m_trig = b; }
80
81 bool flag() const { return m_flag; }
82 void setFlag(bool b) { m_flag = b; }
83
84 const SG::DataProxy* proxy() const { return m_proxy; }
85 void setProxy(const SG::DataProxy* p);
86
87 BFCN* fcn() { return m_fcn; }
88 const BFCN* fcn() const { return m_fcn; }
89
90 unsigned int serial() const { return m_serial; }
91
92private:
95
96 std::string m_name;
98
102
103 bool m_trig;
104 bool m_flag;
105
106 unsigned int m_serial;
107 static std::atomic<unsigned int> s_serial;
108};
109
110#endif
defines and typedefs for IOVSvc
boost::function< StatusCode(IOVSVC_CALLBACK_ARGS) > IOVSvcCallBackFcn
the type of an IOVSvc call back: it wraps both the method and the object the method is called on
Definition IOVSvcDefs.h:58
bool operator()(const CBNode &n1, const CBNode &n2) const
Definition CBNode.h:37
void addParent(CBNode *parent)
Definition CBNode.cxx:65
const BFCN * fcn() const
Definition CBNode.h:88
nodeSet m_parents
Definition CBNode.h:93
void setLevel(int l)
Definition CBNode.h:76
BFCN * fcn()
Definition CBNode.h:87
int level() const
Definition CBNode.h:75
bool m_flag
Definition CBNode.h:104
void addChild(CBNode *child)
Definition CBNode.cxx:70
std::set< CBNode *, CBNode::nodeOrder > nodeSet
Definition CBNode.h:54
int m_level
Definition CBNode.h:97
nodeSet m_children
Definition CBNode.h:94
void setProxy(const SG::DataProxy *p)
Definition CBNode.cxx:93
const SG::DataProxy * proxy() const
Definition CBNode.h:84
void setFlag(bool b)
Definition CBNode.h:82
bool flag() const
Definition CBNode.h:81
const nodeSet & parents()
Definition CBNode.h:70
bool delChild(CBNode *child)
Definition CBNode.cxx:84
constNodeVec children() const
Definition CBNode.h:71
~CBNode()
Definition CBNode.cxx:61
void setTrigger(bool b)
Definition CBNode.h:79
unsigned int serial() const
Definition CBNode.h:90
IOVSvcCallBackFcn BFCN
Definition CBNode.h:33
const std::string & name() const
Definition CBNode.h:74
bool trigger() const
Definition CBNode.h:78
const nodeSet & children()
Definition CBNode.h:69
std::string m_name
Definition CBNode.h:96
unsigned int m_serial
Definition CBNode.h:106
CBNode()=delete
bool m_trig
Definition CBNode.h:103
static std::atomic< unsigned int > s_serial
Definition CBNode.h:107
BFCN * m_fcn
Definition CBNode.h:100
const SG::DataProxy * m_proxy
Definition CBNode.h:99
bool delParent(CBNode *parent)
Definition CBNode.cxx:75
std::vector< const CBNode * > constNodeVec
Definition CBNode.h:55
CallBackID m_cbid
Definition CBNode.h:101
constNodeVec parents() const
Definition CBNode.h:72
Forward declaration.