mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 03:45:30 +07:00
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
/*******************************************************************************
|
|
* 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_data.hpp"
|
|
|
|
#include "meta_variable_info.hpp"
|
|
|
|
namespace meta_hpp
|
|
{
|
|
template < auto Variable >
|
|
class variable_ {
|
|
public:
|
|
explicit variable_(std::string id)
|
|
: info_(std::move(id)) {
|
|
info_.getter_ = &variable_detail::getter<Variable>;
|
|
info_.setter_ = &variable_detail::setter<Variable>;
|
|
}
|
|
|
|
const variable_info& info() const noexcept {
|
|
return info_;
|
|
}
|
|
|
|
template < typename... Internals >
|
|
variable_& operator()(Internals&&...internals) {
|
|
(add_(std::forward<Internals>(internals)), ...);
|
|
return *this;
|
|
}
|
|
private:
|
|
void add_(const data_& internal) {
|
|
detail::merge_with(
|
|
info_.datas_,
|
|
internal.info().id(),
|
|
internal.info(),
|
|
&data_info::merge_with_);
|
|
}
|
|
private:
|
|
variable_info info_;
|
|
};
|
|
}
|