Cat
Attrib.h
Go to the documentation of this file.
1 // $Id: $
2 //-----------------------------------------------------------------------------
3 //
4 // Package : Attrib
5 //
6 // Description: Define basic attributs of an objects
7 //
8 // Author(s) : F. Machefert -
9 // Date : January 20, 2007
10 //
11 //-----------------------------------------------------------------------------
12 #ifndef INC_ATTRIB_H
13 #define INC_ATTRIB_H 1
14 
15 // Include files
16 #include <string>
17 #include <vector>
18 
27 class Attrib {
28 public:
29  enum Attribut {
34  IO,
40  }; // array m_attribString must be changed into Attrib::Attrib if this enu is modified.
41 
43  Attrib( );
44 
45  virtual ~Attrib( );
46 
50  bool is ( int attribut )
51  {
52  std::vector<int>::const_iterator iter ;
53  for ( iter = m_attributs.begin() ;
54  iter != m_attributs.end() ;
55  ++iter ) {
56  if ( attribut == (*iter) ) {
57  return true;
58  }
59  }
60  return false;
61  }
62 
63 
67  void add ( int attribut ) {
68  if (attribut!=Attrib::UNDEFINED) remove(Attrib::UNDEFINED);
69  bool duplicate = false ;
70  std::vector<int>::const_iterator iter ;
71  for ( iter = m_attributs.begin() ;
72  iter != m_attributs.end() ;
73  ++iter ) {
74  if ( attribut == (*iter) ) {
75  duplicate = true ;
76  }
77  }
78  if (!duplicate) {
79  m_attributs.push_back( attribut );
80  }
81  }
82 
86  void remove ( int attribut ) {
87  std::vector<int>::iterator iter , toremove ;
88  for ( iter = m_attributs.begin() ;
89  iter != m_attributs.end() ;
90  ++iter ) {
91  if ( attribut == (*iter) ) {
92  toremove = iter;
93  }
94  }
95  m_attributs.erase (toremove);
96  if(0==m_attributs.size()) add(Attrib::UNDEFINED);
97  }
98 
102  std::string attributs();
103 
104 protected:
105  std::string m_attribString[10];
106 
107 private:
108  std::vector<int> m_attributs;
109 };
110 
111 #endif // INC_ATTRIB_H
std::string attributs()
Definition: Attrib.cpp:54
bool is(int attribut)
Definition: Attrib.h:50
void add(int attribut)
Definition: Attrib.h:67
Attribut
Definition: Attrib.h:29
Definition: Attrib.h:27
virtual ~Attrib()
Destructor.
Definition: Attrib.cpp:49
Attrib()
Standard constructor.
Definition: Attrib.cpp:31
std::string m_attribString[10]
Definition: Attrib.h:105
std::vector< int > m_attributs
Definition: Attrib.h:108