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
27namespace 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),
40 Parameter(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
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
constexpr T c
Parameter()
Creates an empty Parameter.
Definition Parameter.h:51
VariantBasePtr getVariant(const Ice::Current &c=Ice::emptyCurrent) const override
Parameter & operator=(const Parameter &source) override
bool validate(const Ice::Current &c) const override
VariantTypeId getVariantType(const Ice::Current &c=Ice::emptyCurrent) const override
ParameterBasePtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
VariantParameter()
Creates an empty Parameter.
void setVariant(const VariantBasePtr &variant, const Ice::Current &c=Ice::emptyCurrent) override
The Variant class is described here: Variants.
Definition Variant.h:224
This file offers overloads of toIce() and fromIce() functions for STL container types.
Ice::Int VariantTypeId
Definition Variant.h:43
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr