siplasplas
A library for C++ reflection and introspection
cpp::dynamic_reflection::Runtime Class Reference

Provides access to dynamic type and function information at runtime. More...

#include <siplasplas/reflection/dynamic/runtime.hpp>

Public Member Functions

 Runtime (const std::string &name)
 Initializes a dynamic reflection runtime. More...
 
void clear ()
 Clears registered type information.
 
void reset (const std::string &name)
 Clears (resets) registered type information. More...
 
Namespacenamespace_ ()
 Returns reflection information about the global namespace. More...
 
Namespacenamespace_ (const std::string &fullName)
 Returns reflection information about a given namespace. More...
 
bool hasEntity (const std::string &fullName) const
 Checks if an enity is registered with the given name. More...
 
EntitygetEntity (const std::string &fullName)
 Returns a reference to the specified entity. More...
 
template<typename EntityType >
EntityType & getEntity (const std::string &fullName)
 Returns a reference to the specified entity. More...
 
void addEntity (const std::shared_ptr< Entity > &entity)
 Registers an entity in the dynamic reflection runtime. More...
 
const std::string & name () const
 Returns the runtime name.
 

Detailed Description

Provides access to dynamic type and function information at runtime.

Examples:
examples/reflection/dynamic/plugin.cpp, and examples/reflection/dynamic/reflection.cpp.

Constructor & Destructor Documentation

cpp::dynamic_reflection::Runtime::Runtime ( const std::string &  name)

Initializes a dynamic reflection runtime.

Parameters
nameRuntime identifier. This identifier will be used for logging and debugging purposes. It can be used to differentiate runtimes comming from different libraries (See cpp::dynamic_reflection::RuntimeLoaded)

Member Function Documentation

void cpp::dynamic_reflection::Runtime::addEntity ( const std::shared_ptr< Entity > &  entity)

Registers an entity in the dynamic reflection runtime.

Registers the entity in the runtime and attaches it to it. If there's an entity already registered with the entity full name, no registration is performed.

Parameters
entityPointer to an entity
Examples:
examples/reflection/dynamic/reflection.cpp.
Entity& cpp::dynamic_reflection::Runtime::getEntity ( const std::string &  fullName)

Returns a reference to the specified entity.

Parameters
fullNameEntity full qualified name. The behavior is undefined if no entity is registered with the given name. See hasEntity()
Returns
A reference to the entity
template<typename EntityType >
EntityType& cpp::dynamic_reflection::Runtime::getEntity ( const std::string &  fullName)
inline

Returns a reference to the specified entity.

Template Parameters
EntityTypeEntity type (cpp::dynamic_reflection::Class, cpp::dynamic_reflection::Enum, etc). The behavior is undefined if the type doesn't match the entity kind (See Entity::kind())
Parameters
fullNameEntity full qualified name. The behavior is undefined if no entity is registered with the given name. See hasEntity()
Returns
A reference to the entity
bool cpp::dynamic_reflection::Runtime::hasEntity ( const std::string &  fullName) const

Checks if an enity is registered with the given name.

Parameters
fullNameEntity full qualified name
Returns
True if the runtime has an entity registered with the given full name. False instead
Namespace& cpp::dynamic_reflection::Runtime::namespace_ ( )

Returns reflection information about the global namespace.

Returns
A reference to the global namespace entity
Examples:
examples/reflection/dynamic/plugin.cpp, and examples/reflection/dynamic/reflection.cpp.
Namespace& cpp::dynamic_reflection::Runtime::namespace_ ( const std::string &  fullName)

Returns reflection information about a given namespace.

Parameters
fullNameFull qualified namespace name
Returns
A reference to the namespace entity. Throws a std::runtime_error exception if there's no namespace registered with that name
void cpp::dynamic_reflection::Runtime::reset ( const std::string &  name)

Clears (resets) registered type information.

Parameters
nameNew runtime identifier

The documentation for this class was generated from the following file: