Double.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5 * Karlsruhe Institute of Technology (KIT), all rights reserved.
6 *
7 * ArmarX is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ArmarX is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24// Header
25#include "Double.h"
26
28
29// ArmarX
30#include "Float.h"
31
32namespace armarx::aron::data
33{
34 /* constructors */
35 Double::Double(const data::dto::AronDoublePtr& o, const Path& path) :
36 detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::PrimitiveVariant(
37 o,
39 path)
40 {
41 }
42
44 detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::PrimitiveVariant(
46 path)
47 {
48 }
49
50 Double::Double(const double d, const Path& path) :
51 detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::PrimitiveVariant(
52 d,
54 path)
55 {
56 }
57
58 /* operators */
59 bool
60 Double::operator==(const Double& other) const
61 {
62 const auto& otherAron = other.toAronDoubleDTO();
63 if (this->aron->value != otherAron->value)
64 {
65 return false;
66 }
67 return true;
68 }
69
70 bool
71 Double::operator==(const DoublePtr& other) const
72 {
73 if (!other)
74 {
75 return false;
76 }
77 return *this == *other;
78 }
79
80 /* static methods */
82 Double::FromAronDoubleDTO(const data::dto::AronDoublePtr& aron)
83 {
84 if (!aron)
85 {
86 return nullptr;
87 }
88 return std::make_shared<Double>(aron);
89 }
90
91 data::dto::AronDoublePtr
93 {
94 return navigator ? navigator->toAronDoubleDTO() : nullptr;
95 }
96
97 /* public member functions */
98 data::dto::AronDoublePtr
100 {
101 return aron;
102 }
103
104 /* virtual implementations */
105 void
106 Double::fromString(const std::string& setter)
107 {
108 setValue(std::stod(setter));
109 }
110
111 std::string
113 {
114 return "Double";
115 }
116
117 std::string
119 {
120 return "armarx::aron::data::Double";
121 }
122
123 bool
125 {
126 if (!type)
127 return true;
128 return type->getDescriptor() == type::Descriptor::DOUBLE;
129 }
130
133 {
135 throw error::NotImplementedYetException(__PRETTY_FUNCTION__);
136 //return std::make_shared<type::Double>(getPath());
137 }
138} // namespace armarx::aron::data
The Path class.
Definition Path.h:36
Double(const Path &=Path())
Definition Double.cpp:43
std::string getShortName() const override
get a short str representation of this variant
Definition Double.cpp:112
bool operator==(const Double &) const override
Definition Double.cpp:60
type::VariantPtr recalculateType() const override
recalculate the type of a data variant. Please not tha the mapping ist NOT bijective,...
Definition Double.cpp:132
std::string getFullName() const override
get the full str representation of this variant
Definition Double.cpp:118
static DoublePtr FromAronDoubleDTO(const data::dto::AronDoublePtr &aron)
Definition Double.cpp:82
void fromString(const std::string &setter) override
set a primitive from a std string
Definition Double.cpp:106
bool fullfillsType(const type::VariantPtr &) const override
checks, if the current data variant fullfills the given type
Definition Double.cpp:124
data::dto::AronDoublePtr toAronDoubleDTO() const
Definition Double.cpp:99
static data::dto::AronDoublePtr ToAronDoubleDTO(const DoublePtr &navigator)
Definition Double.cpp:92
PrimitiveVariant(const double &v, const data::Descriptor descriptor, const Path &path=Path())
The NotImplementedYetException class.
Definition Exception.h:61
A convenience header to include all aron files (full include, not forward declared)
std::shared_ptr< Double > DoublePtr
A convenience header to include all aron files (full include, not forward declared)
std::shared_ptr< Variant > VariantPtr
#define ARMARX_TRACE
Definition trace.h:77