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 
32 namespace 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,
38  data::Descriptor::DOUBLE,
39  path)
40  {
41  }
42 
43  Double::Double(const Path& path) :
44  detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::PrimitiveVariant(
45  data::Descriptor::DOUBLE,
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,
53  data::Descriptor::DOUBLE,
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 */
81  DoublePtr
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  {
134  ARMARX_TRACE;
135  throw error::NotImplementedYetException(__PRETTY_FUNCTION__);
136  //return std::make_shared<type::Double>(getPath());
137  }
138 } // namespace armarx::aron::data
armarx::aron::type::Descriptor::DOUBLE
@ DOUBLE
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
trace.h
detail
Definition: OpenCVUtil.cpp:128
armarx::aron::data::Descriptor
Descriptor
Definition: Descriptor.h:179
armarx::aron::data::Double::operator==
bool operator==(const Double &) const override
Definition: Double.cpp:60
armarx::aron::data::Double
Definition: Double.h:41
armarx::aron::data::DoublePtr
std::shared_ptr< Double > DoublePtr
Definition: forward_declarations.h:32
armarx::aron::data::Double::recalculateType
type::VariantPtr recalculateType() const override
recalculate the type of a data variant. Please not tha the mapping ist NOT bijective,...
Definition: Double.cpp:132
armarx::aron::data::Double::FromAronDoubleDTO
static DoublePtr FromAronDoubleDTO(const data::dto::AronDoublePtr &aron)
Definition: Double.cpp:82
armarx::aron::error::NotImplementedYetException
The NotImplementedYetException class.
Definition: Exception.h:60
armarx::aron::data::Double::toAronDoubleDTO
data::dto::AronDoublePtr toAronDoubleDTO() const
Definition: Double.cpp:99
armarx::aron::data::Double::getFullName
std::string getFullName() const override
get the full str representation of this variant
Definition: Double.cpp:118
armarx::aron::Path
The Path class.
Definition: Path.h:35
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
Double.h
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::aron::data::Double::fullfillsType
bool fullfillsType(const type::VariantPtr &) const override
checks, if the current data variant fullfills the given type
Definition: Double.cpp:124
armarx::aron::data::Double::ToAronDoubleDTO
static data::dto::AronDoublePtr ToAronDoubleDTO(const DoublePtr &navigator)
Definition: Double.cpp:92
Float.h
armarx::aron::data::Double::getShortName
std::string getShortName() const override
get a short str representation of this variant
Definition: Double.cpp:112
armarx::aron::data
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:3
armarx::aron::data::Double::Double
Double(const Path &=Path())
Definition: Double.cpp:43
armarx::aron::data::Double::fromString
void fromString(const std::string &setter) override
set a primitive from a std string
Definition: Double.cpp:106
armarx::aron::data::detail::SpecializedVariantBase< data::dto::AronDouble, Double >::aron
AronDataType::PointerType aron
Definition: SpecializedVariant.h:153
armarx::aron::data::detail::PrimitiveVariant< data::dto::AronDouble, double, Double >::setValue
void setValue(const double &x)
Definition: PrimitiveVariant.h:126