Scheduler
action.h
Go to the documentation of this file.
1 
10 #ifndef ACTION_H
11 #define ACTION_H
12 
13 #include <iostream>
14 #include <memory>
15 #include <string>
16 #include <stdexcept>
17 
18 namespace Mdp
19 {
20 
21 class ActionSpace;
22 class ActionSpaceBuilder;
23 class DomainModel;
24 
25 class Action
26 {
27 friend ActionSpace;
28 friend ActionSpaceBuilder;
29 public:
30  virtual ~Action(){};
31  virtual std::string getName()=0;
32  virtual void performAction()=0;
33 protected:
34 
35  template<typename T>
36  std::shared_ptr<T> getModel()
37  {
38  std::shared_ptr<T> model = std::dynamic_pointer_cast<T>(domainModel);
39  if (model == nullptr)
40  throw std::runtime_error("inconsistent domain model type");
41  return model;
42  }
43  std::shared_ptr<DomainModel> domainModel{nullptr};
44 };
45 
46 
47 class DummyAction : public Action
48 {
49  std::string getName(){return "DummyAction";};
50  void performAction(){std::cout << "Dummy action performed\n";};
51 };
52 
53 
54 
55 }
56 
57 
58 
59 #endif
std::shared_ptr< T > getModel()
Definition: action.h:36
virtual void performAction()=0
std::shared_ptr< DomainModel > domainModel
Definition: action.h:43
Builds the action space.
Definition: action.h:18
virtual ~Action()
Definition: action.h:30
virtual std::string getName()=0