← Documentation
ADS-IDAC Engine 5.0.0
BranchProcedureAtionTime.cpp
Go to the documentation of this file.
1// BranchProcedureAtionTime.cpp: implementation of the BranchProcedureAtionTime class.
2//
4
6#include "../Scheduler/Scheduler.h"
7#include <boost/serialization/export.hpp>
8#include "../Global/SimulationContext.h"
9#include <boost/archive/binary_oarchive.hpp>
10#include <boost/archive/binary_iarchive.hpp>
11BOOST_CLASS_EXPORT_IMPLEMENT(BranchProcedureAtionTime)
12using namespace std;
13
14
16// Construction/Destruction
18
20{
21
22}
23
25{
27}
29 this->action_time_branches.clear();
30}
31
33 string file_name, str;
34 int num_obj, i;
36 file_name = g_sim.SScheduler.getEOPDirectory();
37 file_name += "ProcedureActionTimeBranches.txt";
38 ifstream fin(file_name.c_str(), ios::in);
39 if(fin.is_open()){
40 fin >> str >> num_obj;
41 for (i = 0 ; i < num_obj; i++){
42 auto p = make_unique<BranchProcedureActionTimeUnit>();
43 p->readInfoFromFile(fin);
44 this->action_time_branches.push_back(std::move(p));
45 }
46 fin.close();
47 }
48 else{
49 //err message
50 }
51}
53 fout << "BranchProcedureAtionTime" << ' '
54 << this->action_time_branches.size() << '\n';
55 for(auto &p : this->action_time_branches){
56 p->saveBranchProcedureActionTimeUnitToFile(fout);
57 }
58}
60 string str;
61 int num_obj, i;
62 fin >> str >> num_obj;
63 for(i = 0; i < num_obj; i++){
64 auto p = make_unique<BranchProcedureActionTimeUnit>();
65 p->retrieveBranchProcedureActionTimeUnitFromFile(fin);
66 this->action_time_branches.push_back(std::move(p));
67 }
68}
70 for(auto &src : _bt.action_time_branches){
71 auto p = make_unique<BranchProcedureActionTimeUnit>();
72 p->copyBranchProcedureActionTimeUnit(*src);
73 this->action_time_branches.push_back(std::move(p));
74 }
75}
76
77BranchProcedureActionTimeUnit *BranchProcedureAtionTime::checkToGenerateActionTimeBranches(string _procedure_name, string _step_name, string _action_name){
79 bool found_tu = false;
80 auto tu_itr = this->action_time_branches.begin();
81 auto tu_itr_end = this->action_time_branches.end();
82 while (tu_itr != tu_itr_end && !found_tu){
83 found_tu = (*tu_itr)->checkIfBranchesNeedToBeGenerated(_procedure_name, _step_name, _action_name);
84 if(found_tu){
85 tu_pt = tu_itr->get();
86 }
87 else{
88 tu_itr++;
89 }
90 }
91 return tu_pt;
92}
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void retrieveBranchProcedureAtionTimeFromFile(std::ifstream &)
BranchProcedureActionTimeUnit * checkToGenerateActionTimeBranches(std::string, std::string, std::string)
std::vector< std::unique_ptr< BranchProcedureActionTimeUnit > > action_time_branches
void saveBranchProcedureAtionTimeToFile(std::ofstream &)
void copyBranchProcedureAtionTime(BranchProcedureAtionTime &)
std::string getEOPDirectory()
Definition: Scheduler.cpp:616
Scheduler SScheduler
Simulation scheduling, parses CLI options.