siplasplas
A library for C++ reflection and introspection
|
Represents a C++ semantic entity (Class, function, namespace, etc) and manages its dynamic reflection information. More...
#include <siplasplas/reflection/dynamic/entity.hpp>
Public Member Functions | |
Entity & | parent () |
Returns a reference to the parent entity The behavior is undefined if the entity has no parent entity (See orphan()) | |
Runtime & | runtime () |
Returns a reference to the runtime where the entity is registered. More... | |
const SourceInfo & | sourceInfo () const |
Returns source information about the entity. | |
const std::string & | name () const |
Returns the name of the entity. | |
const std::string & | fullName () const |
Returns the full qualifies name of the entity. | |
const SourceInfo::Kind & | kind () const |
Returns the kind (Namespace, class, enum, member function, etc) of the entity. | |
bool | detached () const |
Checks whether the entity is not registered (attached) into a dynamic reflection runtime. More... | |
bool | orphan () const |
Checks if the entity has no parent entity. More... | |
void | attach (Runtime &runtime) |
Attaches the entity to a given runtime. More... | |
void | attach (const std::weak_ptr< Entity > &parent) |
Attaches the entity to the runtime of a given entity and links that enity as parent. More... | |
void | addChild (const std::shared_ptr< Entity > &entity) |
Links the given entity as child of the entity. More... | |
bool | isChild (const std::shared_ptr< Entity > &entity) const |
Checks if the given entity is a child entity of this entity. More... | |
bool | isChild (const Entity &entity) const |
Checks if the given entity is a child entity of this entity. More... | |
bool | isChildByName (const std::string &name) const |
Checks if the entity has a child entity with the given name. More... | |
bool | isChildByFullName (const std::string &fullName) const |
Checks if the entity has a child entity with the given name. More... | |
Entity & | getChildByFullName (const std::string &fullName) |
Returns a child entity given its full name. More... | |
Entity & | getChildByName (const std::string &name) |
Returns a child entity given its name. More... | |
std::vector< std::string > | getChildrenNamesByKind (const SourceInfo::Kind &kind) |
Returns the names of the child entities with a given kind. More... | |
std::shared_ptr< Entity > | pointer () |
Returns the shared pointer holding the entity object. | |
Protected Member Functions | |
Entity (const SourceInfo &sourceInfo) | |
Friends | |
bool | operator== (const Entity &lhs, const Entity &rhs) |
Checks two entitties for equality. More... | |
bool | operator!= (const Entity &lhs, const Entity &rhs) |
Checks two entitties for inequality. More... | |
Represents a C++ semantic entity (Class, function, namespace, etc) and manages its dynamic reflection information.
void cpp::dynamic_reflection::Entity::addChild | ( | const std::shared_ptr< Entity > & | entity | ) |
Links the given entity as child of the entity.
This function links the given entity as a child entity of the entity object. At the same time, the given entity links this entity as its parent. The behavior is undefined if the given entity already has a parent (See orphan()). If the entity object already has a child entity with the given entity full name, the given entity is ignored
entity | Shared pointer to an orphan entity |
void cpp::dynamic_reflection::Entity::attach | ( | Runtime & | runtime | ) |
Attaches the entity to a given runtime.
The behavior is undefined if the entity is already attached to a dynamic reflection runtime
runtime | Runtime which the enity will be attached to |
void cpp::dynamic_reflection::Entity::attach | ( | const std::weak_ptr< Entity > & | parent | ) |
Attaches the entity to the runtime of a given entity and links that enity as parent.
The behavior is undefined if the entity is already attached to a dynamic reflection runtime or if the entity already has a parent entity
parent | Pointer to an already-registered entity |
bool cpp::dynamic_reflection::Entity::detached | ( | ) | const |
Checks whether the entity is not registered (attached) into a dynamic reflection runtime.
Entity& cpp::dynamic_reflection::Entity::getChildByFullName | ( | const std::string & | fullName | ) |
Returns a child entity given its full name.
The behavior is undefined if the entity object has no linked child entity with that full name
fullName | Child entity full name |
Entity& cpp::dynamic_reflection::Entity::getChildByName | ( | const std::string & | name | ) |
Returns a child entity given its name.
The behavior is undefined if the entity object has no linked child entity with that name. Equivalent to getChildByFullName(fullName() + <name>)
fullName | Child entity full name |
std::vector<std::string> cpp::dynamic_reflection::Entity::getChildrenNamesByKind | ( | const SourceInfo::Kind & | kind | ) |
Returns the names of the child entities with a given kind.
This function filters the set of child entities of the entity object, returning only the names of those which kind is equal to the specified kind. This can be useful to do quaries like "List the set of classes of a given namespace":
kind | Entity kind Requested entity kind |
bool cpp::dynamic_reflection::Entity::isChild | ( | const std::shared_ptr< Entity > & | entity | ) | const |
Checks if the given entity is a child entity of this entity.
entity | Shared pointer to an entity |
bool cpp::dynamic_reflection::Entity::isChild | ( | const Entity & | entity | ) | const |
Checks if the given entity is a child entity of this entity.
entity | Reference to an entity |
bool cpp::dynamic_reflection::Entity::isChildByFullName | ( | const std::string & | fullName | ) | const |
Checks if the entity has a child entity with the given name.
Equivalent to isChildByFullName(fullName() + <name>)
name | Name of the child entity |
bool cpp::dynamic_reflection::Entity::isChildByName | ( | const std::string & | name | ) | const |
Checks if the entity has a child entity with the given name.
Equivalent to isChildByFullName(fullName() + <name>)
name | Name of the child entity |
bool cpp::dynamic_reflection::Entity::orphan | ( | ) | const |
Checks if the entity has no parent entity.
Runtime& cpp::dynamic_reflection::Entity::runtime | ( | ) |
Returns a reference to the runtime where the entity is registered.
The behavior is undefined if the entity is not attached to any runtime. See detached()
Checks two entitties for inequality.
Equivalent to !(lhs == rhs)
Checks two entitties for equality.