source: PSPA/Interface_Web/trunk/pspaWT/sources/controler/src/elementSnapshot.cc @ 418

Last change on this file since 418 was 418, checked in by lemeur, 11 years ago

definition des compatibilites des elements dans les software

File size: 3.2 KB
Line 
1
2#include <iostream>
3#include "elementSnapshot.h"
4#include "mixedTools.h"
5
6elementSnapshot::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::useraction,
19  //                                           TBoolOk);
20  // registerAcceptableSoftware(nomDeLogiciel::test, TBoolIgnore);
21}
22
23void elementSnapshot::setDefaultValues()
24{
25  defaultSpecificName_ = "snapshot";
26}
27
28void elementSnapshot::setDefaults()
29{
30  specificName_ = defaultSpecificName_;
31
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_);
36  } else {
37    snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr_);
38  }
39}
40
41string* elementSnapshot::getParametersString() const 
42{
43  int compteur = -1;
44  parametersString_[++compteur] = mixedTools::intToString(nbParam_);
45  parametersString_[++compteur] = specificName_;
46  parametersString_[++compteur] = snapshotFile_;
47 
48  if ( compteur != nbParam_ ) {
49    cerr << "ERROR::elementSnapshot::getParametersString() : " << nbParam_ << endl;
50    return NULL;
51  }
52  return parametersString_;
53}
54
55void 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());
65  if ( nbparam != nbParam_ )  {
66    cerr << " elementSnaphot:: setParametersString parameters do not match for a DRIFT";
67    return;
68  }
69 
70  specificName_ = param[++compteur];
71}
72
73// string elementSnapshot::parmelaOutputFlow() const
74// {
75//     // ostringstream sortie;
76//     // return sortie.str();
77//   return string("");
78// }
79
80// string elementSnapshot::transportOutputFlow() const
81// {
82//   return string("");
83// }
84
85string elementSnapshot::FileOutputFlow() const
86{
87  ostringstream sortie;
88  sortie << elementName_.getGenericLabel() << endl;
89  sortie  << specificName_ << endl;
90  sortie << snapshotFile_ << endl;
91  return sortie.str();
92}
93
94vector< 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
104void elementSnapshot::FileInput(ifstream& ifs)
105{
106  ifs >> specificName_;
107  ifs >> snapshotFile_;
108}
109
110string elementSnapshot::print() 
111{
112  string txt = ""; 
113  txt += specificName_;
114  txt += "\nname of file for snapshot : ";
115  txt += snapshotFile_;
116  return txt;
117}
Note: See TracBrowser for help on using the repository browser.