Changeset 160 in PSPA for Interface_Web/trunk/pspaWT/include


Ignore:
Timestamp:
Dec 9, 2012, 1:50:14 PM (12 years ago)
Author:
lemeur
Message:

normalisation nomdElements et nomDeLogiciel

Location:
Interface_Web/trunk/pspaWT/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/include/nomDeLogiciel.h

    r107 r160  
    44#include <string>
    55
     6using namespace std;
    67
    78class nomDeLogiciel
     
    2324  int value_;
    2425
    25   static Logiciel fromString( std::string s)
    26   {
    27     if (s == "parmela" ) return parmela;
    28     else if ( s == "transport" ) return transport;
    29     return unknownSoftware;
    30   }
    31 
    32   static std::string toString( Logiciel lg)
    33   {
    34     switch (lg)
    35       {
    36       case parmela : { return "parmela"; }
    37       case transport : { return "transport"; }
    38       case unknownSoftware : { return "unknownSoftware"; }
    39       }
    40     return "unknownSoftware";
    41   }
    42  
    43   static Logiciel fromValue( int v)
    44   {
    45     switch (v)
    46       {
    47       case 0 : { return parmela; }
    48       case 1 : { return transport; }
    49       }
    50     return unknownSoftware;
    51   }
    52  
    53   static int toValue( Logiciel lg)
    54   {
    55     switch (lg)
    56       {
    57       case parmela : { return 0; }
    58       case transport : { return 1; }
    59       case unknownSoftware :  { return 2; }
    60       }
    61     return -1;
    62   }
     26  static Logiciel fromString( std::string s);
     27  static std::string toString( Logiciel lg); 
     28  static Logiciel fromValue( int v); 
     29  static int toValue( Logiciel lg);
    6330 
    6431 public :
    6532  // constructors
    6633 
    67  nomDeLogiciel() : program_(transport)
    68   {
    69     progString_ = toString(program_);
    70     value_ = toValue(program_);
    71   }
     34  nomDeLogiciel(); 
     35  nomDeLogiciel(const string& s); 
     36  nomDeLogiciel(int val);
    7237 
    73  
    74   nomDeLogiciel(const string& s)
    75     {
    76       program_ = fromString(s);
    77       progString_ = toString(program_);
    78       value_ = toValue(program_);
    79     }
    80  
    81   nomDeLogiciel(int val)
    82     { 
    83       program_ = fromValue(val);
    84       progString_ = toString(program_);
    85       value_ = toValue(program_);
    86     }
    87  
    88   static int getNumberOfSoftwares() { return toValue(unknownSoftware);}
     38  static int getNumberOfSoftwares();
    8939 
    9040  inline std::string getString() const {return progString_;}
     
    9242  // operators
    9343 
    94   nomDeLogiciel& operator= (const nomDeLogiciel& nl)
    95     {
    96       program_ = nl.program_;
    97       progString_ = nl.progString_;
    98       value_ = nl.value_;
    99       return *this;
    100     }
    101  
    102   bool operator== (const nomDeLogiciel& nl)
    103   {
    104     return ( program_ == nl.program_);
    105   }
    106  
    107   bool operator!= (const nomDeLogiciel& nl)
    108   {
    109     return ( program_ != nl.program_);
    110   }
     44  nomDeLogiciel& operator= (const nomDeLogiciel& nl); 
     45  bool operator== (const nomDeLogiciel& nl); 
     46  bool operator!= (const nomDeLogiciel& nl);
    11147 
    11248};
  • Interface_Web/trunk/pspaWT/include/nomdElements.h

    r153 r160  
    66enum typedElement {RFgun, drift, cell, bend, soleno, inconnu};
    77
     8
     9
    810class nomdElements
    911{
    10   typedElement e_;
    11   std::string eStr_;
    12   std::string eImg_;
     12  typedElement e_;  // type entier (enum)
     13  std::string eName_;  // nom de l'element
     14  std::string eImg_;  // nom du fichier de l'icone
     15  std::string eLabel_; // label affiche sous l'icone
    1316
    14   typedElement fromString(std::string s);
    15   std::string toString(typedElement eType);
    16   std::string toImage(typedElement eType);
     17
     18  static   typedElement fromImage(std::string s);
     19  static   std::string toName(typedElement eType);
     20  static   std::string toImage(typedElement eType);
     21  static   std::string toLabel(typedElement eType);
    1722
    1823 public :
     
    2631
    2732  static int getNumberOfElements();
     33  static string getImageFromType( typedElement tp);
     34  static std::string getLabelFromType(typedElement tp);
     35
    2836  typedElement getElementType() const;
    2937  std::string getElementName() const;
Note: See TracChangeset for help on using the changeset viewer.