8#ifndef _Belle2_NSMVar_h
9#define _Belle2_NSMVar_h
11#include <daq/slc/base/Serializable.h>
12#include <daq/slc/base/Date.h>
34 static const NSMVar NOVALUE;
37 NSMVar() : m_value(NULL), m_name(), m_type(NONE), m_len(0)
41 NSMVar(
const std::string& name, Type type,
int len,
const void* value)
44 copy(name, type, len, value);
46 NSMVar(
const std::string& name,
const std::string& value)
49 copy(name, TEXT, value.size(), value.c_str());
51 NSMVar(
const std::string& name,
int value)
54 copy(name, INT, 0, &value);
56 NSMVar(
const std::string& name,
float value)
59 copy(name, FLOAT, 0, &value);
61 NSMVar(
const std::string& name,
int len,
int* value)
64 copy(name, INT, len, value);
66 NSMVar(
const std::string& name,
int len,
float* value)
69 copy(name, FLOAT, len, value);
71 NSMVar(
const std::string& name,
const std::vector<int>& value);
72 NSMVar(
const std::string& name,
const std::vector<float>& value);
73 NSMVar(
const std::string& name) : m_value(NULL), m_name(name), m_type(NONE), m_len(0) {}
74 NSMVar(
const NSMVar& var) : m_value(NULL) { *
this = var; }
80 copy(var.m_name, var.m_type, var.m_len, var.m_value, var.m_id, var.m_date);
85 const NSMVar& operator=(
int val)
87 copy(m_name, INT, 0, &val, m_id);
90 const NSMVar& operator=(
float val)
92 copy(m_name, FLOAT, 0, &val, m_id);
95 const NSMVar& operator=(
const std::string& val)
98 copy(m_name, TEXT, val.size(), val.c_str(), m_id);
100 copy(m_name, TEXT, 1,
"", m_id);
104 const NSMVar& operator=(
const std::vector<int>& val);
105 const NSMVar& operator=(
const std::vector<float>& val);
106 const NSMVar& operator>>(
int& val)
const { val = getInt();
return *
this; }
107 const NSMVar& operator>>(
float& val)
const { val = getFloat();
return *
this; }
108 const NSMVar& operator>>(std::string& val)
const { val = getText();
return *
this; }
109 const NSMVar& operator>>(std::vector<int>& val)
const;
113 void setNode(
const std::string& node) { m_node = node; }
114 void setName(
const std::string& name) { m_name = name; }
115 const void* get()
const {
return m_value; }
116 void* get() {
return m_value; }
118 const std::string& getNode()
const {
return m_node; }
119 const std::string& getName()
const {
return m_name; }
120 Type getType()
const {
return m_type; }
121 const char* getTypeLabel()
const;
122 int getLength()
const {
return m_len; }
124 float getFloat()
const;
125 const char* getText()
const;
126 int getInt(
int i)
const;
127 float getFloat(
int i)
const;
128 int getId()
const {
return m_id; }
129 void setId(
int id) { m_id = id; }
130 void setDate(
int date) { m_date = date; }
131 void setDate(
const Date& date) { m_date = date.get(); }
132 int getDate()
const {
return m_date; }
135 void readObject(
Reader&)
override;
136 void writeObject(
Writer&)
const override;
139 void copy(
const std::string& name, Type type,
int len,
140 const void* value,
int id = 0,
int date = 0);
153 typedef std::vector<NSMVar> NSMVarList;
std::istream & operator>>(std::istream &input, IntervalOfValidity &iov)
Abstract base class for different kinds of events.