Module.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011, SRI International (R)
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <OpenKarto/Module.h>
19 #include <OpenKarto/TypeCasts.h>
20 #include <OpenKarto/Logger.h>
21 
22 #include <iostream>
23 
24 namespace karto
25 {
26 
27  Module::Module(const Identifier& rName)
28  : Object(rName)
29  {
30  }
31 
32  Module::~Module()
33  {
34  }
35 
37  {
38  kt_bool isObjectProcessed = false;
39 
40  if (IsSensor(pObject))
41  {
42  m_Sensors.Add(dynamic_cast<karto::Sensor*>(pObject));
43  isObjectProcessed = true;
44  }
45  else if (IsModuleParameters(pObject))
46  {
47  karto::ModuleParameters* pParameters = dynamic_cast<karto::ModuleParameters*>(pObject);
48 
49  if (pParameters != NULL && pParameters->GetIdentifier() == GetIdentifier())
50  {
51  // copy parameters
52  const karto::ParameterList& rParameters = pParameters->GetParameters();
54  {
55  karto::AbstractParameter* pParameterFrom = *iter;
56  karto::AbstractParameter* pParameterTo = GetParameter(pParameterFrom->GetName());
57  if (pParameterTo != NULL)
58  {
59  pParameterTo->SetValueFromString(pParameterFrom->GetValueAsString());
60  }
61  else
62  {
63  Log(LOG_WARNING, String("Invalid ") + GetIdentifier().ToString() + " parameter: " + pParameterFrom->GetName() + " parameter is ignored!");
64  }
65  }
66  }
67 
68  isObjectProcessed = true;
69  }
70 
71  return isObjectProcessed;
72  }
73 
75  {
76  m_Sensors.Clear();
77  }
78 
79 }
80 
bool kt_bool
Definition: Types.h:145
virtual void SetValueFromString(const karto::String &rStringValue)=0
virtual void Reset()
Definition: Module.cpp:74
const Identifier & GetIdentifier() const
Definition: Object.h:83
virtual const karto::String GetValueAsString() const =0
virtual void Add(const T &rValue)
Definition: List.h:111
void Log(LogLevel level, const karto::String &rMessage)
Definition: Logger.cpp:183
virtual kt_bool Process(karto::Object *pObject)
Definition: Module.cpp:36
const karto::String & GetName() const
Definition: Parameter.h:251
Definition: Any.cpp:20
virtual void Clear()
Definition: List.h:231
AbstractParameter * GetParameter(const String &rParameterName) const
Definition: Object.h:93
Module(const Identifier &rName)
Definition: Module.cpp:27
SensorList m_Sensors
Definition: Module.h:67
#define karto_const_forEach(listtype, list)
Definition: Macros.h:136


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Thu Jun 6 2019 19:20:24