VariantParameter.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 
26 
27 namespace armarx
28 {
30  {
31  type = eVariantParam;
32  this->variant = new Variant();
33  *this->variant = variant;
34  }
35 
37  IceUtil::Shared(source),
38  Ice::Object(source),
39  ParameterBase(source),
41  VariantParameterBase(source)
42  {
43  type = source.type;
44  this->variant = new Variant();
45  *VariantPtr::dynamicCast(this->variant) = *VariantPtr::dynamicCast(source.getVariant());
46  }
47 
49  {
50  if (type != source.getParameterType())
51  {
52  throw InvalidTypeException();
53  }
54 
55  type = source.getParameterType();
56 
57  if (!variant)
58  {
59  variant = new Variant();
60  }
61 
62  *VariantPtr::dynamicCast(this->variant) = *VariantPtr::dynamicCast(source.getVariant());
63  return *this;
64  }
65 
66  ParameterBasePtr VariantParameter::clone(const Ice::Current& c) const
67  {
68  return new VariantParameter(*this);
69  }
70 
71 
72  // setter
73  void VariantParameter::setVariant(const VariantBasePtr& variant, const Ice::Current& c)
74  {
75  *(this->variant) = *variant;
76  }
77 
79  {
80  return variant->getType();
81  }
82 
83  VariantBasePtr VariantParameter::getVariant(const Ice::Current& c) const
84  {
85  return variant;
86  }
87 
88  bool VariantParameter::validate(const Ice::Current& c) const
89  {
90  return getVariant()->validate();
91  }
92 }
armarx::VariantParameter::validate
bool validate(const Ice::Current &c) const override
Definition: VariantParameter.cpp:88
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
armarx::VariantParameter::setVariant
void setVariant(const VariantBasePtr &variant, const Ice::Current &c=Ice::emptyCurrent) override
Definition: VariantParameter.cpp:73
armarx::Parameter
Definition: Parameter.h:44
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::VariantParameter::operator=
Parameter & operator=(const Parameter &source) override
Definition: VariantParameter.cpp:48
IceUtil
Definition: Instance.h:21
IceInternal::Handle<::armarx::VariantBase >
armarx::VariantParameter::getVariantType
VariantTypeId getVariantType(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: VariantParameter.cpp:78
armarx::VariantParameter
Definition: VariantParameter.h:43
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:44
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
VariantParameter.h
Ice
Definition: DBTypes.cpp:64
armarx::VariantParameter::clone
ParameterBasePtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: VariantParameter.cpp:66
armarx::VariantParameter::getVariant
VariantBasePtr getVariant(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: VariantParameter.cpp:83
armarx::VariantParameter::VariantParameter
VariantParameter()
Creates an empty Parameter.
Definition: VariantParameter.h:51
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28