MultiAgentDecisionProcess  Release 0.2.1
ActionHistory.cpp
Go to the documentation of this file.
1 
28 #include "ActionHistory.h"
29 #include "Action.h"
30 //Necessary as header file contains a forward declaration:
32 
33 using namespace std;
34 
35 #define DEBUG_AH 0
36 
37 //Default constructor
39  Index agentI) :
41  IndividualHistory(agentI)
42 {
43  SetLength(0);
44  _m_actionI = 0;
45  _m_isEmpty = true;
46  _m_pred = 0;
47 }
48 
50  Referrer<PlanningUnitMADPDiscrete>( pred->GetReferred() ),
51  IndividualHistory(pred->_m_agentI)
52 {
53  SetLength(pred->GetLength() + 1);
54  _m_actionI = aI;
55  _m_isEmpty = false;
56  _m_pred = pred;
57 }
58 
59 //Destructor
61 {
62 if(DEBUG_AH){ cout << "Deleting action history: ";
63  Print(); cout << endl;}
64 }
65 
67 {
68  stringstream ss;
69  if(_m_pred != 0)
70  {
71  //if the predec. is the empty action sequence (with length 0)
72  //we don't want to print this. (and this is the case when
73  //this action history has length 1)
74  if(_m_length >= 1)
75  ss << _m_pred->SoftPrint();
76  else if (_m_length < 1)
77  {
78  ss << "ActionHistory:Print() - Warning:_m_pred != "<<
79  "null, but lenght < 1 !"<<endl;
80  throw E(ss);
81  }
82  //else length == 1 and we simply skip
83  }
84 
85  if (!_m_isEmpty) // don't print the empty action
86  {
88  _m_actionI))->SoftPrintBrief();
89  ss << ", ";
90  }
91  else
92  ss << "EMPTY_AH";
93 
94  return(ss.str());
95 
96 }