8 #ifndef FAIR_MQ_PROPERTIES_H 9 #define FAIR_MQ_PROPERTIES_H 11 #include <fairmq/EventManager.h> 13 #include <boost/any.hpp> 14 #include <boost/core/demangle.hpp> 18 #include <unordered_map> 29 using Property = boost::any;
30 using Properties = std::map<std::string, Property>;
39 static void AddType(std::string label =
"")
42 label = boost::core::demangle(
typeid(T).name());
44 fTypeInfos[std::type_index(
typeid(T))] = [label](
const Property& p) {
46 ss << boost::any_cast<T>(p);
47 return std::pair<std::string, std::string>{ss.str(), label};
49 fEventEmitters[std::type_index(
typeid(T))] = [](
const fair::mq::EventManager& em,
const std::string& k,
const Property& p) {
54 static std::string ConvertPropertyToString(
const Property& p)
56 return fTypeInfos.at(p.type())(p).first;
60 static std::pair<std::string, std::string> GetPropertyInfo(
const Property& p)
63 return fTypeInfos.at(p.type())(p);
64 }
catch (std::out_of_range& oor) {
65 return {
"[unidentified_type]",
"[unidentified_type]"};
69 static std::unordered_map<std::type_index, void(*)(const fair::mq::EventManager&, const std::string&, const Property&)> fEventEmitters;
71 static std::unordered_map<std::type_index, std::function<std::pair<std::string, std::string>(
const Property&)>> fTypeInfos;
Definition: Properties.h:35
Definition: EventManager.h:31
Manages event callbacks from different subscribers.
Definition: EventManager.h:51
Definition: Properties.h:33
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23
Definition: Properties.h:32