tobicore  7.0.0
 All Classes Functions Variables Typedefs Enumerator Friends Groups Pages
ICMessage.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 "ICMessage.hpp"
20 #include "ICSerializerRapid.hpp"
21 #include <tobicore/TCException.hpp>
22 #include <string.h>
23 
24 #ifdef __BORLANDC__
25 using namespace std;
26 #endif
27 
29 }
30 
32  std::string buffer;
33  ICSerializerRapid serializer(other);
34  ICSerializerRapid deserializer(this);
35  serializer.Serialize(&buffer);
36  deserializer.Deserialize(&buffer);
37 }
38 
40  //this->_classifiers.clear();
41 }
42 
43 ICClassifier* ICMessage::GetClassifier(const std::string& name) const {
44  return this->classifiers.Get(name);
45 }
46 
47 ICClass* ICMessage::GetClass(const std::string& name, const ICLabel label) const {
48  return this->classifiers.Get(name)->classes.Get(label);
49 }
50 
51 ICValue ICMessage::GetValue(const std::string& name, const ICLabel label) const {
52  return this->classifiers.Get(name)->classes.Get(label)->GetValue();
53 }
54 
55 void ICMessage::SetValue(const std::string& name, const ICLabel label, const ICValue value) {
56  this->classifiers.Get(name)->classes.Get(label)->SetValue(value);
57 }
58 
59 void ICMessage::Dump(void) const {
60  if(this->classifiers.Empty())
61  throw TCException("Ethernal sunshine of an empty message",
62  #ifdef _WIN32
63  __FUNCSIG__
64  #else
65  __PRETTY_FUNCTION__
66  #endif
67  );
68 
69  printf("[ICMessage::Dump] TOBI iC message for frame %d\n", GetBlockIdx());
70  ICClassifier* cptr = NULL;
71  ICClass* kptr = NULL;
72  ICClassifierConstIter cit = this->classifiers.Begin();
74 
75  while(cit != this->classifiers.End()) {
76  cptr = (*cit).second;
77  printf(" + Classifier %s [\"%s\", ValueType=%d, LabelType=%d]\n",
78  cptr->GetName().c_str(), cptr->GetDescription().c_str(),
79  cptr->GetValueType(), cptr->GetLabelType());
80  kit = cptr->classes.Begin();
81  while(kit != cptr->classes.End()) {
82  kptr = (*kit).second;
83  printf(" `--> Class Value=%.6f Label=%s\n",
84  kptr->GetValue(), kptr->GetLabel().c_str());
85  ++kit;
86  }
87  ++cit;
88  }
89 }