Refureku v2.2.0
C++17 runtime reflection library.
Namespace.h
1
8#pragma once
9
10#include "Refureku/TypeInfo/Entity/Entity.h"
11#include "Refureku/TypeInfo/Variables/EVarFlags.h"
12#include "Refureku/TypeInfo/Functions/EFunctionFlags.h"
13#include "Refureku/TypeInfo/Functions/FunctionHelper.h"
14
15namespace rfk
16{
17 //Forward declarations
18 class Struct;
19 using Class = Struct;
20 class Enum;
21 class Variable;
22 class Function;
23 class Archetype;
24
25 class Namespace final : public Entity
26 {
27 public:
28 REFUREKU_INTERNAL Namespace(char const* name,
29 std::size_t id) noexcept;
30 Namespace(Namespace&&) = delete;
31 REFUREKU_INTERNAL ~Namespace() noexcept;
32
40 RFK_NODISCARD REFUREKU_API Namespace const* getNamespaceByName(char const* name) const noexcept;
41
52 RFK_NODISCARD REFUREKU_API Namespace const* getNamespaceByPredicate(Predicate<Namespace> predicate,
53 void* userData) const;
54
66 void* userData) const;
67
79 REFUREKU_API bool foreachNamespace(Visitor<Namespace> visitor,
80 void* userData) const;
81
87 REFUREKU_API std::size_t getNamespacesCount() const noexcept;
88
96 RFK_NODISCARD REFUREKU_API Struct const* getStructByName(char const* name) const noexcept;
97
108 RFK_NODISCARD REFUREKU_API Struct const* getStructByPredicate(Predicate<Struct> predicate,
109 void* userData) const;
110
121 RFK_NODISCARD REFUREKU_API Vector<Struct const*> getStructsByPredicate(Predicate<Struct> predicate,
122 void* userData) const;
123
135 REFUREKU_API bool foreachStruct(Visitor<Struct> visitor,
136 void* userData) const;
137
145 RFK_NODISCARD REFUREKU_API Class const* getClassByName(char const* name) const noexcept;
146
157 RFK_NODISCARD REFUREKU_API Class const* getClassByPredicate(Predicate<Class> predicate,
158 void* userData) const;
159
170 RFK_NODISCARD REFUREKU_API Vector<Class const*> getClassesByPredicate(Predicate<Class> predicate,
171 void* userData) const;
172
184 REFUREKU_API bool foreachClass(Visitor<Class> visitor,
185 void* userData) const;
186
194 RFK_NODISCARD REFUREKU_API Enum const* getEnumByName(char const* name) const noexcept;
195
206 RFK_NODISCARD REFUREKU_API Enum const* getEnumByPredicate(Predicate<Enum> predicate,
207 void* userData) const;
208
219 RFK_NODISCARD REFUREKU_API Vector<Enum const*> getEnumsByPredicate(Predicate<Enum> predicate,
220 void* userData) const;
221
233 REFUREKU_API bool foreachEnum(Visitor<Enum> visitor,
234 void* userData) const;
235
247 REFUREKU_API bool foreachArchetype(Visitor<Archetype> visitor,
248 void* userData) const;
249
255 REFUREKU_API std::size_t getArchetypesCount() const noexcept;
256
266 RFK_NODISCARD REFUREKU_API Variable const* getVariableByName(char const* name,
267 EVarFlags flags = EVarFlags::Default) const noexcept;
268
279 RFK_NODISCARD REFUREKU_API Variable const* getVariableByPredicate(Predicate<Variable> predicate,
280 void* userData) const;
281
292 RFK_NODISCARD REFUREKU_API Vector<Variable const*> getVariablesByPredicate(Predicate<Variable> predicate,
293 void* userData) const;
294
306 REFUREKU_API bool foreachVariable(Visitor<Variable> visitor,
307 void* userData) const;
308
314 REFUREKU_API std::size_t getVariablesCount() const noexcept;
315
325 template <typename FunctionSignature>
326 RFK_NODISCARD Function const* getFunctionByName(char const* name,
327 EFunctionFlags flags = EFunctionFlags::Default) const noexcept;
328
338 RFK_NODISCARD REFUREKU_API Function const* getFunctionByName(char const* name,
339 EFunctionFlags flags = EFunctionFlags::Default) const noexcept;
340
350 RFK_NODISCARD REFUREKU_API Vector<Function const*> getFunctionsByName(char const* name,
351 EFunctionFlags flags = EFunctionFlags::Default) const noexcept;
352
363 RFK_NODISCARD REFUREKU_API Function const* getFunctionByPredicate(Predicate<Function> predicate,
364 void* userData) const;
365
376 RFK_NODISCARD REFUREKU_API Vector<Function const*> getFunctionsByPredicate(Predicate<Function> predicate,
377 void* userData) const;
378
390 REFUREKU_API bool foreachFunction(Visitor<Function> visitor,
391 void* userData) const;
392
398 REFUREKU_API std::size_t getFunctionsCount() const noexcept;
399
405 REFUREKU_API void addNamespace(Namespace const& nestedNamespace) noexcept;
406
412 REFUREKU_API void addArchetype(Archetype const& archetype) noexcept;
413
419 REFUREKU_API void addVariable(Variable const& variable) noexcept;
420
426 REFUREKU_API void addFunction(Function const& function) noexcept;
427
433 REFUREKU_API void removeNamespace(Namespace const& nestedNamespace) noexcept;
434
440 REFUREKU_API void removeArchetype(Archetype const& archetype) noexcept;
441
447 REFUREKU_API void removeVariable(Variable const& variable) noexcept;
448
454 REFUREKU_API void removeFunction(Function const& function) noexcept;
455
456 private:
457 //Forward declaration
458 class NamespaceImpl;
459
460 RFK_GEN_GET_PIMPL(NamespaceImpl, Entity::getPimpl())
461 };
462
463 REFUREKU_TEMPLATE_API(rfk::Allocator<Namespace const*>);
464 REFUREKU_TEMPLATE_API(rfk::Vector<Namespace const*, rfk::Allocator<Namespace const*>>);
465
466 #include "Refureku/TypeInfo/Namespace/Namespace.inl"
467}
Definition: Allocator.h:19
Definition: Archetype.h:16
Definition: Entity.h:29
Definition: Enum.h:18
Definition: Function.h:17
Definition: Namespace.h:26
REFUREKU_API void removeNamespace(Namespace const &nestedNamespace) noexcept
Remove a nested namespace from this namespace.
RFK_NODISCARD REFUREKU_API Struct const * getStructByPredicate(Predicate< Struct > predicate, void *userData) const
Retrieve the first nested struct satisfying the provided predicate.
RFK_NODISCARD REFUREKU_API Variable const * getVariableByPredicate(Predicate< Variable > predicate, void *userData) const
Retrieve the first nested variable satisfying the provided predicate.
REFUREKU_API void addVariable(Variable const &variable) noexcept
Add a nested variable to this namespace.
RFK_NODISCARD REFUREKU_API Vector< Class const * > getClassesByPredicate(Predicate< Class > predicate, void *userData) const
Retrieve all nested classes satisfying the provided predicate.
REFUREKU_API bool foreachStruct(Visitor< Struct > visitor, void *userData) const
Execute the given visitor on all nested structs.
REFUREKU_API bool foreachEnum(Visitor< Enum > visitor, void *userData) const
Execute the given visitor on all nested enums.
RFK_NODISCARD REFUREKU_API Class const * getClassByName(char const *name) const noexcept
Retrieve a class from this namespace.
RFK_NODISCARD REFUREKU_API Enum const * getEnumByName(char const *name) const noexcept
Retrieve an enum from this namespace.
REFUREKU_API bool foreachVariable(Visitor< Variable > visitor, void *userData) const
Execute the given visitor on all nested variables.
REFUREKU_API void addArchetype(Archetype const &archetype) noexcept
Add a nested archetype to this namespace.
RFK_NODISCARD REFUREKU_API Vector< Function const * > getFunctionsByName(char const *name, EFunctionFlags flags=EFunctionFlags::Default) const noexcept
Retrieve all functions with a given name from this namespace.
RFK_NODISCARD REFUREKU_API Vector< Struct const * > getStructsByPredicate(Predicate< Struct > predicate, void *userData) const
Retrieve all nested structs satisfying the provided predicate.
REFUREKU_API std::size_t getNamespacesCount() const noexcept
Get the number of namespaces nested in this namespace.
REFUREKU_API bool foreachNamespace(Visitor< Namespace > visitor, void *userData) const
Execute the given visitor on all nested namespaces.
RFK_NODISCARD REFUREKU_API Variable const * getVariableByName(char const *name, EVarFlags flags=EVarFlags::Default) const noexcept
Retrieve a variable from this namespace.
REFUREKU_API bool foreachFunction(Visitor< Function > visitor, void *userData) const
Execute the given visitor on all nested functions.
RFK_NODISCARD Function const * getFunctionByName(char const *name, EFunctionFlags flags=EFunctionFlags::Default) const noexcept
Retrieve a function with a given name and signature from this namespace.
RFK_NODISCARD REFUREKU_API Vector< Variable const * > getVariablesByPredicate(Predicate< Variable > predicate, void *userData) const
Retrieve all nested variables satisfying the provided predicate.
RFK_NODISCARD REFUREKU_API Vector< Namespace const * > getNamespacesByPredicate(Predicate< Namespace > predicate, void *userData) const
Retrieve all nested namespaces satisfying the provided predicate.
REFUREKU_API bool foreachClass(Visitor< Class > visitor, void *userData) const
Execute the given visitor on all nested classes.
RFK_NODISCARD REFUREKU_API Enum const * getEnumByPredicate(Predicate< Enum > predicate, void *userData) const
Retrieve the first nested enum satisfying the provided predicate.
REFUREKU_API std::size_t getArchetypesCount() const noexcept
Get the number of archetypes nested in this namespace.
REFUREKU_API std::size_t getVariablesCount() const noexcept
Get the number of variables nested in this namespace.
REFUREKU_API void addNamespace(Namespace const &nestedNamespace) noexcept
Add a nested namespace to this namespace.
RFK_NODISCARD REFUREKU_API Vector< Function const * > getFunctionsByPredicate(Predicate< Function > predicate, void *userData) const
Retrieve all nested functions satisfying the provided predicate.
REFUREKU_API std::size_t getFunctionsCount() const noexcept
Get the number of functions nested in this namespace.
REFUREKU_API void addFunction(Function const &function) noexcept
Add a nested function to this namespace.
RFK_NODISCARD REFUREKU_API Struct const * getStructByName(char const *name) const noexcept
Retrieve a struct from this namespace.
REFUREKU_API void removeFunction(Function const &function) noexcept
Remove a nested function from this namespace.
RFK_NODISCARD REFUREKU_API Namespace const * getNamespaceByName(char const *name) const noexcept
Retrieve a namespace contained in this namespace.
RFK_NODISCARD REFUREKU_API Vector< Enum const * > getEnumsByPredicate(Predicate< Enum > predicate, void *userData) const
Retrieve all nested enums satisfying the provided predicate.
RFK_NODISCARD REFUREKU_API Class const * getClassByPredicate(Predicate< Class > predicate, void *userData) const
Retrieve the first nested class satisfying the provided predicate.
REFUREKU_API void removeArchetype(Archetype const &archetype) noexcept
Remove a nested archetype from this namespace.
REFUREKU_API void removeVariable(Variable const &variable) noexcept
Remove a nested variable from this namespace.
RFK_NODISCARD REFUREKU_API Function const * getFunctionByPredicate(Predicate< Function > predicate, void *userData) const
Retrieve the first nested function satisfying the provided predicate.
RFK_NODISCARD REFUREKU_API Namespace const * getNamespaceByPredicate(Predicate< Namespace > predicate, void *userData) const
Retrieve the first nested namespace satisfying the provided predicate.
REFUREKU_API bool foreachArchetype(Visitor< Archetype > visitor, void *userData) const
Execute the given visitor on all nested archetypes.
Definition: Struct.h:40
Definition: Variable.h:16
Definition: Vector.h:19
Definition: Allocator.h:16
bool(*)(T const &value, void *userData) Predicate
Predicate defining if a value is valid or not.
Definition: Predicate.h:21
EFunctionFlags
Definition: EFunctionFlags.h:17
bool(*)(T const &value, void *userData) Visitor
Visitor function.
Definition: Visitor.h:21
EVarFlags
Definition: EVarFlags.h:16