16#ifndef SIMICS_CONF_CLASS_H
17#define SIMICS_CONF_CLASS_H
19#include <simics/base/conf-object.h>
65 const std::string &
name,
66 const std::string &short_desc,
68 const class_kind_t kind,
74 const std::string &
name,
75 const std::string &short_desc,
77 const class_kind_t kind,
78 const iface::ObjectFactoryInterface &factory);
95 operator conf_class_t*()
const;
100 const std::string &
name()
const;
180 void register_log_groups() const noexcept;
183 void register_interfaces() noexcept;
185 conf_class_t *cls_ {
nullptr};
187 std::string description_;
188 std::vector<std::string> log_groups_;
189 std::map<std::string, const interface_t *> pending_interfaces_;
210make_class(
const std::string &name,
const std::string &short_desc,
211 const std::string &description,
212 const class_kind_t kind = Sim_Class_Kind_Vanilla) {
215 detail::init_class<T>(cls.get());
216 decorate_class<T>(
nullptr, cls.get());
234make_class(
const std::string &name,
const std::string &short_desc,
235 const std::string &description, A *constructor_arg,
236 const class_kind_t kind = Sim_Class_Kind_Vanilla) {
240 detail::init_class<T>(cls.get());
241 decorate_class<T>(
nullptr, cls.get());
273template <
typename T,
typename A = None>
276 template <
typename U = A>
277 using EnableIfNone = std::enable_if_t<std::is_same<U, None>::value,
int>;
280 template <
typename U = A>
281 using EnableIfNotNone = std::enable_if_t<!std::is_same<U, None>::value,
286 template <
typename U = A, EnableIfNone<U> = 0>
constexpr
288 const std::string &short_desc,
289 const std::string &description,
290 const class_kind_t kind = Sim_Class_Kind_Vanilla) {
291 make_class<T>(name, short_desc, description, kind);
295 template <
typename U = A, EnableIfNotNone<U> = 0>
constexpr
297 const std::string &short_desc,
298 const std::string &description,
300 const class_kind_t kind = Sim_Class_Kind_Vanilla) {
301 make_class<T, A>(name, short_desc, description, constructor_arg, kind);
305#define GROUP_ID(...) \
306 IMPL(GET_MACRO(__VA_ARGS__, GROUP_ID_TWO_ARGS, \
307 GROUP_ID_ONE_ARG)(__VA_ARGS__))
309#define GROUP_ID_ONE_ARG(NAME) \
310 simics::ConfClass::getGroupId(SIM_object_class(obj()), #NAME)
312#define GROUP_ID_TWO_ARGS(OBJ, NAME) \
313 simics::ConfClass::getGroupId(SIM_object_class(OBJ), #NAME)
Represents a Simics attribute.
Definition: attribute.h:79
Represents a Simics class attribute.
Definition: attribute.h:152
Represents Simics C type conf_class_t.
Definition: conf-class.h:52
static uint64 getGroupId(conf_class_t *cls, const std::string &name)
Return the ID of a log group.
ConfClass * add(ConfClass *port, const std::string &name)
A function to add a port object to the set of ports defined by the class.
ConfClass * add(const Attribute &attr)
A function to add an attribute to the set of attributes of ConfClass.
const std::string & name() const
Return the class name.
const std::string & description() const
Return the class description.
ConfClass(const ConfClass &)=delete
Avoid implicit copy.
ConfClass * add(EventInfo &&event)
A function to add an event to the set of events of ConfClass.
ConfClass * add(const ClassAttribute &attr)
static ConfClassPtr createInstance(const std::string &name, const std::string &short_desc, const std::string &description, const class_kind_t kind, const ObjectFactoryInterface &factory)
Factory function to create a ConfClass instance All parameters except the last one is used to call th...
ConfClass * add(const iface::InterfaceInfo &iface)
Stores the provided InterfaceInfo for later registration.
ConfClass(conf_class_t *cls, const std::string &name, const std::string &description)
Must use factory method to create instance.
Definition: conf-class.h:174
ConfClass * add(const ConfClassPtr &port, const std::string &name)
ConfClass * add(const LogGroups &names)
ConfClass * add(const char *const *names)
Functions to add log groups that an object can use to separate messages.
const std::vector< std::string > & log_groups() const
Return the class log groups.
ConfClass & operator=(const ConfClass &)=delete
Definition: conf-class.h:246
Interface for a factory pattern to create ConfObject instances.
Definition: object-factory-interface.h:31
A factory for creating instances of ConfObject-derived classes with an argument.
Definition: object-factory.h:78
A factory for creating instances of ConfObject-derived classes.
Definition: object-factory.h:35
Utility class for automatic registration of C++ classes with Simics.
Definition: conf-class.h:274
constexpr RegisterClassWithSimics(const std::string &name, const std::string &short_desc, const std::string &description, A *constructor_arg, const class_kind_t kind=Sim_Class_Kind_Vanilla)
Definition: conf-class.h:296
constexpr RegisterClassWithSimics(const std::string &name, const std::string &short_desc, const std::string &description, const class_kind_t kind=Sim_Class_Kind_Vanilla)
Definition: conf-class.h:287
Definition: interface-info.h:27
Definition: after-bank.h:33
std::initializer_list< std::string > LogGroups
Type used for log group names.
Definition: log.h:27
std::unique_ptr< ConfClass > ConfClassPtr
Definition: conf-class.h:38
void decorate_class(...)
Overload it with specific implementation by including the other header before this file.
Definition: conf-class.h:195
ConfClassPtr make_class(const std::string &name, const std::string &short_desc, const std::string &description, const class_kind_t kind=Sim_Class_Kind_Vanilla)
A factory method to create a ConfClassPtr which associate with the C++ class T.
Definition: conf-class.h:210