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