tobicore  7.0.0
 All Classes Functions Variables Typedefs Enumerator Friends Groups Pages
ICSetClassifier.cpp
1 /*
2  Copyright (C) 2009-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
3  Michele Tavella <michele.tavella@epfl.ch>
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "ICSetClassifier.hpp"
20 #include <tobicore/TCException.hpp>
21 
22 #ifdef __BORLANDC__
23 using namespace std;
24 #endif
25 
27 }
28 
30  this->_map.clear();
31 }
32 
34  ICClassifierIter it = this->_map.find(pclr->GetName());
35  if(it != this->_map.end())
36  throw TCException("ICClassifier already present",
37  #ifdef _WIN32
38  __FUNCSIG__
39  #else
40  __PRETTY_FUNCTION__
41  #endif
42  );
43 
44  this->_map[pclr->GetName()] = pclr;
45  return pclr;
46 }
47 
49  ICClassifierIter it = this->_map.find(nclr);
50  if(it == this->_map.end())
51  throw TCException("nclr not found",
52  #ifdef _WIN32
53  __FUNCSIG__
54  #else
55  __PRETTY_FUNCTION__
56  #endif
57  );
58 
59  ICClassifier* retval = (*it).second;
60  this->_map.erase(it);
61  return retval;
62 }
63 
65  if(pclr == NULL)
66  throw TCException("pclr is NULL",
67  #ifdef _WIN32
68  __FUNCSIG__
69  #else
70  __PRETTY_FUNCTION__
71  #endif
72  );
73 
74  return this->Remove(pclr->GetName());
75 }
76 
77 ICClassifier* ICSetClassifier::Get(std::string nclr) const {
78  ICClassifierConstIter it = this->_map.find(nclr);
79  if(it == this->_map.end())
80  throw TCException("nclr not found",
81  #ifdef _WIN32
82  __FUNCSIG__
83  #else
84  __PRETTY_FUNCTION__
85  #endif
86  );
87 
88  ICClassifier* retval = (*it).second;
89  return retval;
90 }
91 
93  return this->Get(pclr->GetName());
94 }
95 
96 bool ICSetClassifier::Has(std::string nclr) const {
97  ICClassifierConstIter it = this->_map.find(nclr);
98  return(it != this->_map.end());
99 }
100 
102  ICClassifierConstIter it = this->_map.find(pclr->GetName());
103  return(it != this->_map.end());
104 }
105 
106 bool ICSetClassifier::Empty(void) const {
107  return this->_map.empty();
108 }
109 
110 unsigned int ICSetClassifier::Size(void) const {
111  return this->_map.size();
112 }
113 
115  this->_map.clear();
116 }
117 
119  ICClassifierIter cit = this->Begin();
120  while(cit != this->End()) {
121  ICClassifier* cptr = (*cit).second;
122  if(cptr != NULL)
123  delete cptr;
124  }
125  this->Clear();
126 }
127 
129  ICClassifierIter it = this->_map.begin();
130  return it;
131 }
132 
134  ICClassifierIter it = this->_map.end();
135  return it;
136 }
137 
139  ICClassifierConstIter it = this->_map.begin();
140  return it;
141 }
142 
144  ICClassifierConstIter it = this->_map.end();
145  return it;
146 }