SMACC2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
smacc2::event_generators::EgConditionalGenerator Class Reference

#include <eg_conditional_generator.hpp>

Inheritance diagram for smacc2::event_generators::EgConditionalGenerator:
Inheritance graph
Collaboration diagram for smacc2::event_generators::EgConditionalGenerator:
Collaboration graph

Public Member Functions

 EgConditionalGenerator (ConditionalGeneratorMode mode, std::function< bool()> updatePredicate=nullptr)
 
virtual ~EgConditionalGenerator ()
 
void onEntry () override
 
template<typename TState , typename TSource >
void onStateAllocation ()
 
virtual void update () override
 
void setPredicateFunction (std::function< bool()> updatePredicate)
 
- Public Member Functions inherited from smacc2::SmaccEventGenerator
 SmaccEventGenerator ()
 
virtual ~SmaccEventGenerator ()
 
template<typename TState , typename TSource >
void onStateAllocation ()
 
virtual void onEntry ()
 
virtual void onExit ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
void initialize (ISmaccState *ownerState)
 
virtual void onInitialized ()
 
- Public Member Functions inherited from smacc2::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

Public Attributes

ConditionalGeneratorMode mode_
 

Private Member Functions

void checkPredicateAndPost ()
 

Private Attributes

std::function< void()> postEventTrue
 
std::function< void()> postEventFalse
 
std::function< bool()> updatePredicate_
 

Additional Inherited Members

virtual void update ()=0
 

Detailed Description

Definition at line 44 of file eg_conditional_generator.hpp.

Constructor & Destructor Documentation

◆ EgConditionalGenerator()

smacc2::event_generators::EgConditionalGenerator::EgConditionalGenerator ( ConditionalGeneratorMode  mode,
std::function< bool()>  updatePredicate = nullptr 
)

Definition at line 21 of file eg_conditional_generator.cpp.

◆ ~EgConditionalGenerator()

smacc2::event_generators::EgConditionalGenerator::~EgConditionalGenerator ( )
virtual

Definition at line 27 of file eg_conditional_generator.cpp.

27{}

Member Function Documentation

◆ checkPredicateAndPost()

void smacc2::event_generators::EgConditionalGenerator::checkPredicateAndPost ( )
private

Definition at line 29 of file eg_conditional_generator.cpp.

30{
31 if (this->updatePredicate_())
32 {
33 this->postEventTrue();
34 }
35 else
36 {
37 this->postEventFalse();
38 }
39}

References postEventFalse, postEventTrue, and updatePredicate_.

Referenced by onEntry(), and update().

Here is the caller graph for this function:

◆ onEntry()

void smacc2::event_generators::EgConditionalGenerator::onEntry ( )
overridevirtual

◆ onStateAllocation()

template<typename TState , typename TSource >
void smacc2::event_generators::EgConditionalGenerator::onStateAllocation ( )
inline

Definition at line 54 of file eg_conditional_generator.hpp.

55 {
56 this->postEventTrue = [this]() { this->postEvent<EvTrue<TSource, TState>>(); };
57 this->postEventFalse = [this]() { this->postEvent<EvFalse<TSource, TState>>(); };
58 }

References postEventFalse, and postEventTrue.

◆ setPredicateFunction()

void smacc2::event_generators::EgConditionalGenerator::setPredicateFunction ( std::function< bool()>  updatePredicate)

Definition at line 57 of file eg_conditional_generator.cpp.

58{
59 updatePredicate_ = updatePredicate;
60}

References updatePredicate_.

◆ update()

void smacc2::event_generators::EgConditionalGenerator::update ( )
overridevirtual

Implements smacc2::ISmaccUpdatable.

Definition at line 49 of file eg_conditional_generator.cpp.

References checkPredicateAndPost(), mode_, and smacc2::event_generators::ON_UPDATE.

Here is the call graph for this function:

Member Data Documentation

◆ mode_

ConditionalGeneratorMode smacc2::event_generators::EgConditionalGenerator::mode_

Definition at line 61 of file eg_conditional_generator.hpp.

Referenced by onEntry(), and update().

◆ postEventFalse

std::function<void()> smacc2::event_generators::EgConditionalGenerator::postEventFalse
private

Definition at line 68 of file eg_conditional_generator.hpp.

Referenced by checkPredicateAndPost(), and onStateAllocation().

◆ postEventTrue

std::function<void()> smacc2::event_generators::EgConditionalGenerator::postEventTrue
private

Definition at line 67 of file eg_conditional_generator.hpp.

Referenced by checkPredicateAndPost(), and onStateAllocation().

◆ updatePredicate_

std::function<bool()> smacc2::event_generators::EgConditionalGenerator::updatePredicate_
private

Definition at line 69 of file eg_conditional_generator.hpp.

Referenced by checkPredicateAndPost(), and setPredicateFunction().


The documentation for this class was generated from the following files: