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
28namespace armarx
29{
30 void
31 VariantListParameter::setVariantList(const SingleTypeVariantListBasePtr& variantList,
32 const Ice::Current& c)
33 {
34 if (!this->variantList)
35 {
36 this->variantList = new SingleTypeVariantList(variantList->getContainerType());
37 }
38
39 this->variantList =
40 SingleTypeVariantListBasePtr::dynamicCast(variantList->cloneContainer());
41 }
42
44 VariantListParameter::getVariantType(const Ice::Current& c) const
45 {
46 return variantList->getContainerType();
47 }
48
50 IceUtil::Shared(source),
51 Ice::Object(source),
52 ParameterBase(source),
53 Parameter(source),
54 VariantListParameterBase(source)
55 {
56 throw LocalException("NYI");
57 type = source.type;
58 variantList = new SingleTypeVariantList(source.variantList->getContainerType());
59
60 for (int i = 0; i < source.variantList->getSize(); i++)
61 {
62 VariantPtr variant = new Variant();
63 *variant = *(VariantPtr::dynamicCast(source.variantList->getElementBase(i)));
64
65 // this->variantList->addElement(variant);
66 }
67 }
68
71 {
72 if (type != source.getParameterType())
73 {
74 throw InvalidTypeException();
75 }
76
77 type = source.getParameterType();
78 *this->variantList = *source.getVariantList();
79 return *this;
80 }
81
83 {
84 variantList = new SingleTypeVariantList(source.getContainerType());
85 type = eVariantListParam;
86 *variantList = source;
87 }
88
89 ParameterBasePtr
90 VariantListParameter::clone(const Ice::Current& c) const
91 {
92 return new VariantListParameter(*this);
93 }
94
95 SingleTypeVariantListBasePtr
96 VariantListParameter::getVariantList(const Ice::Current& c) const
97 {
98 return variantList;
99 }
100
101 bool
102 VariantListParameter::validate(const Ice::Current& c) const
103 {
104 for (int i = 0; i < variantList->getSize(); i++)
105 {
106 if (!variantList->getElementBase(i)->validateElements())
107 {
108 return false;
109 }
110 }
111
112 return true;
113 }
114} // namespace armarx
constexpr T c
Parameter()
Creates an empty Parameter.
Definition Parameter.h:51
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
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
void setVariantList(const SingleTypeVariantListBasePtr &variantList, const Ice::Current &c=Ice::emptyCurrent) override
VariantListParameter()
Creates an empty Parameter.
SingleTypeVariantListBasePtr getVariantList(const Ice::Current &c=Ice::emptyCurrent) const 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.
IceInternal::Handle< Variant > VariantPtr
Definition Variant.h:41
Ice::Int VariantTypeId
Definition Variant.h:43