VariantListParameter.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * 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 * @package ArmarX::Core
19 * @author Kai Welke (welke _at_ kit _dot_ edu)
20 * @date 2012 Kai Welke
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
27 
28 namespace armarx
29 {
30  void VariantListParameter::setVariantList(const SingleTypeVariantListBasePtr& variantList, const Ice::Current& c)
31  {
32  if (!this->variantList)
33  {
34  this->variantList = new SingleTypeVariantList(variantList->getContainerType());
35  }
36 
37  this->variantList = SingleTypeVariantListBasePtr::dynamicCast(variantList->cloneContainer());
38 
39  }
40 
42  {
43  return variantList->getContainerType();
44  }
45 
47  IceUtil::Shared(source),
48  Ice::Object(source),
49  ParameterBase(source),
51  VariantListParameterBase(source)
52  {
53  throw LocalException("NYI");
54  type = source.type;
55  variantList = new SingleTypeVariantList(source.variantList->getContainerType());
56 
57  for (int i = 0 ; i < source.variantList->getSize() ; i++)
58  {
59  VariantPtr variant = new Variant();
60  *variant = *(VariantPtr::dynamicCast(source.variantList->getElementBase(i)));
61 
62  // this->variantList->addElement(variant);
63  }
64  }
65 
67  {
68  if (type != source.getParameterType())
69  {
70  throw InvalidTypeException();
71  }
72 
73  type = source.getParameterType();
74  *this->variantList = *source.getVariantList();
75  return *this;
76  }
77 
79  {
80  variantList = new SingleTypeVariantList(source.getContainerType());
81  type = eVariantListParam;
82  *variantList = source;
83  }
84 
85  ParameterBasePtr VariantListParameter::clone(const Ice::Current& c) const
86  {
87  return new VariantListParameter(*this);
88  }
89 
90 
91  SingleTypeVariantListBasePtr VariantListParameter::getVariantList(const Ice::Current& c) const
92  {
93  return variantList;
94  }
95 
96  bool VariantListParameter::validate(const Ice::Current& c) const
97  {
98  for (int i = 0 ; i < variantList->getSize() ; i++)
99  {
100  if (!variantList->getElementBase(i)->validateElements())
101  {
102  return false;
103  }
104  }
105 
106  return true;
107  }
108 }
armarx::VariantListParameter::getVariantList
SingleTypeVariantListBasePtr getVariantList(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: VariantListParameter.cpp:91
armarx::VariantListParameter
Definition: VariantListParameter.h:43
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
armarx::VariantListParameter::VariantListParameter
VariantListParameter()
Creates an empty Parameter.
Definition: VariantListParameter.h:51
armarx::VariantListParameter::operator=
Parameter & operator=(const Parameter &source) override
Definition: VariantListParameter.cpp:66
armarx::Parameter
Definition: Parameter.h:44
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
IceUtil
Definition: Instance.h:21
armarx::VariantListParameter::validate
bool validate(const Ice::Current &c) const override
Definition: VariantListParameter.cpp:96
IceInternal::Handle< Variant >
armarx::VariantListParameter::clone
ParameterBasePtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: VariantListParameter.cpp:85
armarx::SingleTypeVariantList
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
Definition: SingleTypeVariantList.h:47
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:44
VariantListParameter.h
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
Ice
Definition: DBTypes.cpp:64
Variant.h
armarx::VariantType::SingleTypeVariantList
const VariantTypeId SingleTypeVariantList
Definition: SingleTypeVariantList.h:193
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::VariantListParameter::getVariantType
VariantTypeId getVariantType(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: VariantListParameter.cpp:41
armarx::VariantListParameter::setVariantList
void setVariantList(const SingleTypeVariantListBasePtr &variantList, const Ice::Current &c=Ice::emptyCurrent) override
Definition: VariantListParameter.cpp:30