remove all value family id

This commit is contained in:
BlackMATov
2021-07-07 00:19:30 +07:00
parent e471b3b70a
commit d08fe88b85
8 changed files with 29 additions and 258 deletions

View File

@@ -66,13 +66,10 @@ namespace meta_hpp
field_info& operator=(field_info&&) = default;
field_info& operator=(const field_info&) = default;
public:
const family_id& fid() const noexcept {
return fid_;
}
const std::string& id() const noexcept {
return id_;
}
value get(cinstance instance) const {
return getter_(instance);
}
@@ -99,7 +96,7 @@ namespace meta_hpp
}
void merge(const field_info& other) {
if ( fid() != other.fid() ) {
if ( id() != other.id() ) {
throw std::logic_error("field_info::merge failed");
}
detail::merge_with(datas_, other.datas_, &data_info::merge);
@@ -110,12 +107,10 @@ namespace meta_hpp
template < typename FieldType, FieldType Field >
field_info(detail::auto_arg_t<FieldType, Field>, std::string id)
: fid_{get_value_family_id<FieldType, Field>()}
, id_{std::move(id)}
: id_{std::move(id)}
, getter_{&field_detail::getter<FieldType, Field>}
, setter_{&field_detail::setter<FieldType, Field>} {}
private:
family_id fid_;
std::string id_;
value(*getter_)(cinstance);
void(*setter_)(instance, value);

View File

@@ -60,10 +60,6 @@ namespace meta_hpp
function_info& operator=(function_info&&) = default;
function_info& operator=(const function_info&) = default;
public:
const family_id& fid() const noexcept {
return fid_;
}
const std::string& id() const noexcept {
return id_;
}
@@ -95,7 +91,7 @@ namespace meta_hpp
}
void merge(const function_info& other) {
if ( fid() != other.fid() ) {
if ( id() != other.id() ) {
throw std::logic_error("function_info::merge failed");
}
detail::merge_with(datas_, other.datas_, &data_info::merge);
@@ -106,11 +102,9 @@ namespace meta_hpp
template < typename FunctionType, FunctionType Function >
function_info(detail::auto_arg_t<FunctionType, Function>, std::string id)
: fid_{get_value_family_id<FunctionType, Function>()}
, id_{std::move(id)}
: id_{std::move(id)}
, invoke_{&function_detail::invoke<FunctionType, Function>} {}
private:
family_id fid_;
std::string id_;
std::optional<value>(*invoke_)(value*, std::size_t);
std::map<std::string, data_info, std::less<>> datas_;

View File

@@ -78,27 +78,12 @@ namespace meta_hpp
return self_id;
}
};
template < typename T, T V >
class value_family final : public family_base<> {
public:
static family_id id() noexcept {
static family_id self_id{++last_id_};
assert(self_id.id > 0u && "family_id overflow");
return self_id;
}
};
}
template < typename T >
family_id get_type_family_id() noexcept {
return family_id_detail::type_family<T>::id();
}
template < typename T, T V >
family_id get_value_family_id() noexcept {
return family_id_detail::value_family<T, V>::id();
}
}
namespace meta_hpp

View File

@@ -110,10 +110,6 @@ namespace meta_hpp
method_info& operator=(method_info&&) = default;
method_info& operator=(const method_info&) = default;
public:
const family_id& fid() const noexcept {
return fid_;
}
const std::string& id() const noexcept {
return id_;
}
@@ -155,7 +151,7 @@ namespace meta_hpp
}
void merge(const method_info& other) {
if ( fid() != other.fid() ) {
if ( id() != other.id() ) {
throw std::logic_error("method_info::merge failed");
}
detail::merge_with(datas_, other.datas_, &data_info::merge);
@@ -166,12 +162,10 @@ namespace meta_hpp
template < typename MethodType, MethodType Method >
method_info(detail::auto_arg_t<MethodType, Method>, std::string id)
: fid_{get_value_family_id<MethodType, Method>()}
, id_{std::move(id)}
: id_{std::move(id)}
, invoke_{&method_detail::invoke<MethodType, Method>}
, cinvoke_{&method_detail::cinvoke<MethodType, Method>} {}
private:
family_id fid_;
std::string id_;
std::optional<value>(*invoke_)(instance, value*, std::size_t);
std::optional<value>(*cinvoke_)(cinstance, value*, std::size_t);

View File

@@ -27,12 +27,6 @@ namespace meta_hpp
return detail::find_opt(types_, fid);
}
template < typename T, T V >
std::optional<type> resolve() const {
const family_id fid = get_value_family_id<T, V>();
return detail::find_opt(types_, fid);
}
template < typename T >
std::optional<type> resolve(T&&) const {
const family_id fid = get_type_family_id<std::decay_t<T>>();
@@ -149,7 +143,6 @@ namespace meta_hpp
? info.id()
: prefix + "::" + info.id();
detail::merge_with(types_, info.fid(), info, &type::merge);
detail::merge_with(fields_, name, info, &field_info::merge);
info.visit(overloaded {
@@ -165,7 +158,6 @@ namespace meta_hpp
? info.id()
: prefix + "::" + info.id();
detail::merge_with(types_, info.fid(), info, &type::merge);
detail::merge_with(functions_, name, info, &function_info::merge);
info.visit(overloaded {
@@ -181,7 +173,6 @@ namespace meta_hpp
? info.id()
: prefix + "::" + info.id();
detail::merge_with(types_, info.fid(), info, &type::merge);
detail::merge_with(methods_, name, info, &method_info::merge);
info.visit(overloaded {
@@ -212,7 +203,6 @@ namespace meta_hpp
? info.id()
: prefix + "::" + info.id();
detail::merge_with(types_, info.fid(), info, &type::merge);
detail::merge_with(variables_, name, info, &variable_info::merge);
info.visit(overloaded {

View File

@@ -53,10 +53,6 @@ namespace meta_hpp
variable_info& operator=(variable_info&&) = default;
variable_info& operator=(const variable_info&) = default;
public:
const family_id& fid() const noexcept {
return fid_;
}
const std::string& id() const noexcept {
return id_;
}
@@ -87,7 +83,7 @@ namespace meta_hpp
}
void merge(const variable_info& other) {
if ( fid() != other.fid() ) {
if ( id() != other.id() ) {
throw std::logic_error("variable_info::merge failed");
}
detail::merge_with(datas_, other.datas_, &data_info::merge);
@@ -98,12 +94,10 @@ namespace meta_hpp
template < typename VariableType, VariableType Variable >
variable_info(detail::auto_arg_t<VariableType, Variable>, std::string id)
: fid_{get_value_family_id<VariableType, Variable>()}
, id_{std::move(id)}
: id_{std::move(id)}
, getter_{&variable_detail::getter<VariableType, Variable>}
, setter_{&variable_detail::setter<VariableType, Variable>} {}
private:
family_id fid_;
std::string id_;
value(*getter_)();
void(*setter_)(value);