FACT++  1.0
Dim.h
Go to the documentation of this file.
1 #ifndef FACT_Dim
2 #define FACT_Dim
3 
4 #include "DimSetup.h"
5 
6 #include <string>
7 #include <vector>
8 
9 #include "dic.hxx"
10 
11 namespace Dim
12 {
13  // --------------------------------------------------------------------------
14  //
26  inline bool SendCommand(const std::string &command)
27  {
28  return DimClient::sendCommand(command.c_str(), NULL, 0);
29  }
30  inline void SendCommandNB(const std::string &command)
31  {
32  DimClient::sendCommandNB(command.c_str(), NULL, 0);
33  }
34 
35  // --------------------------------------------------------------------------
36  //
57  template<typename T>
58  inline bool SendCommand(const std::string &command, const T &t)
59  {
60  return DimClient::sendCommand(command.c_str(), const_cast<T*>(&t), sizeof(t));
61  }
62 
63  template<>
64  inline bool SendCommand(const std::string &command, const std::string &t)
65  {
66  return DimClient::sendCommand(command.c_str(), const_cast<char*>(t.c_str()), t.length()+1);
67  }
68 
69  template<typename T>
70  inline bool SendCommand(const std::string &command, const std::vector<T> &v)
71  {
72  return DimClient::sendCommand(command.c_str(), const_cast<char*>(v.data()), v.size()*sizeof(T));
73  }
74 
75  inline bool SendCommand(const std::string &command, const void *d, size_t s)
76  {
77  return DimClient::sendCommand(command.c_str(), const_cast<void*>(d), s);
78  }
79 
80  // -------------------------------------------------------------------------
81 
82  template<typename T>
83  inline void SendCommandNB(const std::string &command, const T &t)
84  {
85  DimClient::sendCommandNB(command.c_str(), const_cast<T*>(&t), sizeof(t));
86  }
87 
88  template<>
89  inline void SendCommandNB(const std::string &command, const std::string &t)
90  {
91  DimClient::sendCommandNB(command.c_str(), const_cast<char*>(t.c_str()), t.length()+1);
92  }
93 
94  template<typename T>
95  inline void SendCommandNB(const std::string &command, const std::vector<T> &v)
96  {
97  DimClient::sendCommandNB(command.c_str(), const_cast<T*>(v.data()), v.size()*sizeof(T));
98  }
99 
100  inline void SendCommandNB(const std::string &command, const void *d, size_t s)
101  {
102  DimClient::sendCommandNB(command.c_str(), const_cast<void*>(d), s);
103  }
104 }
105 
106 #endif
static int sendCommand(const char *name, int data)
Definition: diccpp.cxx:1098
bool SendCommand(const std::string &command)
Definition: Dim.h:26
Namespace to host some global Dim helper functions.
Definition: Dim.h:11
static void sendCommandNB(const char *name, int data)
Definition: diccpp.cxx:1140
void SendCommandNB(const std::string &command)
Definition: Dim.h:30
TT t
Definition: test_client.c:26