Dripline-Cpp  v2.10.11
Dripline Implementation in C++
dripline_constants.hh
Go to the documentation of this file.
1 /*
2  * dripline_constants.hh
3  *
4  * Created on: Jan 5, 2016
5  * Author: N.S. Oblath
6  */
7 
8 #ifndef DRIPLINE_CONSTANTS_HH_
9 #define DRIPLINE_CONSTANTS_HH_
10 
11 #include "dripline_api.hh"
12 
13 #include "macros.hh"
14 
15 #include <cstdint>
16 #include <limits>
17 #include <climits>
18 #include <ostream>
19 
20 namespace dripline
21 {
22 #ifndef DL_MAX_PAYLOAD_SIZE
23 #define DL_MAX_PAYLOAD_SIZE 10000
24 #endif
25 
26  // Dripline message constants
27  // Conforming to the dripline wire protocol: https://github.com/project8/hardware/wiki/Wire-Protocol
28  // Please be sure that these constants are kept in sync with the dripline constants.
29 
34  enum class DRIPLINE_API op_t:unsigned {
35  set = 0,
36  get = 1,
37  cmd = 9,
38  unknown = UINT_MAX
39  };
40 
42  DRIPLINE_API unsigned to_uint( op_t an_op );
45  DRIPLINE_API op_t to_op_t( unsigned an_op_uint );
47  DRIPLINE_API std::ostream& operator<<( std::ostream& a_os, op_t an_op );
49  DRIPLINE_API std::string to_string( op_t an_op );
52  DRIPLINE_API op_t to_op_t( std::string an_op_str );
53 
58  enum class DRIPLINE_API msg_t:unsigned
59  {
60  reply = 2,
61  request = 3,
62  alert = 4,
63  unknown = UINT_MAX
64  };
65 
67  DRIPLINE_API unsigned to_uint( msg_t a_msg );
70  DRIPLINE_API msg_t to_msg_t( unsigned a_msg_uint );
72  DRIPLINE_API std::ostream& operator<<( std::ostream& a_os, msg_t a_msg );
74  DRIPLINE_API std::string to_string( msg_t a_msg );
77  DRIPLINE_API msg_t to_msg_t( std::string a_msg_str );
78 
79 } /* namespace dripline */
80 
81 #endif /* DRIPLINE_CONSTANTS_HH_ */
#define DRIPLINE_API
Definition: dripline_api.hh:34
std::ostream & operator<<(std::ostream &a_os, op_t an_op)
Pass the integer-equivalent of a message-operation enum to an ostream.
std::string to_string(op_t an_op)
Gives the human-readable version of a message operation.
unsigned to_uint(op_t an_op)
Convert a message-operation enum to an integer.
op_t to_op_t(unsigned an_op_uint)
msg_t to_msg_t(unsigned a_msg_uint)