siplasplas
A library for C++ reflection and introspection
runtime.hpp
1 #ifndef SIPLASPLAS_REFLECTION_DYNAMIC_RUNTIME_HPP
2 #define SIPLASPLAS_REFLECTION_DYNAMIC_RUNTIME_HPP
3 
4 #include "namespace.hpp"
5 
6 namespace cpp
7 {
8 
9 namespace dynamic_reflection
10 {
11 
16 class SIPLASPLAS_REFLECTION_DYNAMIC_EXPORT Runtime
17 {
18 public:
19  Runtime();
20 
28  Runtime(const std::string& name);
29 
33  void clear();
34 
40  void reset(const std::string& name);
41 
47  Namespace& namespace_();
48 
57  Namespace& namespace_(const std::string& fullName);
58 
67  bool hasEntity(const std::string& fullName) const;
68 
77  Entity& getEntity(const std::string& fullName);
78 
91  template<typename EntityType>
92  EntityType& getEntity(const std::string& fullName)
93  {
94  return EntityType::fromEntity(getEntity(fullName).pointer());
95  }
96 
106  void addEntity(const std::shared_ptr<Entity>& entity);
107 
111  const std::string& name() const;
112 
113 private:
114  std::string _name;
115  std::unordered_map<std::string, std::shared_ptr<Entity>> _entities;
116 };
117 
118 }
119 
120 }
121 
122 #endif // SIPLASPLAS_REFLECTION_DYNAMIC_RUNTIME_HPP
Definition: canary_allocator.hpp:7
Stores dynamic reflection information of a namespace.
Definition: namespace.hpp:19
Provides access to dynamic type and function information at runtime.
Definition: runtime.hpp:16
EntityType & getEntity(const std::string &fullName)
Returns a reference to the specified entity.
Definition: runtime.hpp:92
Represents a C++ semantic entity (Class, function, namespace, etc) and manages its dynamic reflection...
Definition: entity.hpp:22