Belle II Software development
Callback Class Referenceabstract
Inheritance diagram for Callback:
AbstractNSMCallback NSMCallback RCCallback DqmMasterCallback ERecoMasterCallback ERecoRunControlCallback EventServerCallback RFMasterCallback RFRunControlCallback RoiSenderCallback

Public Member Functions

virtual void notify (const NSMVar &var)=0
 
int reset ()
 
int add (NSMVHandler *handler, bool overwrite=true, bool isdump=true)
 
void remove (const std::string &node, const std::string &name)
 
void remove (const std::string &name)
 
void remove (const DBObject &obj)
 
StringList & getHandlerNames ()
 
NSMVHandlerList & getHandlers ()
 
NSMVHandlergetHandler (const std::string &name)
 
NSMVHandlergetHandler (const std::string &node, const std::string &name)
 
void setUseGet (const std::string &name, bool use)
 
void setUseSet (const std::string &name, bool use)
 
void setRevision (int revision)
 
int getRevision () const
 

Private Member Functions

NSMVHandlergetHandler_p (const std::string &node, const std::string &name)
 

Private Attributes

int m_revision
 
NSMVHandlerList m_handler
 
StringList m_hnames
 

Friends

class AbstractNSMCallback
 
class NSMCallback
 

Detailed Description

Definition at line 24 of file Callback.h.

Constructor & Destructor Documentation

◆ Callback()

Callback ( )
inline

Definition at line 30 of file Callback.h.

30: m_revision(1) {}

◆ ~Callback()

virtual ~Callback ( )
inlinevirtual

Definition at line 31 of file Callback.h.

31{}

Member Function Documentation

◆ add()

int add ( NSMVHandler handler,
bool  overwrite = true,
bool  isdump = true 
)

Definition at line 25 of file Callback.cc.

26{
27 if (handler) {
28 std::string hname = handler->getNode() + "@" + handler->getName();
29 if (m_handler.find(hname) != m_handler.end()) {
30 NSMVHandler* handler_old = m_handler.find(hname)->second;
31 if (handler->useSet() && overwrite) {
32 handler->set(handler_old->get());
33 }
34 delete handler_old;
35 m_handler.erase(hname);
36 }
37 handler->setDumped(isdump);
38 m_handler.insert(std::pair<std::string, NSMVHandler*>(hname, handler));
39 m_hnames.push_back(hname);
40 return m_handler.size();
41 }
42 return 0;
43}

◆ getHandler() [1/2]

NSMVHandler & getHandler ( const std::string &  name)
inline

Definition at line 42 of file Callback.h.

43 {
44 return getHandler("", name);
45 }

◆ getHandler() [2/2]

NSMVHandler & getHandler ( const std::string &  node,
const std::string &  name 
)

Definition at line 56 of file Callback.cc.

58{
59 NSMVHandler* p = getHandler_p(node, name);
60 if (p != NULL) return *p;
61 throw (std::out_of_range(StringUtil::form("no handler for %s:%s",
62 node.c_str(), name.c_str())));
63}

◆ getHandler_p()

NSMVHandler * getHandler_p ( const std::string &  node,
const std::string &  name 
)
private

Definition at line 65 of file Callback.cc.

66{
67 std::string hname = node + "@" + name;
68 if (m_handler.find(hname) != m_handler.end()) {
69 return m_handler.find(hname)->second;
70 }
71 hname = "@" + name;
72 if (m_handler.find(hname) != m_handler.end()) {
73 return m_handler.find(hname)->second;
74 }
75 return NULL;
76}

◆ getHandlerNames()

StringList & getHandlerNames ( )
inline

Definition at line 40 of file Callback.h.

40{ return m_hnames; }

◆ getHandlers()

NSMVHandlerList & getHandlers ( )
inline

Definition at line 41 of file Callback.h.

41{ return m_handler; }

◆ getRevision()

int getRevision ( ) const
inline

Definition at line 59 of file Callback.h.

59{ return m_revision; }

◆ remove() [1/3]

void remove ( const DBObject obj)

Definition at line 78 of file Callback.cc.

79{
80 DBObject::NameValueList list;
81 obj.search(list, "", true);
82 for (DBObject::NameValueList::iterator it = list.begin();
83 it != list.end(); ++it) {
84 const std::string& name(it->name);
85 if (name.size() == 0 || name.at(0) == '$') continue;
86 switch (it->type) {
87 case DBField::OBJECT:
88 break;
89 default:
90 remove(name);
91 break;
92 }
93 }
94}

◆ remove() [2/3]

void remove ( const std::string &  name)
inline

Definition at line 38 of file Callback.h.

38{ remove("", name); }

◆ remove() [3/3]

void remove ( const std::string &  node,
const std::string &  name 
)

Definition at line 45 of file Callback.cc.

46{
47 std::string hname = node + "@" + node;
48 if (m_handler.find(hname) != m_handler.end()) {
49 NSMVHandler* handler_old = m_handler.find(hname)->second;
50 delete handler_old;
51 m_handler.erase(hname);
52 return;
53 }
54}

◆ reset()

int reset ( )

Definition at line 14 of file Callback.cc.

15{
16 for (NSMVHandlerList::iterator it = m_handler.begin();
17 it != m_handler.end(); ++it) {
18 if (it->second != NULL) delete it->second;
19 }
20 m_handler = NSMVHandlerList();
21 m_hnames = StringList();
22 return ++m_revision;
23}

◆ setRevision()

void setRevision ( int  revision)
inline

Definition at line 58 of file Callback.h.

58{ m_revision = revision; }

◆ setUseGet()

void setUseGet ( const std::string &  name,
bool  use 
)
inline

Definition at line 48 of file Callback.h.

49 {
50 getHandler(name).setUseGet(use);
51 }

◆ setUseSet()

void setUseSet ( const std::string &  name,
bool  use 
)
inline

Definition at line 52 of file Callback.h.

53 {
54 getHandler(name).setUseSet(use);
55 }

Friends And Related Function Documentation

◆ AbstractNSMCallback

friend class AbstractNSMCallback
friend

Definition at line 26 of file Callback.h.

◆ NSMCallback

friend class NSMCallback
friend

Definition at line 27 of file Callback.h.

Member Data Documentation

◆ m_handler

NSMVHandlerList m_handler
private

Definition at line 66 of file Callback.h.

◆ m_hnames

StringList m_hnames
private

Definition at line 67 of file Callback.h.

◆ m_revision

int m_revision
private

Definition at line 65 of file Callback.h.


The documentation for this class was generated from the following files: