← Documentation
ADS-IDAC Engine 5.0.0
BranchMentalProcedureActivationTime.cpp
Go to the documentation of this file.
1// BranchMentalProcedureActivationTime.cpp: implementation of the BranchMentalProcedureActivationTime class.
2//
4
6#include "../Global/SimulationContext.h"
7#include <boost/serialization/export.hpp>
8#include <boost/archive/binary_oarchive.hpp>
9#include <boost/archive/binary_iarchive.hpp>
10BOOST_CLASS_EXPORT_IMPLEMENT(BranchMentalProcedureActivationTime)
11using namespace std;
12
14// Construction/Destruction
16
18{
19
20}
21
23{
25}
26
28{
30 bool found_atu = false;
31 auto bmp_atu_itr = this->activation_time_branches.begin();
32 while (bmp_atu_itr != this->activation_time_branches.end() && !found_atu)
33 {
34 found_atu = (*bmp_atu_itr)->checkIfActivationBranchNeedsToBeGenerated(_mental_belief_name, _mental_procedure_name);
35 if(found_atu){
36 bmpatu_pt = bmp_atu_itr->get();
37 }
38 else{
39 bmp_atu_itr++;
40 }
41 }
42 return bmpatu_pt;
43}
44
46{
47 this->activation_time_branches.clear();
48}
49
51{
52 for (auto &src : _bmp_at.activation_time_branches)
53 {
54 auto p = make_unique<BranchMentalProcedureActivationTimeUnit>();
55 p->copyBranchMentalProcedureActivationTimeUnit(*src);
56 this->activation_time_branches.push_back(std::move(p));
57 }
58}
59
61{
62 string file_name, str;
63 int num_obj, i;
64 file_name = g_sim.SScheduler.getEOPDirectory();
65 file_name += "MentalProcedureActivationTimeBranches.txt";
66 ifstream fin(file_name.c_str(), ios::in);
67 if(fin.is_open()){
68 fin >> str >> num_obj;
69 for (i = 0 ; i < num_obj; i++){
70 auto p = make_unique<BranchMentalProcedureActivationTimeUnit>();
71 p->readInfoFromFile(fin);
72 this->activation_time_branches.push_back(std::move(p));
73 }
74 fin.close();
75 }
76 else
77 {
78 cout << "File: " << file_name << " cound not be found" << endl;
79 ofstream fout("err messages.txt", ios::app);
80 fout << r5pars_.timesno << " File: " << file_name << " cound not be found\n";
81 fout.close();
82 }
83}
84
86{
87 string str;
88 int num_obj, i;
89 fin >> str >> num_obj;
90 for (i = 0; i != num_obj; i ++ )
91 {
92 auto p = make_unique<BranchMentalProcedureActivationTimeUnit>();
93 p->retrieveBranchMentalProcedureActivationTimeUnitFromFile(fin);
94 this->activation_time_branches.push_back(std::move(p));
95 }
96}
97
99{
100 fout << "BranchMentalProcedureActivationTime" << ' '
101 << this->activation_time_branches.size() << '\n';
102 for(auto &p : this->activation_time_branches)
103 {
104 p->saveBranchMentalProcedureActivationTimeUnitToFile(fout);
105 }
106}
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void copyBranchMentalProcedureActivationTime(BranchMentalProcedureActivationTime &)
BranchMentalProcedureActivationTimeUnit * checkToGenerateActivationTimeBranches(std::string, std::string)
std::vector< std::unique_ptr< BranchMentalProcedureActivationTimeUnit > > activation_time_branches
std::string getEOPDirectory()
Definition: Scheduler.cpp:616
struct @0 r5pars_
Scheduler SScheduler
Simulation scheduling, parses CLI options.