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 
karto::AbstractParameter::GetValueAsString
virtual const karto::String GetValueAsString() const =0
TypeCasts.h
karto_const_forEach
#define karto_const_forEach(listtype, list)
Definition: Macros.h:136
Module.h
karto::AbstractParameter::SetValueFromString
virtual void SetValueFromString(const karto::String &rStringValue)=0
karto::Object::GetParameter
AbstractParameter * GetParameter(const String &rParameterName) const
Definition: Object.h:93
karto::LOG_WARNING
@ LOG_WARNING
Definition: Logger.h:63
karto::Module::Module
Module(const Identifier &rName)
Definition: Module.cpp:27
karto::String
Definition: String.h:52
Logger.h
karto::Module::Process
virtual kt_bool Process(karto::Object *pObject)
Definition: Module.cpp:36
karto::List< SmartPointer< AbstractParameter > >
karto::List::Clear
virtual void Clear()
Definition: List.h:231
kt_bool
bool kt_bool
Definition: Types.h:145
karto::AbstractParameter::GetName
const karto::String & GetName() const
Definition: Parameter.h:251
karto::AbstractParameter
Definition: Parameter.h:220
karto::List::Add
virtual void Add(const T &rValue)
Definition: List.h:111
karto::Module::m_Sensors
SensorList m_Sensors
Definition: Module.h:67
karto::Log
void Log(LogLevel level, const karto::String &rMessage)
Definition: Logger.cpp:183
karto::Identifier
Definition: Identifier.h:40
karto::Object
Definition: Object.h:54
karto::Sensor
Definition: Sensor.h:46
karto::Object::GetIdentifier
const Identifier & GetIdentifier() const
Definition: Object.h:83
karto::Module::Reset
virtual void Reset()
Definition: Module.cpp:74
karto
Definition: Any.cpp:20


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Wed Mar 2 2022 00:37:22