source: trunk/FACT++/src/Dim.h@ 11302

Last change on this file since 11302 was 11003, checked in by tbretz, 13 years ago
Moved GetLocalIp and Setup to DimSetup
File size: 1.7 KB
Line 
1#ifndef FACT_Dim
2#define FACT_Dim
3
4#include "DimSetup.h"
5
6#include <string>
7
8#include "dic.hxx"
9
10namespace Dim
11{
12 // --------------------------------------------------------------------------
13 //
14 //! Simplification wrapper to send a command without data
15 //!
16 //! Example:
17 //! - Dim::SendCommand("SERVER/COMMAND");
18 //!
19 //! @param command
20 //! Dim command identifier
21 //!
22 //! @returns
23 //! the return value of DimClient::sendCommand
24 //!
25 inline bool SendCommand(const std::string &command)
26 {
27 return DimClient::sendCommand(command.c_str(), NULL, 0);
28 }
29
30 // --------------------------------------------------------------------------
31 //
32 //! Simplification wrapper to send a command with the given data
33 //!
34 //! Example:
35 //! - Dim::SendCommand("SERVER/COMMAND", uint16_t(42));
36 //! - struct tm t; Dim::SendCommand("SERVER/TIME", t);
37 //!
38 //! @param command
39 //! Dim command identifier
40 //!
41 //! @param t
42 //! object to be sent, the pointer to the data to be sent is
43 //! set to &t
44 //!
45 //! @tparam T
46 //! type of the data to be sent. The size of the data to be sent
47 //! is determined as sizeof(T)
48 //!
49 //! @returns
50 //! the return value of DimClient::sendCommand
51 //!
52 template<typename T>
53 inline bool SendCommand(const std::string &command, const T &t)
54 {
55 return DimClient::sendCommand(command.c_str(), (void*)&t, sizeof(t));
56 }
57
58 inline bool SendCommand(const std::string &command, const void *d, size_t s)
59 {
60 return DimClient::sendCommand(command.c_str(), const_cast<void*>(d), s);
61 }
62}
63
64#endif
Note: See TracBrowser for help on using the repository browser.