/******************************************************************************** * Copyright (C) 2014-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #include #include #include using namespace std; using namespace fair::mq::tools; using boost::any_cast; namespace fair { namespace mq { template ostream& operator<<(ostream& os, const vector& v) { for (unsigned int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) { os << ", "; } } return os; } template pair getString(const boost::any& v, const string& label) { return { to_string(any_cast(v)), label }; } template pair getStringPair(const boost::any& v, const string& label) { stringstream ss; ss << any_cast(v); return { ss.str(), label }; } unordered_map(const Property&)>> PropertyHelper::fTypeInfos = { { type_index(typeid(char)), [](const Property& p) { return pair{ string(1, any_cast(p)), "char" }; } }, { type_index(typeid(unsigned char)), [](const Property& p) { return pair{ string(1, any_cast(p)), "unsigned char" }; } }, { type_index(typeid(string)), [](const Property& p) { return pair{ any_cast(p), "string" }; } }, { type_index(typeid(int)), [](const Property& p) { return getString(p, "int"); } }, { type_index(typeid(size_t)), [](const Property& p) { return getString(p, "size_t"); } }, { type_index(typeid(uint32_t)), [](const Property& p) { return getString(p, "uint32_t"); } }, { type_index(typeid(uint64_t)), [](const Property& p) { return getString(p, "uint64_t"); } }, { type_index(typeid(long)), [](const Property& p) { return getString(p, "long"); } }, { type_index(typeid(long long)), [](const Property& p) { return getString(p, "long long"); } }, { type_index(typeid(unsigned)), [](const Property& p) { return getString(p, "unsigned"); } }, { type_index(typeid(unsigned long)), [](const Property& p) { return getString(p, "unsigned long"); } }, { type_index(typeid(unsigned long long)), [](const Property& p) { return getString(p, "unsigned long long"); } }, { type_index(typeid(float)), [](const Property& p) { return getString(p, "float"); } }, { type_index(typeid(double)), [](const Property& p) { return getString(p, "double"); } }, { type_index(typeid(long double)), [](const Property& p) { return getString(p, "long double"); } }, { type_index(typeid(bool)), [](const Property& p) { stringstream ss; ss << boolalpha << any_cast(p); return pair{ ss.str(), "bool" }; } }, { type_index(typeid(vector)), [](const Property& p) { stringstream ss; ss << boolalpha << any_cast>(p); return pair{ ss.str(), "vector>" }; } }, { type_index(typeid(boost::filesystem::path)), [](const Property& p) { return getStringPair(p, "boost::filesystem::path"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, { type_index(typeid(vector)), [](const Property& p) { return getStringPair>(p, "vector"); } }, }; unordered_map PropertyHelper::fEventEmitters = { { type_index(typeid(char)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(unsigned char)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(string)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(int)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(size_t)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(uint32_t)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(uint64_t)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(long long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(unsigned)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(unsigned long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(unsigned long long)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(float)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(double)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(long double)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(bool)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(boost::filesystem::path)), [](const EventManager& em, const string& k, const Property& p) { em.Emit(k, any_cast(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, { type_index(typeid(vector)), [](const EventManager& em, const string& k, const Property& p) { em.Emit>(k, any_cast>(p)); } }, }; } // namespace mq } // namespace fair