DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
dtnode.h
Go to the documentation of this file.
1 #ifndef DTNODE_H
2 #define DTNODE_H
3 
4 #include <commons_global.h>
5 #include <dtree/variables.h>
6 
7 #include <memory>
8 #include <boost/weak_ptr.hpp>
9 #include <vector>
10 
11 namespace dtree {
12 
13 class DecisionTree;
14 class NodeExtra;
15 
20 {
21 public:
22  explicit Node(std::shared_ptr<DecisionTree> node);
23 
24  int getChildrenCount() const;
25 
29  std::shared_ptr<Node> getChild(int idx);
30 
32  std::shared_ptr<Node> getUnmappedChild(int idx);
33  void setChild(int idx, std::shared_ptr<Node> child);
34 
35  void setMapping (int idx, int remapped);
36  int getMapping(int idx) const;
37 
38  void setExtra(std::shared_ptr<NodeExtra> extra);
39  std::shared_ptr<NodeExtra> extra() const;
40 
41  Variable variable() const { return mVariable; }
42  void setVariable(Variable var);
43 
44  void setParent(std::weak_ptr<Node> node) { mParent = node; }
45  std::weak_ptr<Node> parent() const { return mParent; }
46 
47  double value() const { return mValue; }
48  void setValue(double v) { mValue = v; }
49 
50 private:
51  std::weak_ptr<DecisionTree> mTree;
52  std::weak_ptr<Node> mParent;
53  std::vector<std::shared_ptr<Node> > mNodes;
54  std::vector<int> mGroups;
55  std::shared_ptr<NodeExtra> mExtra;
56 
57  Variable mVariable;
58  double mValue;
59 };
60 
61 }
62 
63 #endif // NODE_H
std::weak_ptr< Node > parent() const
Definition: dtnode.h:45
void setParent(std::weak_ptr< Node > node)
Definition: dtnode.h:44
a decision tree node.
Definition: dtnode.h:19
void setValue(double v)
Definition: dtnode.h:48
Variable
Definition: variables.h:10
Definition: commonstateevaluators.h:8
double value() const
Definition: dtnode.h:47
Variable variable() const
Definition: dtnode.h:41
#define COMMONSSHARED_EXPORT
Definition: commons_global.h:23