| | |
| | | #include "bhome_msg_api.pb.h" |
| | | #include <chrono> |
| | | |
| | | using namespace bhome::msg; |
| | | using namespace bhome_msg; |
| | | |
| | | template <class Msg> |
| | | struct MsgToType { |
| | | }; |
| | | |
| | | #define BHOME_MAP_MSG_AND_TYPE(mSG, tYPE) \ |
| | | template <> \ |
| | | struct MsgToType<mSG> { \ |
| | | static const bhome::msg::MsgType value = tYPE; \ |
| | | #define BHOME_MAP_MSG_AND_TYPE(mSG, tYPE) \ |
| | | template <> \ |
| | | struct MsgToType<mSG> { \ |
| | | static const MsgType value = tYPE; \ |
| | | }; |
| | | |
| | | #define BHOME_SIMPLE_MAP_MSG(name) BHOME_MAP_MSG_AND_TYPE(Msg##name, kMsgType##name) |
| | |
| | | #undef BHOME_MAP_MSG_AND_TYPE |
| | | |
| | | template <class Msg> |
| | | constexpr inline bhome::msg::MsgType GetType(const Msg &) |
| | | constexpr inline MsgType GetType(const Msg &) |
| | | { |
| | | return MsgToType<Msg>::value; |
| | | } |