$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 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:46
const std::string & name() const
Definition: entity.hpp:67
Definition: trigger.hpp:482
virtual EventPtr clone() const =0
virtual void to_json(fable::Json &) const =0
Definition: trigger.hpp:290
TriggerFactory< Event > EventFactory
Definition: cloe_fwd.hpp:80

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

Example

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")
#define DEFINE_NIL_EVENT(xName, xname, xdescription)
Definition: nil_event.hpp:57

This will define the following classes for us:

  • Event
  • EventFactory
  • EventCallback

This event can be registered with the register_event helper function.