$darkmode
nil_event.hpp File Reference
#include <memory>
#include <string>
#include <cloe/core.hpp>
#include <cloe/trigger.hpp>
#include <cloe/trigger/helper_macros.hpp>
Include dependency graph for nil_event.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CLOE_TRIGGER_NIL_EVENT_HPP_
 
#define DEFINE_NIL_EVENT(xName, xname, xdescription)
 

Macro Definition Documentation

◆ DEFINE_NIL_EVENT

#define DEFINE_NIL_EVENT (   xName,
  xname,
  xdescription 
)
Value:
class xName : public ::cloe::Event { \
public: \
explicit xName(const std::string& name) : ::cloe::Event(name) {} \
::cloe::EventPtr clone() const override { return std::make_unique<xName>(name()); } \
void to_json(::cloe::Json&) const override {} \
bool operator()(const ::cloe::Sync&) const { return true; } \
}; \
\
class _X_FACTORY(xName) : public ::cloe::EventFactory { \
public: \
using EventType = xName; \
\
_X_FACTORY(xName)() : ::cloe::EventFactory(xname, xdescription) {} \
\
std::unique_ptr<::cloe::Event> make(const ::cloe::Conf&) const override { \
return std::make_unique<xName>(this->name()); \
} \
\
std::unique_ptr<::cloe::Event> make(const std::string&) const override { \
return std::make_unique<xName>(this->name()); \
} \
}; \
\
using _X_CALLBACK(xName) = ::cloe::DirectCallback<xName>;
Definition: registrar.hpp:45
virtual void to_json(Json &) const =0
TriggerFactory< Event > EventFactory
Definition: trigger.hpp:516
Definition: coordinator.hpp:36
Definition: trigger.hpp:487
virtual EventPtr clone() const =0
Definition: trigger.hpp:300
std::string name() const
Definition: entity.hpp:68

Macro DEFINE_NIL_EVENT defines an event that has no state and no configuration.

Parameters
xNameidentifier for event
xnamestring identifier of event (lowercase)
xdescriptionstring description of event

Given the stateless event "start of simulation", we can create it in code like so, note that the semicolon at the end is required.

DEFINE_NIL_EVENT(Start, "start", "start of simulation")

This will define the following classes for us:

  • Event
  • EventFactory
  • EventCallback

This event can be registered with the register_event helper function.