UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
trace_inline.hpp
1 /* trace_inline.hpp */
2 /* $Id$ */
3 #ifndef __trace_inline_hpp
4 #define __trace_inline_hpp
5 
6 #include <string.h>
7 
10 {
11  char charVal;
12  int intVal;
13  float floatVal;
14  double doubleVal;
15 
16  const TrHdrAttrVal& operator=(const char &c) {charVal = c; return *this;}
17  const TrHdrAttrVal& operator=(const int &i) {intVal = i; return *this;}
18  const TrHdrAttrVal& operator=(const float &f) {floatVal = f; return *this;}
19  const TrHdrAttrVal& operator=(const double &d) {doubleVal = d; return *this;}
20 
21  const char& operator()(const char &c) const {(void)c; return charVal;}
22  const int& operator()(const int &i) const {(void)i; return intVal;}
23  const float& operator()(const float &f) const {(void)f; return floatVal;}
24  const double& operator()(const double &d) const {(void)d; return doubleVal;}
25 
26  bool operator==(const TrHdrAttrVal& val) const
27  {return (memcmp(&val, this, sizeof(TrHdrAttrVal) == 0));}
28 };
29 
32 template <typename T>
33 void Trace::Header::setAttr(AttrId id, const T& value)
34 {
35  TrHdrAttrVal val;
36 
37  // default header value is all-byte-zero for correct comparing
38  // in header comparator
39  memset(&val, 0, sizeof(TrHdrAttrVal));
40 
41  val = (T)value;
42  m_attrs[id] = val;
43 }
44 
47 template <typename T>
48 const T& Trace::Header::getAttrValue(AttrId id, bool *result) const
49 {
50  T value;
51  std::map<AttrId, TrHdrAttrVal>::const_iterator it = m_attrs.find(id);
52  if (it == m_attrs.end())
53  {
54  if (result)
55  *result = false;
56 
57  return m_tmp_attribute(value);
58  }
59  else
60  {
61  if (result)
62  *result = true;
63 
64  return it->second(value);
65  }
66 }
67 
68 #endif /* trace_inline.hpp */
Definition: trace_inline.hpp:9
const T & getAttrValue(AttrId id, bool *result=0x0) const
Definition: trace_inline.hpp:48
void setAttr(AttrId id, const T &value)
Definition: trace_inline.hpp:33
AttrId
Definition: trace.hpp:34