19#include <simics/base/event.h>
20#include <simics/base/sim-exception.h>
21#include <simics/base/time.h>
34using ev_callback = std::add_pointer_t<void(conf_object_t *,
void *)>;
40using ev_describe = std::add_pointer_t<
char *(conf_object_t *obj,
57 event_class_t **
ev {
nullptr};
95 operator event_class_t *()
const;
103 static_assert(std::is_base_of<ConfObject, T>::value,
104 "T must be a descendant of ConfObject");
105 return static_cast<T *
>(
obj_);
111 event_class_t *
ev_ {
nullptr};
118template <
typename T = ConfObject>
125 bool posted(
void *match_data =
nullptr)
const override {
126 return next(match_data) >= 0.0;
129 void remove(
void *match_data =
nullptr)
const override {
136 void post(
double seconds,
void *data =
nullptr)
override {
142 "Queue not set, unable to post events");
147 if (SIM_clear_exception() != SimExc_No_Exception) {
148 SIM_LOG_ERROR(
obj_->
obj(), 0,
"%s", SIM_last_error());
152 double next(
void *match_data =
nullptr)
const override {
165template <
typename T = ConfObject>
172 bool posted(
void *match_data =
nullptr)
const override {
173 return next(match_data) >= 0;
176 void remove(
void *match_data =
nullptr)
const override {
184 void post(cycles_t cycles,
void *data =
nullptr)
override {
190 if (SIM_clear_exception() != SimExc_No_Exception) {
191 SIM_LOG_ERROR(
obj_->
obj(), 0,
"%s", SIM_last_error());
195 cycles_t
next(
void *match_data =
nullptr)
const override {
208template <
typename T = ConfObject>
215 bool posted(
void *match_data =
nullptr)
const override {
216 return next(match_data) >= 0;
219 void remove(
void *match_data =
nullptr)
const override {
226 void post(pc_step_t steps,
void *data =
nullptr)
override {
232 if (SIM_clear_exception() != SimExc_No_Exception) {
233 SIM_LOG_ERROR(
obj_->
obj(), 0,
"%s", SIM_last_error());
237 pc_step_t
next(
void *match_data =
nullptr)
const override {
Base class for all Simics configuration objects.
Definition: conf-object.h:126
ConfObjectRef obj() const
Return a ConfObjectRef represents this object.
Definition: conf-object.h:137
Definition: event-interface.h:61
Cycle-based event type.
Definition: event.h:167
void post(cycles_t cycles, void *data=nullptr) override
Posts the event on the associated queue of the device.
Definition: event.h:184
T * dev_
Definition: event.h:204
cycles_t next(void *match_data=nullptr) const override
Returns the cycles to the next occurrence of the event in the queue (relative to the current time)
Definition: event.h:195
bool posted(void *match_data=nullptr) const override
Returns true if the event is in the queue, and false otherwise.
Definition: event.h:172
void remove(void *match_data=nullptr) const override
Removes all events of this type with matching data from the queue.
Definition: event.h:176
An event is required to implement the interface.
Definition: event-interface.h:29
The Event class allows users to define callbacks that will be executed after a specified delay.
Definition: event.h:79
Event(ConfObject *obj, const std::string &name)
T * device_ptr() const
Definition: event.h:102
const char * name() const
void destroy(void *data) override
Called when the event is removed from the queue without being called.
conf_object_t * clock_
clock_ cannot be initialized here by SIM_object_clock, since attribute queue is not set yet
Definition: event.h:114
attr_value_t get_value(void *data) override
Called to convert the event data into a value that can be saved in a configuration.
void * set_value(attr_value_t value) override
Called to convert a configuration value into event data.
Event(ConfObject *obj, event_class_t *ev)
static int pointer_eq(void *data, void *match_data)
ConfObject * obj_
Definition: event.h:110
char * describe(void *data) const override
Called to generate a human-readable description of the event to be used in the print-event-queue comm...
event_class_t * ev_
Definition: event.h:111
Definition: event-interface.h:75
Not commonly used for device model. Step-based event type.
Definition: event.h:210
void remove(void *match_data=nullptr) const override
Removes all events of this type with matching data from the queue.
Definition: event.h:219
pc_step_t next(void *match_data=nullptr) const override
Returns the steps to the next occurrence of the event in the queue (relative to the current time)
Definition: event.h:237
bool posted(void *match_data=nullptr) const override
Returns true if the event is in the queue, and false otherwise.
Definition: event.h:215
void post(pc_step_t steps, void *data=nullptr) override
Posts the event on the associated queue of the device.
Definition: event.h:226
T * dev_
Definition: event.h:246
Definition: event-interface.h:47
Time-based event type.
Definition: event.h:120
void post(double seconds, void *data=nullptr) override
Posts the event on the associated queue of the device.
Definition: event.h:136
T * dev_
Definition: event.h:161
double next(void *match_data=nullptr) const override
Returns the time to the next occurrence of the event in the queue (relative to the current time)
Definition: event.h:152
bool posted(void *match_data=nullptr) const override
Returns true if the event is in the queue, and false otherwise.
Definition: event.h:125
void remove(void *match_data=nullptr) const override
Removes all events of this type with matching data from the queue.
Definition: event.h:129
Definition: after-bank.h:33
std::add_pointer_t< char *(conf_object_t *obj, void *data)> ev_describe
Definition: event.h:41
ev_callback ev_destroy
Definition: event.h:35
std::add_pointer_t< void *(conf_object_t *obj, attr_value_t value)> ev_value_setter
Definition: event.h:39
std::add_pointer_t< attr_value_t(conf_object_t *obj, void *data)> ev_value_getter
Definition: event.h:37
std::add_pointer_t< void(conf_object_t *, void *)> ev_callback
Definition: event.h:34
EventInfo(const std::string &name, event_class_flag_t flags, event_class_t **ev, ev_callback callback, ev_destroy destroy, ev_value_getter get_value, ev_value_setter set_value, ev_describe describe)
event_class_t ** ev
Definition: event.h:57
EventInfo(const std::string &name, event_class_t **ev, ev_callback callback)
ev_value_getter get_value
Definition: event.h:60
ev_callback callback
Definition: event.h:58
event_class_flag_t flags
Definition: event.h:56
ev_describe describe
Definition: event.h:62
ev_destroy destroy
Definition: event.h:59
ev_value_setter set_value
Definition: event.h:61
std::string name
Definition: event.h:55