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