8#include "daq/slc/nsm/Callback.h"
10#include "daq/slc/base/StringUtil.h"
16 for (NSMVHandlerList::iterator it = m_handler.begin();
17 it != m_handler.end(); ++it) {
18 if (it->second != NULL)
delete it->second;
20 m_handler = NSMVHandlerList();
21 m_hnames = StringList();
25int Callback::add(
NSMVHandler* handler,
bool overwrite,
bool isdump)
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());
35 m_handler.erase(hname);
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();
45void Callback::remove(
const std::string& node,
const std::string& )
47 std::string hname = node +
"@" + node;
48 if (m_handler.find(hname) != m_handler.end()) {
49 NSMVHandler* handler_old = m_handler.find(hname)->second;
51 m_handler.erase(hname);
56NSMVHandler& Callback::getHandler(
const std::string& node,
57 const std::string& 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())));
65NSMVHandler* Callback::getHandler_p(
const std::string& node,
const std::string& name)
67 std::string hname = node +
"@" + name;
68 if (m_handler.find(hname) != m_handler.end()) {
69 return m_handler.find(hname)->second;
72 if (m_handler.find(hname) != m_handler.end()) {
73 return m_handler.find(hname)->second;
78void Callback::remove(
const DBObject& obj)
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;
Abstract base class for different kinds of events.