1 | |
---|
2 | #include <iostream> |
---|
3 | #include "elementSnapshot.h" |
---|
4 | #include "mixedTools.h" |
---|
5 | |
---|
6 | elementSnapshot::elementSnapshot(int num) : |
---|
7 | abstractElement(), |
---|
8 | incr_(num) |
---|
9 | { |
---|
10 | setDefaultValues(); |
---|
11 | setDefaults(); |
---|
12 | elementName_ = nomdElements("snapshot"); |
---|
13 | nbParam_ = elementName_.getElementNbParameters(); |
---|
14 | parametersString_ = new string[nbParam_+1]; |
---|
15 | registerAcceptableSoftware(nomDeLogiciel::transport, TBoolIgnore); |
---|
16 | registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolIgnore); |
---|
17 | registerAcceptableSoftware(nomDeLogiciel::generator, TBoolIgnore); |
---|
18 | registerAcceptableSoftware(nomDeLogiciel::test, TBoolIgnore); |
---|
19 | } |
---|
20 | |
---|
21 | void elementSnapshot::setDefaultValues() |
---|
22 | { |
---|
23 | defaultLabel_ = "snapshot"; |
---|
24 | } |
---|
25 | |
---|
26 | void elementSnapshot::setDefaults() |
---|
27 | { |
---|
28 | label_ = defaultLabel_; |
---|
29 | |
---|
30 | if(incr_ < 10) { |
---|
31 | snapshotFile_= string("cliche")+string(".00")+mixedTools::intToString(incr_); |
---|
32 | } else if(incr_ >= 10 && incr_ < 100) { |
---|
33 | snapshotFile_= string("cliche")+string(".0")+mixedTools::intToString(incr_); |
---|
34 | } else { |
---|
35 | snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr_); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | string* elementSnapshot::getParametersString() const |
---|
40 | { |
---|
41 | int compteur = -1; |
---|
42 | parametersString_[++compteur] = mixedTools::intToString(nbParam_); |
---|
43 | parametersString_[++compteur] = label_; |
---|
44 | parametersString_[++compteur] = snapshotFile_; |
---|
45 | |
---|
46 | if ( compteur != nbParam_ ) { |
---|
47 | cerr << "ERROR::elementSnapshot::getParametersString() : " << nbParam_ << endl; |
---|
48 | return NULL; |
---|
49 | } |
---|
50 | return parametersString_; |
---|
51 | } |
---|
52 | |
---|
53 | void elementSnapshot::setParametersString(string* param) |
---|
54 | { |
---|
55 | if ( param == NULL ) |
---|
56 | { |
---|
57 | cerr << " elementSnaphot::setParametersString parameters empty parameter set"; |
---|
58 | return; |
---|
59 | } |
---|
60 | |
---|
61 | int compteur = -1; |
---|
62 | int nbparam = atoi(param[++compteur].c_str()); |
---|
63 | if ( nbparam != nbParam_ ) { |
---|
64 | cerr << " elementSnaphot:: setParametersString parameters do not match for a DRIFT"; |
---|
65 | return; |
---|
66 | } |
---|
67 | |
---|
68 | label_ = param[++compteur]; |
---|
69 | } |
---|
70 | |
---|
71 | string elementSnapshot::parmelaOutputFlow() const |
---|
72 | { |
---|
73 | // ostringstream sortie; |
---|
74 | // return sortie.str(); |
---|
75 | return string(""); |
---|
76 | } |
---|
77 | |
---|
78 | string elementSnapshot::transportOutputFlow() const |
---|
79 | { |
---|
80 | return string(""); |
---|
81 | } |
---|
82 | |
---|
83 | string elementSnapshot::FileOutputFlow() const |
---|
84 | { |
---|
85 | ostringstream sortie; |
---|
86 | sortie << elementName_.getElementLabel() << endl; |
---|
87 | sortie << label_ << endl; |
---|
88 | sortie << snapshotFile_ << endl; |
---|
89 | return sortie.str(); |
---|
90 | } |
---|
91 | |
---|
92 | void elementSnapshot::FileInput(ifstream& ifs) |
---|
93 | { |
---|
94 | ifs >> label_; |
---|
95 | ifs >> snapshotFile_; |
---|
96 | } |
---|
97 | |
---|
98 | string elementSnapshot::print() |
---|
99 | { |
---|
100 | string txt = ""; |
---|
101 | txt += label_; |
---|
102 | txt += "\nname of file for snapshot : "; |
---|
103 | txt += snapshotFile_; |
---|
104 | return txt; |
---|
105 | } |
---|