1 | #ifndef NOMDELOGICIEL_SEEN |
---|
2 | #define NOMDELOGICIEL_SEEN |
---|
3 | |
---|
4 | #include <string> |
---|
5 | |
---|
6 | |
---|
7 | class nomDeLogiciel |
---|
8 | { |
---|
9 | |
---|
10 | public: |
---|
11 | |
---|
12 | |
---|
13 | enum Logiciel |
---|
14 | { |
---|
15 | parmela, transport, unknownSoftware |
---|
16 | }; |
---|
17 | |
---|
18 | |
---|
19 | private: |
---|
20 | |
---|
21 | Logiciel program_; |
---|
22 | std::string progString_; |
---|
23 | int value_; |
---|
24 | |
---|
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 | } |
---|
63 | |
---|
64 | public : |
---|
65 | // constructors |
---|
66 | |
---|
67 | nomDeLogiciel() : program_(transport) |
---|
68 | { |
---|
69 | progString_ = toString(program_); |
---|
70 | value_ = toValue(program_); |
---|
71 | } |
---|
72 | |
---|
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);} |
---|
89 | |
---|
90 | inline std::string getString() const {return progString_;} |
---|
91 | |
---|
92 | // operators |
---|
93 | |
---|
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 | } |
---|
111 | |
---|
112 | }; |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | #endif |
---|