SMACC
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
smacc::event_generators::EgConditionalGenerator Class Reference

#include <eg_conditional_generator.h>

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

Public Member Functions

 EgConditionalGenerator (ConditionalGeneratorMode mode, std::function< bool()> updatePredicate=nullptr)
 
virtual 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 smacc::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 smacc::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (ros::Duration duration)
 
void executeUpdate ()
 
void setUpdatePeriod (ros::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 30 of file eg_conditional_generator.h.

Constructor & Destructor Documentation

◆ EgConditionalGenerator()

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

Definition at line 7 of file eg_conditional_generator.cpp.

8 :mode_(mode),
9 updatePredicate_(updatePredicate)
10 {
11
12 }

Member Function Documentation

◆ checkPredicateAndPost()

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

Definition at line 14 of file eg_conditional_generator.cpp.

15 {
16 if(this->updatePredicate_())
17 {
18 this->postEventTrue();
19 }
20 else
21 {
22 this->postEventFalse();
23 }
24 }

References postEventFalse, postEventTrue, and updatePredicate_.

Referenced by onEntry(), and update().

Here is the caller graph for this function:

◆ onEntry()

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

◆ onStateAllocation()

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

Definition at line 38 of file eg_conditional_generator.h.

39 {
40 this->postEventTrue = [this]() { this->postEvent<EvTrue<TSource, TState>>(); };
41 this->postEventFalse = [this]() { this->postEvent<EvFalse<TSource, TState>>(); };
42 }

References postEventFalse, and postEventTrue.

◆ setPredicateFunction()

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

Definition at line 42 of file eg_conditional_generator.cpp.

43 {
44 updatePredicate_ = updatePredicate;
45 }

References updatePredicate_.

◆ update()

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

Implements smacc::ISmaccUpdatable.

Definition at line 34 of file eg_conditional_generator.cpp.

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

Here is the call graph for this function:

Member Data Documentation

◆ mode_

ConditionalGeneratorMode smacc::event_generators::EgConditionalGenerator::mode_

Definition at line 45 of file eg_conditional_generator.h.

Referenced by onEntry(), and update().

◆ postEventFalse

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

Definition at line 52 of file eg_conditional_generator.h.

Referenced by checkPredicateAndPost(), and onStateAllocation().

◆ postEventTrue

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

Definition at line 51 of file eg_conditional_generator.h.

Referenced by checkPredicateAndPost(), and onStateAllocation().

◆ updatePredicate_

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

Definition at line 53 of file eg_conditional_generator.h.

Referenced by checkPredicateAndPost(), and setPredicateFunction().


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