DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
decisiontreemanager.h
Go to the documentation of this file.
1 #ifndef DECISIONTREEMANAGER_H
2 #define DECISIONTREEMANAGER_H
3 
4 #include <commons_global.h>
5 #include <dtree/variables.h>
6 
7 #include <string>
8 #include <vector>
9 #include <set>
10 
11 #include <memory>
12 
13 namespace displace {
14 namespace commons {
15 struct Scenario;
16 }
17 }
18 
19 namespace dtree {
20 class DecisionTree;
21 
26 {
27 private:
29 
32 public:
33 
38  enum TreeType {
39  InvalidTreeType = -1, // this is a special code, do not change this value
40 
41  GoFishing, ChooseGround,
42  StartFishing, ChangeGround, StopFishing,
44 
45  SIZE
46  };
47 
48  int readFromDirectory(std::string path);
49  int readFromScenario (std::string path, displace::commons::Scenario scenario);
50  std::shared_ptr<dtree::DecisionTree> tree (TreeType type);
51  bool hasTree(TreeType type);
52  bool hasTreeVariable (TreeType type, dtree::Variable variable) const;
53 
58  if (mInstance == 0)
59  mInstance = new DecisionTreeManager();
60  return mInstance;
61  }
62 
63  static std::string treeTypeCode(TreeType type);
64  static TreeType treeTypeFromCode (std::string code);
65 
66 protected:
67  bool readFile(std::string filename);
68  void readScenarioFileIfAvailable(std::string path, std::string scenarioname);
69 
70 private:
71  std::vector<std::shared_ptr<dtree::DecisionTree> > mTrees;
72  std::vector<std::set<dtree::Variable> > mVariableDictionary;
73 
74  static DecisionTreeManager *mInstance;
75 
76  static const char * const mCodes[];
77 };
78 
79 } // ns
80 
81 #endif // DECISIONTREEMANAGER_H
static DecisionTreeManager * manager()
returns the instance of the singleton. Uses lazy initialization to proper initialize the instance.
Definition: decisiontreemanager.h:57
Definition: decisiontreemanager.h:13
Definition: decisiontreemanager.h:41
Definition: decisiontreemanager.h:42
Definition: comstructs.h:32
Variable
Definition: variables.h:10
Definition: commonstateevaluators.h:8
TreeType
An enumerated type to identify which tree to refer. They are internally used as index to various cont...
Definition: decisiontreemanager.h:38
A class that implements a Singleton for managing the Decision Trees for vessels.
Definition: decisiontreemanager.h:25
Definition: decisiontreemanager.h:43
displace::commons::Scenario scenario
Definition: main.cpp:247
#define COMMONSSHARED_EXPORT
Definition: commons_global.h:23