8#ifndef _Belle2_AbstractNSMCallback_hh
9#define _Belle2_AbstractNSMCallback_hh
11#include "daq/slc/nsm/Callback.h"
12#include "daq/slc/nsm/NSMMessage.h"
13#include "daq/slc/nsm/NSMNode.h"
14#include "daq/slc/nsm/NSMCommand.h"
25 class NSMCommunicator;
26 typedef std::map<std::string, NSMNode> NSMNodeMap;
27 typedef std::map<std::string, NSMNodeMap> NSMNodeMapMap;
39 bool get(
const NSMNode& node,
const std::string& name,
int& val,
int timeout = 5);
40 bool get(
const NSMNode& node,
const std::string& name,
float& val,
int timeout = 5);
41 bool get(
const NSMNode& node,
const std::string& name, std::string& val,
int timeout = 5);
42 bool get(
const NSMNode& node,
const std::string& name, std::vector<int>& val,
int timeout = 5);
43 bool get(
const NSMNode& node,
const std::string& name, std::vector<float>& val,
int timeout = 5);
44 bool set(
const NSMNode& node,
const std::string& name,
int val,
int timeout = 5);
45 bool set(
const NSMNode& node,
const std::string& name,
float val,
int timeout = 5);
46 bool set(
const NSMNode& node,
const std::string& name,
const std::string& val,
int timeout = 5);
47 bool set(
const NSMNode& node,
const std::string& name,
const std::vector<int>& val,
int timeout = 5);
48 bool set(
const NSMNode& node,
const std::string& name,
const std::vector<float>& val,
int timeout = 5);
51 bool get(
const std::string& name,
int& val) {
return get(
"", name, val); }
52 bool get(
const std::string& name,
float& val) {
return get(
"", name, val); }
53 bool get(
const std::string& name, std::string& val) {
return get(
"", name, val); }
54 bool get(
const std::string& name, std::vector<int>& val) {
return get(
"", name, val); }
55 bool get(
const std::string& name, std::vector<float>& val) {
return get(
"", name, val); }
56 bool set(
const std::string& name,
int val) {
return set(
"", name, val); }
57 bool set(
const std::string& name,
float val) {
return set(
"", name, val); }
58 bool set(
const std::string& name,
const std::string& val) {
return set(
"", name, val); }
59 bool set(
const std::string& name,
const std::vector<int>& val) {
return set(
"", name, val); }
60 bool set(
const std::string& name,
const std::vector<float>& val) {
return set(
"", name, val); }
61 bool get(
const std::string& node,
const std::string& name,
int& val) {
return get_t(node, name, val); }
62 bool get(
const std::string& node,
const std::string& name,
float& val) {
return get_t(node, name, val); }
63 bool get(
const std::string& node,
const std::string& name, std::string& val) {
return get_t(node, name, val); }
64 bool get(
const std::string& node,
const std::string& name, std::vector<int>& val) {
return get_t(node, name, val); }
65 bool get(
const std::string& node,
const std::string& name, std::vector<float>& val) {
return get_t(node, name, val); }
66 bool set(
const std::string& node,
const std::string& name,
int val) {
return set_t(node, name, val); }
67 bool set(
const std::string& node,
const std::string& name,
float val) {
return set_t(node, name, val); }
68 bool set(
const std::string& node,
const std::string& name,
const std::string& val) {
return set_t(node, name, val); }
69 bool set(
const std::string& node,
const std::string& name,
const std::vector<int>& val) {
return set_t(node, name, val); }
70 bool set(
const std::string& node,
const std::string& name,
const std::vector<float>& val) {
return set_t(node, name, val); }
71 int wait(
double timeout = 5);
74 virtual void notify(
const NSMVar& var) = 0;
78 NSMNode& getNode() {
return m_node; }
79 const NSMNode& getNode()
const {
return m_node; }
80 void setNode(
const NSMNode& node) { m_node = node; }
81 int getTimeout()
const {
return m_timeout; }
82 void setTimeout(
int timeout) { m_timeout = timeout; }
91 NSMNodeMapMap m_node_v_m;
95 bool set(
const NSMNode& node,
const NSMVar& var,
int timeout = 5);
99 bool get_t(
const NSMNode& node,
const std::string& name,
100 T& val,
int timeout, NSMVar::Type type = NSMVar::NONE,
int len = 0)
103 var.setNode(node.getName());
104 if (get(node, var, timeout)) {
105 if (type == NSMVar::NONE ||
106 (type == var.getType() &&
107 ((len == 0 && var.getLength() == 0) ||
108 (len > 0 && var.getLength() > 0)))) {
116 bool get_t(
const std::string& node,
const std::string& name, T& val)
121 handler->handleGet(var);
128 bool set_t(
const std::string& node,
const std::string& name,
const T& val)
133 if (node.size() == 0) {
134 notify(handler->get());
Abstract base class for different kinds of events.