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

Go to the source code of this file.

Classes

class  cloe::events::Evaluate
 
class  cloe::events::EvaluateFactory
 

Typedefs

using cloe::events::EvaluateCallback = DirectCallback< Evaluate, double >
 

Detailed Description

See also
cloe/trigger/evaluate_event.cpp

This file defines the Evaluate event and the corresponding EvaluateFactory. These can be used to make comparisons between two values. For example, let us say that our model would like to make a comparison between some internal value SET_SPEED and a desired value TARGET_SET_SPEED. The user should then be able to insert a trigger with the event corresponding to:

SET_SPEED >= TARGET_SET_SPEED

The model will need to add the EvaluateCallback to its class:

std::shared_ptr<events::EvaluateCallback> callback_set_speed_;

And in it's enroll(Registrar& r) method, it should register the callback:

callback_set_speed_ = register_event<events::Evaluate, double>( r, std::make_unique<events::EvaluateFactory>( name() + "/set_speed", "set speed in km/h"));

In the process(const Sync& s) method, the trigger can then be called:

callback_set_speed_->trigger(s, set_speed_);