[22] | 1 | #ifndef MessagesIdentifiers_h
|
---|
| 2 | #define MessagesIdentifiers_h
|
---|
| 3 |
|
---|
| 4 | #include <t3devlib/t3devlib.h>
|
---|
| 5 |
|
---|
| 6 | class MessagesIdentifiers
|
---|
| 7 | {
|
---|
| 8 | public:
|
---|
| 9 | static const char* GeneralConfigurationReq;
|
---|
| 10 | static const char* GeneralConfigurationRsp;
|
---|
| 11 | static const char* SetFilterReq;
|
---|
| 12 | static const char* SetFilterRsp;
|
---|
| 13 | static const char* StartTrafficCaptureReq;
|
---|
| 14 | static const char* StartTrafficCaptureRsp;
|
---|
| 15 | static const char* StopTrafficCaptureReq;
|
---|
| 16 | static const char* StopTrafficCaptureRsp;
|
---|
| 17 | static const char* EquipmentOperationReq;
|
---|
| 18 | static const char* EquipmentOperationRsp;
|
---|
| 19 | static const int Size;
|
---|
| 20 | static const char* Messages[];
|
---|
| 21 |
|
---|
| 22 | static unsigned char GetIdx(const std::string& message)
|
---|
| 23 | {
|
---|
| 24 | // Sanity check.
|
---|
| 25 | if (message.length() == 0)
|
---|
| 26 | {
|
---|
| 27 | return 0xff;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | // Get index
|
---|
| 31 | const char ** ppEnum = MessagesIdentifiers::Messages;
|
---|
| 32 | int i = 0;
|
---|
| 33 | while (*(ppEnum[i]) && strcmp(ppEnum[i], message.c_str()) != 0)
|
---|
| 34 | i++;
|
---|
| 35 | if (*(ppEnum[i]) == 0) { // Not found.
|
---|
| 36 | return 0xff;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | return static_cast<unsigned char>(i);
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | static std::string GetMessage(int idx)
|
---|
| 43 | {
|
---|
| 44 | // Sanity check.
|
---|
| 45 | if (idx >=MessagesIdentifiers::Size)
|
---|
| 46 | {
|
---|
| 47 | return std::string("");
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | return std::string(Messages[idx]);
|
---|
| 51 | }
|
---|
| 52 | };
|
---|
| 53 |
|
---|
| 54 | #endif // MessagesIdentifiers_h
|
---|
| 55 |
|
---|