-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStateCommand.h
executable file
·49 lines (39 loc) · 1.46 KB
/
StateCommand.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include"RxFSM/IncludeExtLibs.h"
namespace Reactor
{
/**
* One action associated with every command
* - A command may hold "entry actions", "exit actions", "input action", "transition actions"
*
* An InputCommand is essentially the same as a StateCommand, use different typename Input vs Output
*/
template <typename Return>
class StateCommandController : public CommandControllerAction<Return>
{
public:
StateCommandController(CommandControllerPolicy policy, RxThreadPool::Ptr threadPool)
: CommandControllerAction<Return>(policy, threadPool)
, condition_(std::make_shared<Templates::AlwaysTrigger<Return>>(Templates::AlwaysTrigger<Return>()))
{ }
StateCommandController(Templates::TriggerCondition<Return>* condition,
CommandControllerPolicy policy,
RxThreadPool::Ptr threadPool)
: CommandControllerAction<Return>(policy, threadPool)
, condition_(condition)
{ }
virtual ~StateCommandController()
{ }
CLASS_TRAITS(StateCommandController)
std::shared_ptr<Templates::TriggerCondition<Return>> Condition() const
{
return condition_;
}
void SetCondition(Templates::TriggerCondition<Return>* condition)
{
condition_ = std::make_shared<Templates::TriggerConditionHolder<Return>>(Templates::TriggerConditionHolder<Return>(condition));
}
private:
std::shared_ptr<Templates::TriggerCondition<Return>> condition_;
};
}