1 | #include "nomDeLogiciel.h" |
---|
2 | |
---|
3 | |
---|
4 | nomDeLogiciel::Logiciel nomDeLogiciel::fromString( std::string s) |
---|
5 | { |
---|
6 | if (s == "parmela" ) return parmela; |
---|
7 | else if ( s == "transport" ) return transport; |
---|
8 | return unknownSoftware; |
---|
9 | } |
---|
10 | |
---|
11 | std::string nomDeLogiciel::toString( nomDeLogiciel::Logiciel lg) |
---|
12 | { |
---|
13 | switch (lg) |
---|
14 | { |
---|
15 | case parmela : { return "parmela"; } |
---|
16 | case transport : { return "transport"; } |
---|
17 | case unknownSoftware : { return "unknownSoftware"; } |
---|
18 | } |
---|
19 | return "unknownSoftware"; |
---|
20 | } |
---|
21 | |
---|
22 | nomDeLogiciel::Logiciel nomDeLogiciel::fromValue( int v) |
---|
23 | { |
---|
24 | switch (v) |
---|
25 | { |
---|
26 | case 0 : { return parmela; } |
---|
27 | case 1 : { return transport; } |
---|
28 | } |
---|
29 | return unknownSoftware; |
---|
30 | } |
---|
31 | |
---|
32 | int nomDeLogiciel::toValue( nomDeLogiciel::Logiciel lg) |
---|
33 | { |
---|
34 | switch (lg) |
---|
35 | { |
---|
36 | case parmela : { return 0; } |
---|
37 | case transport : { return 1; } |
---|
38 | case unknownSoftware : { return 2; } |
---|
39 | } |
---|
40 | return -1; |
---|
41 | } |
---|
42 | |
---|
43 | nomDeLogiciel::nomDeLogiciel() |
---|
44 | { |
---|
45 | program_ = transport; |
---|
46 | progString_ = toString(program_); |
---|
47 | value_ = toValue(program_); |
---|
48 | } |
---|
49 | |
---|
50 | nomDeLogiciel::nomDeLogiciel(const string& s) |
---|
51 | { |
---|
52 | program_ = fromString(s); |
---|
53 | progString_ = toString(program_); |
---|
54 | value_ = toValue(program_); |
---|
55 | } |
---|
56 | |
---|
57 | nomDeLogiciel::nomDeLogiciel(int val) |
---|
58 | { |
---|
59 | program_ = fromValue(val); |
---|
60 | progString_ = toString(program_); |
---|
61 | value_ = toValue(program_); |
---|
62 | } |
---|
63 | |
---|
64 | int nomDeLogiciel::getNumberOfSoftwares() |
---|
65 | { |
---|
66 | return toValue(unknownSoftware); |
---|
67 | } |
---|
68 | |
---|
69 | // operators |
---|
70 | |
---|
71 | nomDeLogiciel& nomDeLogiciel::operator= (const nomDeLogiciel& nl) |
---|
72 | { |
---|
73 | program_ = nl.program_; |
---|
74 | progString_ = nl.progString_; |
---|
75 | value_ = nl.value_; |
---|
76 | return *this; |
---|
77 | } |
---|
78 | |
---|
79 | bool nomDeLogiciel::operator== (const nomDeLogiciel& nl) |
---|
80 | { |
---|
81 | return ( program_ == nl.program_); |
---|
82 | } |
---|
83 | |
---|
84 | bool nomDeLogiciel::operator!= (const nomDeLogiciel& nl) |
---|
85 | { |
---|
86 | return ( program_ != nl.program_); |
---|
87 | } |
---|