←
Documentation
ADS-IDAC Engine
5.0.0
BranchInfoGatherMode.cpp
Go to the documentation of this file.
1
// BranchInfoGatherMode.cpp: implementation of the BranchInfoGatherMode class.
2
//
4
5
#include <sstream>
6
#include "
BranchInfoGatherMode.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(
BranchInfoGatherMode
)
13
using namespace
std;
14
15
17
// Construction/Destruction
19
20
BranchInfoGatherMode::BranchInfoGatherMode
() {
21
info_gather_mode
=
sim::State::New
;
22
}
23
24
BranchInfoGatherMode::~BranchInfoGatherMode
() {
25
26
}
27
void
BranchInfoGatherMode::setInfoGatherMode
(
int
n) {
info_gather_mode
= n; }
28
int
BranchInfoGatherMode::getInfoGatherMode
() {
return
info_gather_mode
; }
29
void
BranchInfoGatherMode::saveInfoToFile
(ostream &fout) {
30
string
str;
31
if
(
info_gather_mode
==
sim::State::OldInfo
) {
32
str =
"use_memorized_info"
;
33
}
else
{
34
str =
"gather_new_info"
;
35
}
36
fout <<
' '
<< this->
getSender
() <<
' '
<<
sim::Action::SendInfo
<<
' '
<<
sim::None
<<
" info_gather_mode "
<< this->
getProbability
()
37
<<
' '
38
<< this->
getTimeOfCommunication
() <<
' '
<< this->
getRemainingTime
() <<
" 0.0 0 "
<<
'"'
<< str <<
'"'
<<
'\n'
;
39
}
40
void
BranchInfoGatherMode::copyBranchInfoGatherMode
(
BranchInfoGatherMode
&_bigm) {
41
this->
copyCommunication
(_bigm);
42
this->
copyTimerAndProbability
(_bigm);
43
info_gather_mode
= _bigm.
getInfoGatherMode
();
44
}
45
string
BranchInfoGatherMode::translateMessage
() {
46
string
str;
47
str =
"Info_gather_mode: Sender: "
;
48
str +=
g_sim
.
Translator
.
getString
(this->
getSender
());
49
str +=
"; Receiver: "
;
50
str +=
g_sim
.
Translator
.
getString
(this->
getIntendedReceiver
());
51
if
(
info_gather_mode
==
sim::State::OldInfo
) {
52
str +=
"; Mode: conditional_use_of_memorized_info_if_available"
;
53
}
else
{
54
str +=
"; Mode: always_check_for_up_to_date_info"
;
55
}
56
str +=
"; New Probability: "
;
57
std::ostringstream streamObj;
58
streamObj << this->
getProbability
();
59
str += streamObj.str();
60
return
str;
61
}
62
void
BranchInfoGatherMode::saveBranchInfoGatherModeToFile
(ofstream &fout) {
63
fout <<
info_gather_mode
<<
'\n'
;
64
this->
saveTimerAndProbabilityToFile
(fout);
65
this->
saveCommunicationToFile
(fout);
66
}
67
void
BranchInfoGatherMode::retrieveBranchInfoGatherModeFromFile
(ifstream &fin) {
68
fin >>
info_gather_mode
;
69
this->
retrieveTimerAndProbabilityFromFile
(fin);
70
this->
retrieveCommunicationFromFile
(fin);
71
}
BranchInfoGatherMode.h
g_sim
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
Definition:
SimulationContext.cpp:7
BranchInfoGatherMode
Definition:
BranchInfoGatherMode.h:22
BranchInfoGatherMode::translateMessage
std::string translateMessage()
Definition:
BranchInfoGatherMode.cpp:45
BranchInfoGatherMode::saveInfoToFile
void saveInfoToFile(std::ostream &)
Definition:
BranchInfoGatherMode.cpp:29
BranchInfoGatherMode::retrieveBranchInfoGatherModeFromFile
void retrieveBranchInfoGatherModeFromFile(std::ifstream &)
Definition:
BranchInfoGatherMode.cpp:67
BranchInfoGatherMode::saveBranchInfoGatherModeToFile
void saveBranchInfoGatherModeToFile(std::ofstream &)
Definition:
BranchInfoGatherMode.cpp:62
BranchInfoGatherMode::BranchInfoGatherMode
BranchInfoGatherMode()
Definition:
BranchInfoGatherMode.cpp:20
BranchInfoGatherMode::getInfoGatherMode
int getInfoGatherMode()
Definition:
BranchInfoGatherMode.cpp:28
BranchInfoGatherMode::info_gather_mode
int info_gather_mode
Definition:
BranchInfoGatherMode.h:43
BranchInfoGatherMode::~BranchInfoGatherMode
virtual ~BranchInfoGatherMode()
Definition:
BranchInfoGatherMode.cpp:24
BranchInfoGatherMode::copyBranchInfoGatherMode
void copyBranchInfoGatherMode(BranchInfoGatherMode &)
Definition:
BranchInfoGatherMode.cpp:40
BranchInfoGatherMode::setInfoGatherMode
void setInfoGatherMode(int)
Definition:
BranchInfoGatherMode.cpp:27
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
Probability::getProbability
double getProbability()
Definition:
Probability.cpp:27
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::Action::SendInfo
constexpr int SendInfo
Definition:
SimConstants.h:204
sim::State::OldInfo
constexpr int OldInfo
Definition:
SimConstants.h:126
sim::State::New
constexpr int New
Definition:
SimConstants.h:114
sim::None
constexpr int None
Definition:
SimConstants.h:75
SimulationContext::Translator
ConvertToString Translator
Parameter name/value conversion.
Definition:
SimulationContext.h:52
src
ADSIDAC
Branch
BranchInfoGatherMode.cpp
Generated by
1.9.4