15#include <nlohmann/json.hpp>
25 template <
typename Arg,
typename =
void>
27 template <
typename Arg>
28 struct has_reset_method<Arg,
std::void_t<decltype( reset( std::declval<Arg&>() ) )>> : std::true_type {};
29 template <
typename Arg>
33 template <
typename Arg,
typename =
void>
35 template <
typename Arg>
37 Arg,
std::void_t<decltype( mergeAndReset( std::declval<Arg&>(), std::declval<Arg&>() ) )>> : std::true_type {};
38 template <
typename Arg>
71 ,
m_getJSON{ []( void const* ptr ) ->
nlohmann::json { return *reinterpret_cast<const T*>( ptr ); } }
72 , m_reset{ [](
void* ptr ) {
75 , m_mergeAndReset{ [](
void* e,
void* o ) {
77 mergeAndReset( *
reinterpret_cast<T*
>( e ), *
reinterpret_cast<T*
>( o ) );
102 throw std::runtime_error( std::string(
"Entity: mergeAndReset called on different types: " ) +
136 template <
typename T>
138 registerEntity( { std::move( c ), std::move( n ), std::move( t ), ent } );
141 std::for_each( begin(
m_sinks ), end(
m_sinks ), [ent](
auto sink ) { sink->registerEntity( ent ); } );
144 template <
typename T>
148 std::for_each( begin(
m_sinks ), end(
m_sinks ), [&it](
auto sink ) { sink->removeEntity( it->second ); } );
Wrapper class for arbitrary monitoring objects.
std::string component
name of the component owning the Entity
Entity(std::string component, std::string name, std::string type, T &ent)
void * id() const
unique identifier, actually mapped to internal pointer
friend void mergeAndReset(Entity const &ent, Entity const &other)
function calling merge and reset on internal data with the internal data of another entity
std::type_index typeIndex() const
function to get internal type
nlohmann::json(* m_getJSON)(void const *)
function converting the internal data to json.
friend void to_json(nlohmann::json &j, Gaudi::Monitoring::Hub::Entity const &e)
conversion to json via nlohmann library
void(* m_mergeAndReset)(void *, void *)
function calling merge and reset on internal data with the internal data of another entity
void(* m_reset)(void *)
function reseting internal data.
bool operator==(Entity const &ent) const
operator== for comparison with an entity
std::string type
type of the entity, see comment above concerning its format and usage
void * m_ptr
pointer to the actual data inside this Entity
std::string name
name of the entity
std::type_index m_typeIndex
friend void reset(Entity const &e)
function resetting internal data
constexpr bool has_mergeAndReset_method_v
constexpr bool has_reset_method_v
Interface reporting services must implement.
virtual void registerEntity(Entity ent)=0
virtual void removeEntity(Entity const &ent)=0
void removeSink(Sink *sink)
void registerEntity(std::string c, std::string n, std::string t, T &ent)
void removeEntity(T &ent)
std::vector< Sink * > m_sinks
std::map< void *, Entity > m_entities
void registerEntity(Entity ent)