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