16#ifndef SIMICS_ATTRIBUTE_H
17#define SIMICS_ATTRIBUTE_H
20#if _MSVC_LANG < 201402L
21#error "The C++ compiler version is not supported (C++ API v2 requires C++14)"
23#elif defined __cplusplus
24#if __cplusplus < 201402L
25#error "The C++ compiler version is not supported (C++ API v2 requires C++14)"
29#include <simics/base/conf-object.h>
40#define GET_MACRO(_1, _2, NAME, ...) NAME
51#define ATTR_GETTER(...) \
52 IMPL(GET_MACRO(__VA_ARGS__, _G_DUAL, _G_SINGLE)(__VA_ARGS__))
53#define ATTR_SETTER(...) \
54 IMPL(GET_MACRO(__VA_ARGS__, _S_DUAL, _S_SINGLE)(__VA_ARGS__))
55#define ATTR_CLS_VAR(CLASS, VAR) \
56 simics::AttributeAccessor<CLASS, decltype(&CLASS::VAR), &CLASS::VAR>()
58#define ATTR_TYPE_STR(VAR) simics::attr_type_str<decltype(VAR)>()
69template <
typename CLASS,
typename MEMBER, MEMBER m>
71 static_assert(std::is_member_object_pointer<MEMBER>::value,
72 "type MEMBER is not a member object pointer type");
75 :
getter(detail::attr_getter_helper_dual<
76 MEMBER, CLASS>::template f<m>),
77 setter(detail::attr_setter_helper_dual<
78 MEMBER, CLASS>::template f<m>) {}
110 (
getter &&
setter) ? Sim_Attr_Optional : Sim_Attr_Pseudo) {}
115 template <
typename CLASS,
typename MEMBER, MEMBER m>
118 attr_attr_t
attr = Sim_Attr_Optional)
125 virtual const std::string &
name()
const {
129 virtual const std::string &
type()
const {
133 virtual const std::string &
desc()
const {
145 virtual attr_attr_t
attr()
const {
struct conf_object conf_object_t
Definition: bank-issue-callbacks-interface.h:23
Represents a Simics attribute.
Definition: attribute.h:88
virtual attr_setter setter() const
Definition: attribute.h:141
virtual const std::string & name() const
Definition: attribute.h:125
virtual const std::string & desc() const
Definition: attribute.h:133
virtual attr_getter getter() const
Definition: attribute.h:137
Attribute(Attribute &&)=default
Attribute(const std::string &name, const std::string &type, const std::string &desc, AttributeAccessor< CLASS, MEMBER, m > ref, attr_attr_t attr=Sim_Attr_Optional)
Definition: attribute.h:116
virtual ~Attribute()=default
virtual attr_attr_t attr() const
Definition: attribute.h:145
virtual const std::string & type() const
Definition: attribute.h:129
Attribute(const std::string &name, const std::string &type, const std::string &desc, attr_getter getter, attr_setter setter, attr_attr_t attr)
Definition: attribute.h:101
Attribute(const std::string &name, const std::string &type, const std::string &desc, attr_getter getter, attr_setter setter)
Definition: attribute.h:107
Definition: attr-value.h:23
std::add_pointer_t< attr_value_t(conf_object_t *)> attr_getter
Definition: attribute.h:62
std::add_pointer_t< set_error_t(conf_object_t *, attr_value_t *)> attr_setter
Definition: attribute.h:64
A container of get and set callbacks for a class member variable.
Definition: attribute.h:70
attr_setter setter
Definition: attribute.h:81
attr_getter getter
Definition: attribute.h:80
AttributeAccessor()
Definition: attribute.h:74