←
Documentation
ADS-IDAC Engine
5.0.0
BranchSubGoal.cpp
Go to the documentation of this file.
1
// BranchSubGoal.cpp: implementation of the BranchSubGoal class.
2
//
4
5
#include <sstream>
6
#include "
BranchSubGoal.h
"
7
#include "../Global/ConvertToString.h"
8
#include <boost/serialization/export.hpp>
9
#include "../Global/SimulationContext.h"
10
#include <boost/archive/binary_oarchive.hpp>
11
#include <boost/archive/binary_iarchive.hpp>
12
BOOST_CLASS_EXPORT_IMPLEMENT(
BranchSubGoal
)
13
using namespace
std;
14
15
17
// Construction/Destruction
19
20
BranchSubGoal::BranchSubGoal
() {
21
22
}
23
24
BranchSubGoal::~BranchSubGoal
() {
25
26
}
27
void
BranchSubGoal::copyBranchSubGoal
(
BranchSubGoal
&_bgp) {
28
DecisionSubGoal::copyDecisionSubGoal
((
DecisionSubGoal
&) _bgp);
29
TimerAndProbability::copyTimerAndProbability
((
TimerAndProbability
&) _bgp);
30
Communication::copyCommunication
((
Communication
&) _bgp);
31
};
32
string
BranchSubGoal::translateMessage
() {
33
string
str;
34
str =
"SUBGOAL: Sender: "
;
35
str +=
g_sim
.
Translator
.
getString
(this->
getSender
());
36
str +=
"; Receiver: "
;
37
str +=
g_sim
.
Translator
.
getString
(this->
getIntendedReceiver
());
38
str +=
"; Subgoal: "
;
39
str +=
g_sim
.
Translator
.
getString
(this->
getDecision
());
40
str +=
"; New Probability: "
;
41
std::ostringstream streamObj;
42
streamObj << this->
getProbability
();
43
str += streamObj.str();
44
return
str;
45
}
46
void
BranchSubGoal::saveInfoToFile
(ostream &fout) {
47
fout <<
' '
<< this->
getSender
() <<
' '
<<
sim::Decision::Goal
<<
' '
<< this->
getDecision
() <<
" NONE "
<< this->
getProbability
()
48
<<
' '
49
<< this->
getTimeOfCommunication
() <<
' '
<< this->
getRemainingTime
() <<
" 0.0 0 "
<<
'"'
<<
"NONE"
<<
'"'
50
<<
'\n'
;
51
}
52
void
BranchSubGoal::saveBranchSubGoalToFile
(ofstream &fout) {
53
this->
saveDecisionSubGoalToFile
(fout);
54
this->
saveTimerAndProbabilityToFile
(fout);
55
this->
saveCommunicationToFile
(fout);
56
}
57
void
BranchSubGoal::retrieveBranchSubGoalFromFile
(ifstream &fin) {
58
this->
retrieveDecisionSubGoalFromFile
(fin);
59
this->
retrieveTimerAndProbabilityFromFile
(fin);
60
this->
retrieveCommunicationFromFile
(fin);
61
}
BranchSubGoal.h
g_sim
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
Definition:
SimulationContext.cpp:7
BranchSubGoal
Definition:
BranchSubGoal.h:22
BranchSubGoal::~BranchSubGoal
virtual ~BranchSubGoal()
Definition:
BranchSubGoal.cpp:24
BranchSubGoal::BranchSubGoal
BranchSubGoal()
Definition:
BranchSubGoal.cpp:20
BranchSubGoal::retrieveBranchSubGoalFromFile
void retrieveBranchSubGoalFromFile(std::ifstream &)
Definition:
BranchSubGoal.cpp:57
BranchSubGoal::saveInfoToFile
void saveInfoToFile(std::ostream &)
Definition:
BranchSubGoal.cpp:46
BranchSubGoal::translateMessage
std::string translateMessage()
Definition:
BranchSubGoal.cpp:32
BranchSubGoal::copyBranchSubGoal
void copyBranchSubGoal(BranchSubGoal &)
Definition:
BranchSubGoal.cpp:27
BranchSubGoal::saveBranchSubGoalToFile
void saveBranchSubGoalToFile(std::ofstream &)
Definition:
BranchSubGoal.cpp:52
Communication
Definition:
Communication.h:20
Communication::getSender
int getSender()
Definition:
Communication.cpp:43
Communication::getTimeOfCommunication
double getTimeOfCommunication()
Definition:
Communication.cpp:47
Communication::saveCommunicationToFile
void saveCommunicationToFile(std::ofstream &)
Definition:
Communication.cpp:60
Communication::getIntendedReceiver
int getIntendedReceiver()
Definition:
Communication.cpp:44
Communication::retrieveCommunicationFromFile
void retrieveCommunicationFromFile(std::ifstream &)
Definition:
Communication.cpp:65
Communication::copyCommunication
void copyCommunication(Communication &)
Definition:
Communication.cpp:52
ConvertToString::getString
std::string getString(int) const
Definition:
ConvertToString.cpp:190
DecisionSubGoal
Definition:
DecisionSubGoal.h:17
DecisionSubGoal::saveDecisionSubGoalToFile
void saveDecisionSubGoalToFile(std::ofstream &)
Definition:
DecisionSubGoal.cpp:29
DecisionSubGoal::retrieveDecisionSubGoalFromFile
void retrieveDecisionSubGoalFromFile(std::ifstream &)
Definition:
DecisionSubGoal.cpp:33
DecisionSubGoal::copyDecisionSubGoal
void copyDecisionSubGoal(DecisionSubGoal &)
Definition:
DecisionSubGoal.cpp:25
Decision::getDecision
int getDecision()
Definition:
Decision.cpp:27
Probability::getProbability
double getProbability()
Definition:
Probability.cpp:27
TimerAndProbability
Definition:
TimerAndProbability.h:21
TimerAndProbability::saveTimerAndProbabilityToFile
void saveTimerAndProbabilityToFile(std::ofstream &)
Definition:
TimerAndProbability.cpp:34
TimerAndProbability::copyTimerAndProbability
void copyTimerAndProbability(TimerAndProbability &)
Definition:
TimerAndProbability.cpp:30
TimerAndProbability::retrieveTimerAndProbabilityFromFile
void retrieveTimerAndProbabilityFromFile(std::ifstream &)
Definition:
TimerAndProbability.cpp:38
Timer::getRemainingTime
double getRemainingTime()
Definition:
Timer.cpp:31
sim::Decision::Goal
constexpr int Goal
Definition:
SimConstants.h:190
SimulationContext::Translator
ConvertToString Translator
Parameter name/value conversion.
Definition:
SimulationContext.h:52
src
ADSIDAC
Branch
BranchSubGoal.cpp
Generated by
1.9.4