DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
notification_enum.hpp
Go to the documentation of this file.
1
9#ifndef SNBMODULES_INCLUDE_SNBMODULES_COMMON_NOTIFICATION_ENUM_HPP_
10#define SNBMODULES_INCLUDE_SNBMODULES_COMMON_NOTIFICATION_ENUM_HPP_
11
12#include <map>
13#include <optional>
14#include <string>
15
16namespace dunedaq::snbmodules {
18{
38
40 {
41 const std::map<e_notification_type, std::string> MyEnumStrings{
42 { CONNECTION_REQUEST, "CONNECTION_REQUEST" }, { NEW_TRANSFER, "NEW_TRANSFER" },
43 { UPDATE_REQUEST, "UPDATE_REQUEST" }, { GROUP_METADATA, "GROUP_METADATA" },
44 { TRANSFER_ERROR, "TRANSFER_ERROR" }, { START_TRANSFER, "START_TRANSFER" },
45 { TRANSFER_METADATA, "TRANSFER_METADATA" }, { PAUSE_TRANSFER, "PAUSE_TRANSFER" },
46 { RESUME_TRANSFER, "RESUME_TRANSFER" }, { CANCEL_TRANSFER, "CANCEL_TRANSFER" }
47 };
48 auto it = MyEnumStrings.find(e);
49 return it == MyEnumStrings.end() ? "Not supported" : it->second;
50 }
51
52 static std::optional<e_notification_type> string_to_notification(std::string s)
53 {
54 const std::map<std::string, e_notification_type> MyStringsEnum{
55 { "CONNECTION_REQUEST", CONNECTION_REQUEST }, { "NEW_TRANSFER", NEW_TRANSFER },
56 { "UPDATE_REQUEST", UPDATE_REQUEST }, { "GROUP_METADATA", GROUP_METADATA },
57 { "TRANSFER_ERROR", TRANSFER_ERROR }, { "START_TRANSFER", START_TRANSFER },
58 { "TRANSFER_METADATA", TRANSFER_METADATA }, { "PAUSE_TRANSFER", PAUSE_TRANSFER },
59 { "RESUME_TRANSFER", RESUME_TRANSFER }, { "CANCEL_TRANSFER", CANCEL_TRANSFER }
60 };
61 auto it = MyStringsEnum.find(s);
62 if (it == MyStringsEnum.end()) {
63 return std::nullopt;
64 }
65 return it->second;
66 }
67};
68
69} // namespace dunedaq::snbmodules
70#endif // SNBMODULES_INCLUDE_SNBMODULES_COMMON_NOTIFICATION_ENUM_HPP_
static std::optional< e_notification_type > string_to_notification(std::string s)
static std::string notification_to_string(e_notification_type e)
e_notification_type
Different type of notifications possible to send.