diff --git a/headers/meta.hpp/meta_all.hpp b/headers/meta.hpp/meta_all.hpp index fb0bc4e..1037a7a 100644 --- a/headers/meta.hpp/meta_all.hpp +++ b/headers/meta.hpp/meta_all.hpp @@ -9,3 +9,4 @@ #include "meta_fwd.hpp" #include "meta_infos.hpp" #include "meta_registry.hpp" +#include "meta_utilities.hpp" diff --git a/headers/meta.hpp/meta_fwd.hpp b/headers/meta.hpp/meta_fwd.hpp index cc8e0c7..19ff1ac 100644 --- a/headers/meta.hpp/meta_fwd.hpp +++ b/headers/meta.hpp/meta_fwd.hpp @@ -52,3 +52,19 @@ namespace meta_hpp template < typename Method > class method_; class namespace_; } + +namespace meta_hpp +{ + template < typename K, typename V > + using info_map = std::map>; + + using class_info_map = info_map; + using ctor_info_map = info_map; + using data_info_map = info_map; + using enum_info_map = info_map; + using evalue_info_map = info_map; + using function_info_map = info_map; + using member_info_map = info_map; + using method_info_map = info_map; + using namespace_info_map = info_map; +} diff --git a/headers/meta.hpp/meta_infos/class_info.hpp b/headers/meta.hpp/meta_infos/class_info.hpp index 20d7bc7..64971b6 100644 --- a/headers/meta.hpp/meta_infos/class_info.hpp +++ b/headers/meta.hpp/meta_infos/class_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class class_info final { diff --git a/headers/meta.hpp/meta_infos/ctor_info.hpp b/headers/meta.hpp/meta_infos/ctor_info.hpp index 770d0a6..3012a5c 100644 --- a/headers/meta.hpp/meta_infos/ctor_info.hpp +++ b/headers/meta.hpp/meta_infos/ctor_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class ctor_info final { diff --git a/headers/meta.hpp/meta_infos/data_info.hpp b/headers/meta.hpp/meta_infos/data_info.hpp index faf7811..1f5dd9e 100644 --- a/headers/meta.hpp/meta_infos/data_info.hpp +++ b/headers/meta.hpp/meta_infos/data_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class data_info final { diff --git a/headers/meta.hpp/meta_infos/enum_info.hpp b/headers/meta.hpp/meta_infos/enum_info.hpp index b21b7f4..6430153 100644 --- a/headers/meta.hpp/meta_infos/enum_info.hpp +++ b/headers/meta.hpp/meta_infos/enum_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class enum_info final { diff --git a/headers/meta.hpp/meta_infos/evalue_info.hpp b/headers/meta.hpp/meta_infos/evalue_info.hpp index c19ca79..13db9d5 100644 --- a/headers/meta.hpp/meta_infos/evalue_info.hpp +++ b/headers/meta.hpp/meta_infos/evalue_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class evalue_info final { diff --git a/headers/meta.hpp/meta_infos/function_info.hpp b/headers/meta.hpp/meta_infos/function_info.hpp index 74f911c..f84237c 100644 --- a/headers/meta.hpp/meta_infos/function_info.hpp +++ b/headers/meta.hpp/meta_infos/function_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class function_info final { diff --git a/headers/meta.hpp/meta_infos/member_info.hpp b/headers/meta.hpp/meta_infos/member_info.hpp index 8fd680e..d1bb8d3 100644 --- a/headers/meta.hpp/meta_infos/member_info.hpp +++ b/headers/meta.hpp/meta_infos/member_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class member_info final { diff --git a/headers/meta.hpp/meta_infos/method_info.hpp b/headers/meta.hpp/meta_infos/method_info.hpp index 591fabf..97483b0 100644 --- a/headers/meta.hpp/meta_infos/method_info.hpp +++ b/headers/meta.hpp/meta_infos/method_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class method_info final { diff --git a/headers/meta.hpp/meta_infos/namespace_info.hpp b/headers/meta.hpp/meta_infos/namespace_info.hpp index 5f17f32..855765f 100644 --- a/headers/meta.hpp/meta_infos/namespace_info.hpp +++ b/headers/meta.hpp/meta_infos/namespace_info.hpp @@ -6,6 +6,9 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + namespace meta_hpp { class namespace_info final { diff --git a/headers/meta.hpp/meta_registry.hpp b/headers/meta.hpp/meta_registry.hpp index bbbccd8..dbc2616 100644 --- a/headers/meta.hpp/meta_registry.hpp +++ b/headers/meta.hpp/meta_registry.hpp @@ -33,5 +33,134 @@ namespace meta_hpp member_info get_member_by_name(std::string_view name) const noexcept; method_info get_method_by_name(std::string_view name) const noexcept; namespace_info get_namespace_by_name(std::string_view name) const noexcept; + public: + template < typename... Internals > + registry& operator()(Internals&&... internals); + private: + template < typename Class > + void add_(const std::string& prefix, const class_& internal); + void add_(const std::string& prefix, const data_& internal); + template < typename Enum > + void add_(const std::string& prefix, const enum_& internal); + template < typename Function > + void add_(const std::string& prefix, const function_& internal); + template < typename Member > + void add_(const std::string& prefix, const member_& internal); + template < typename Method > + void add_(const std::string& prefix, const method_& internal); + void add_(const std::string& prefix, const namespace_& internal); + void add_(const std::string& prefix, ...) = delete; + private: + void add_info_(const std::string& prefix, const class_info& info); + void add_info_(const std::string& prefix, const ctor_info& info); + void add_info_(const std::string& prefix, const data_info& info); + void add_info_(const std::string& prefix, const enum_info& info); + void add_info_(const std::string& prefix, const evalue_info& info); + void add_info_(const std::string& prefix, const function_info& info); + void add_info_(const std::string& prefix, const member_info& info); + void add_info_(const std::string& prefix, const method_info& info); + void add_info_(const std::string& prefix, const namespace_info& info); + private: + class_info_map classes_; + data_info_map datas_; + enum_info_map enums_; + evalue_info_map evalues_; + function_info_map functions_; + member_info_map members_; + method_info_map methods_; + namespace_info_map namespaces_; }; } + +namespace meta_hpp +{ + template < typename... Internals > + inline registry& registry::operator()(Internals&&... internals) { + (add_(std::string{}, std::forward(internals)), ...); + return *this; + } +} + +namespace meta_hpp +{ + template < typename Class > + inline void registry::add_(const std::string& prefix, const class_& internal) { + add_info_(prefix, internal.make_info()); + } + + inline void registry::add_(const std::string& prefix, const data_& internal) { + add_info_(prefix, internal.make_info()); + } + + template < typename Enum > + inline void registry::add_(const std::string& prefix, const enum_& internal) { + add_info_(prefix, internal.make_info()); + } + + template < typename Function > + inline void registry::add_(const std::string& prefix, const function_& internal) { + add_info_(prefix, internal.make_info()); + } + + template < typename Member > + inline void registry::add_(const std::string& prefix, const member_& internal) { + add_info_(prefix, internal.make_info()); + } + + template < typename Method > + inline void registry::add_(const std::string& prefix, const method_& internal) { + add_info_(prefix, internal.make_info()); + } + + inline void registry::add_(const std::string& prefix, const namespace_& internal) { + add_info_(prefix, internal.make_info()); + } +} + +namespace meta_hpp +{ + inline void registry::add_info_(const std::string& prefix, const class_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const ctor_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const data_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const enum_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const evalue_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const function_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const member_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const method_info& info) { + (void)prefix; + (void)info; + } + + inline void registry::add_info_(const std::string& prefix, const namespace_info& info) { + (void)prefix; + (void)info; + } +} diff --git a/headers/meta.hpp/meta_registry/class_.hpp b/headers/meta.hpp/meta_registry/class_.hpp index 525931e..c6de986 100644 --- a/headers/meta.hpp/meta_registry/class_.hpp +++ b/headers/meta.hpp/meta_registry/class_.hpp @@ -6,9 +6,32 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/class_info.hpp" + namespace meta_hpp { template < typename Class > class class_ final { + public: + explicit class_(std::string name); + + class_info make_info() const; + private: + std::string name_; }; } + +namespace meta_hpp +{ + template < typename Class > + inline class_::class_(std::string name) + : name_{std::move(name)} {} + + template < typename Class > + inline class_info class_::make_info() const { + return class_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/ctor_.hpp b/headers/meta.hpp/meta_registry/ctor_.hpp index fd15a22..03d628d 100644 --- a/headers/meta.hpp/meta_registry/ctor_.hpp +++ b/headers/meta.hpp/meta_registry/ctor_.hpp @@ -6,9 +6,29 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/ctor_info.hpp" + namespace meta_hpp { template < typename... Args > class ctor_ final { + public: + explicit ctor_() = default; + + template < typename Class > + ctor_info make_info() const; + private: }; } + +namespace meta_hpp +{ + template < typename... Args > + template < typename Class > + inline ctor_info ctor_::make_info() const { + return ctor_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/data_.hpp b/headers/meta.hpp/meta_registry/data_.hpp index 0c6d281..ccbf5a0 100644 --- a/headers/meta.hpp/meta_registry/data_.hpp +++ b/headers/meta.hpp/meta_registry/data_.hpp @@ -6,8 +6,31 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/data_info.hpp" + namespace meta_hpp { class data_ final { + public: + explicit data_(std::string name, class value value); + + data_info make_info() const; + private: + std::string name_; + class value value_; }; } + +namespace meta_hpp +{ + inline data_::data_(std::string name, class value value) + : name_{std::move(name)} + , value_{std::move(value)} {} + + inline data_info data_::make_info() const { + return data_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/enum_.hpp b/headers/meta.hpp/meta_registry/enum_.hpp index d046015..3910210 100644 --- a/headers/meta.hpp/meta_registry/enum_.hpp +++ b/headers/meta.hpp/meta_registry/enum_.hpp @@ -6,9 +6,32 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/enum_info.hpp" + namespace meta_hpp { template < typename Enum > class enum_ final { + public: + explicit enum_(std::string name); + + enum_info make_info() const; + private: + std::string name_; }; } + +namespace meta_hpp +{ + template < typename Enum > + inline enum_::enum_(std::string name) + : name_{std::move(name)} {} + + template < typename Enum > + inline enum_info enum_::make_info() const { + return enum_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/evalue_.hpp b/headers/meta.hpp/meta_registry/evalue_.hpp index 397fe7a..a338fee 100644 --- a/headers/meta.hpp/meta_registry/evalue_.hpp +++ b/headers/meta.hpp/meta_registry/evalue_.hpp @@ -6,9 +6,34 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/evalue_info.hpp" + namespace meta_hpp { template < typename Enum > class evalue_ final { + public: + explicit evalue_(std::string name, Enum value); + + evalue_info make_info() const; + private: + std::string name_; + Enum value_; }; } + +namespace meta_hpp +{ + template < typename Enum > + inline evalue_::evalue_(std::string name, Enum value) + : name_{std::move(name)} + , value_{std::move(value)} {} + + template < typename Enum > + inline evalue_info evalue_::make_info() const { + return evalue_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/function_.hpp b/headers/meta.hpp/meta_registry/function_.hpp index 12a04ab..72273d2 100644 --- a/headers/meta.hpp/meta_registry/function_.hpp +++ b/headers/meta.hpp/meta_registry/function_.hpp @@ -6,9 +6,34 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/function_info.hpp" + namespace meta_hpp { template < typename Function > class function_ final { + public: + explicit function_(std::string name, Function instance); + + function_info make_info() const; + private: + std::string name_; + Function instance_; }; } + +namespace meta_hpp +{ + template < typename Function > + inline function_::function_(std::string name, Function instance) + : name_{std::move(name)} + , instance_{std::move(instance)} {} + + template < typename Function > + inline function_info function_::make_info() const { + return function_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/member_.hpp b/headers/meta.hpp/meta_registry/member_.hpp index a93eb31..0630d49 100644 --- a/headers/meta.hpp/meta_registry/member_.hpp +++ b/headers/meta.hpp/meta_registry/member_.hpp @@ -6,9 +6,34 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/member_info.hpp" + namespace meta_hpp { template < typename Member > class member_ final { + public: + explicit member_(std::string name, Member instance); + + member_info make_info() const; + private: + std::string name_; + Member instance_; }; } + +namespace meta_hpp +{ + template < typename Member > + inline member_::member_(std::string name, Member instance) + : name_{std::move(name)} + , instance_{std::move(instance)} {} + + template < typename Member > + inline member_info member_::make_info() const { + return member_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/method_.hpp b/headers/meta.hpp/meta_registry/method_.hpp index 2cb0530..7aa9aa1 100644 --- a/headers/meta.hpp/meta_registry/method_.hpp +++ b/headers/meta.hpp/meta_registry/method_.hpp @@ -6,9 +6,34 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/method_info.hpp" + namespace meta_hpp { template < typename Method > class method_ final { + public: + explicit method_(std::string name, Method instance); + + method_info make_info() const; + private: + std::string name_; + Method instance_; }; } + +namespace meta_hpp +{ + template < typename Method > + inline method_::method_(std::string name, Method instance) + : name_{std::move(name)} + , instance_{std::move(instance)} {} + + template < typename Method > + inline method_info method_::make_info() const { + return method_info{}; + } +} diff --git a/headers/meta.hpp/meta_registry/namespace_.hpp b/headers/meta.hpp/meta_registry/namespace_.hpp index cd21b26..bc4f16e 100644 --- a/headers/meta.hpp/meta_registry/namespace_.hpp +++ b/headers/meta.hpp/meta_registry/namespace_.hpp @@ -6,8 +6,29 @@ #pragma once +#include "../meta_fwd.hpp" +#include "../meta_utilities.hpp" + +#include "../meta_infos/namespace_info.hpp" + namespace meta_hpp { class namespace_ final { + public: + explicit namespace_(std::string name); + + namespace_info make_info() const; + private: + std::string name_; }; } + +namespace meta_hpp +{ + inline namespace_::namespace_(std::string name) + : name_{std::move(name)} {} + + inline namespace_info namespace_::make_info() const { + return namespace_info{}; + } +} diff --git a/headers/meta.hpp/meta_utilities.hpp b/headers/meta.hpp/meta_utilities.hpp new file mode 100644 index 0000000..8658506 --- /dev/null +++ b/headers/meta.hpp/meta_utilities.hpp @@ -0,0 +1,11 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "meta_fwd.hpp" + +#include "meta_utilities/value.hpp" diff --git a/headers/meta.hpp/meta_utilities/value.hpp b/headers/meta.hpp/meta_utilities/value.hpp new file mode 100644 index 0000000..461fa3f --- /dev/null +++ b/headers/meta.hpp/meta_utilities/value.hpp @@ -0,0 +1,23 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_fwd.hpp" + +namespace meta_hpp +{ + class value final { + public: + value() = delete; + + value(value&&) = default; + value& operator=(value&&) = default; + + value(const value&) = default; + value& operator=(const value&) = default; + }; +}