SMACC
Loading...
Searching...
No Matches
smacc_event_generator_library
eg_conditional_generator
src
eg_conditional_generator
eg_conditional_generator.cpp
Go to the documentation of this file.
1
#include <
eg_conditional_generator/eg_conditional_generator.h
>
2
3
namespace
smacc
4
{
5
namespace
event_generators
6
{
7
EgConditionalGenerator::EgConditionalGenerator
(
ConditionalGeneratorMode
mode, std::function <
bool
()> updatePredicate)
8
:mode_(mode),
9
updatePredicate_(updatePredicate)
10
{
11
12
}
13
14
void
EgConditionalGenerator::checkPredicateAndPost
()
15
{
16
if
(this->
updatePredicate_
())
17
{
18
this->
postEventTrue
();
19
}
20
else
21
{
22
this->
postEventFalse
();
23
}
24
}
25
26
void
EgConditionalGenerator::onEntry
()
27
{
28
if
(
mode_
==
ConditionalGeneratorMode::ONE_SHOT
)
29
{
30
this->
checkPredicateAndPost
();
31
}
32
}
33
34
void
EgConditionalGenerator::update
()
35
{
36
if
(
mode_
==
ConditionalGeneratorMode::ON_UPDATE
)
37
{
38
this->
checkPredicateAndPost
();
39
}
40
}
41
42
void
EgConditionalGenerator::setPredicateFunction
(std::function <
bool
()> updatePredicate)
43
{
44
updatePredicate_
= updatePredicate;
45
}
46
47
}
// namespace state_reactors
48
}
// namespace smacc
smacc::event_generators::EgConditionalGenerator::checkPredicateAndPost
void checkPredicateAndPost()
Definition:
eg_conditional_generator.cpp:14
smacc::event_generators::EgConditionalGenerator::updatePredicate_
std::function< bool()> updatePredicate_
Definition:
eg_conditional_generator.h:53
smacc::event_generators::EgConditionalGenerator::setPredicateFunction
void setPredicateFunction(std::function< bool()> updatePredicate)
Definition:
eg_conditional_generator.cpp:42
smacc::event_generators::EgConditionalGenerator::mode_
ConditionalGeneratorMode mode_
Definition:
eg_conditional_generator.h:45
smacc::event_generators::EgConditionalGenerator::postEventTrue
std::function< void()> postEventTrue
Definition:
eg_conditional_generator.h:51
smacc::event_generators::EgConditionalGenerator::EgConditionalGenerator
EgConditionalGenerator(ConditionalGeneratorMode mode, std::function< bool()> updatePredicate=nullptr)
Definition:
eg_conditional_generator.cpp:7
smacc::event_generators::EgConditionalGenerator::update
virtual void update() override
Definition:
eg_conditional_generator.cpp:34
smacc::event_generators::EgConditionalGenerator::postEventFalse
std::function< void()> postEventFalse
Definition:
eg_conditional_generator.h:52
smacc::event_generators::EgConditionalGenerator::onEntry
virtual void onEntry() override
Definition:
eg_conditional_generator.cpp:26
eg_conditional_generator.h
smacc::event_generators::ConditionalGeneratorMode
ConditionalGeneratorMode
Definition:
eg_conditional_generator.h:24
smacc::event_generators::ConditionalGeneratorMode::ON_UPDATE
@ ON_UPDATE
smacc::event_generators::ConditionalGeneratorMode::ONE_SHOT
@ ONE_SHOT
smacc
Definition:
callback_counter_semaphore.h:17
Generated by
1.9.5