MultiAgentDecisionProcess  Release 0.2.1
ObservationHistoryTree.cpp
Go to the documentation of this file.
1 
29 #define DEBUG_OHT 0
30 
31 /*
32 //Default constructor
33 ObservationHistoryTree::ObservationHistoryTree()
34 {
35  _m_index = 0;
36  _m_indexValid = false;
37  _m_obsHist = 0;
38 }
39 ObservationHistoryTree::ObservationHistoryTree(ObservationHistory *const oh)
40 {
41  _m_index = 0;
42  _m_indexValid = false;
43  _m_obsHist = oh;
44 }
45 //Copy assignment constructor.
46 ObservationHistoryTree::ObservationHistoryTree(const ObservationHistoryTree& o)
47 {
48 if(DEBUG_OHT){ cout << "Cloning ObservationHistoryTree. This node ";
49  PrintThisNode();cout << endl;}
50 }
51 
52 //Destructor -- deletes this node, the contained ObservationHistory and all
53 //successors
54 ObservationHistoryTree::~ObservationHistoryTree()
55 {
56 if(DEBUG_OHT){ cout << "Deleting ObservationHistoryTree. This node ";
57  PrintThisNode();cout << endl;}
58 
59  delete(_m_obsHist);
60  vector<ObservationHistoryTree*>::iterator it = _m_successor.begin();
61  vector<ObservationHistoryTree*>::iterator last = _m_successor.end();
62 
63  while(it != last)
64  {
65  delete(*it);
66  it++;
67  }
68  _m_successor.clear();
69 }
70 void ObservationHistoryTree::SetSuccessor(Index observationI,
71  ObservationHistoryTree* suc)
72 {
73  size_t cursize = _m_successor.size();
74  if(observationI == cursize)
75  _m_successor.push_back(suc);
76  else if(observationI < 0 || observationI > _m_successor.size() )
77  cout << "ObservationHistoryTree::SetSuccessor ERROR index out of"
78  << " bounds! (perhaps setting _m_successor["
79  << observationI<< "] before _m_successor["
80  << observationI-1 << "] ?? )";
81  else
82  {
83  cout << "_m_successor["<< observationI<< "] already set: overwriting!";
84  _m_successor[observationI] = suc;
85  }
86 }
87 ObservationHistoryTree* ObservationHistoryTree::GetSuccessor(Index observationI) const
88 {
89  if(observationI < 0 || observationI >= _m_successor.size() )
90  throw E("ObservationHistoryTree::GetSuccessor index out of bounds!");
91  else
92  return(_m_successor[observationI]);
93 }
94 void ObservationHistoryTree::PrintThisNode() const
95 {
96  if(_m_obsHist != 0)
97  {
98  cout << "index: "<<_m_index<<" - ";
99  _m_obsHist->Print();
100  }
101 }
102 void ObservationHistoryTree::Print() const
103 {
104  if(_m_obsHist != 0)
105  {
106  cout << "index: "<<_m_index<<" - ";
107  _m_obsHist->Print();
108  cout <<endl;
109  vector<ObservationHistoryTree*>::const_iterator it = _m_successor.begin();
110  vector<ObservationHistoryTree*>::const_iterator last = _m_successor.end();
111  while(it != last)
112  {
113  if(*it != 0) (*it)->Print();
114  it++;
115  }
116  }
117 }
118 */