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 
27 // ArmarX
28 #include "Float.h"
29 
30 namespace armarx::aron::data
31 {
32  /* constructors */
33  Double::Double(const data::dto::AronDoublePtr& o, const Path& path) :
34  detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::PrimitiveVariant(
35  o,
36  data::Descriptor::DOUBLE,
37  path)
38  {
39  }
40 
41  Double::Double(const Path& path) :
42  detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::PrimitiveVariant(
43  data::Descriptor::DOUBLE,
44  path)
45  {
46  }
47 
48  Double::Double(const double d, const Path& path) :
49  detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::PrimitiveVariant(
50  d,
51  data::Descriptor::DOUBLE,
52  path)
53  {
54  }
55 
56  /* operators */
57  bool
58  Double::operator==(const Double& other) const
59  {
60  const auto& otherAron = other.toAronDoubleDTO();
61  if (this->aron->value != otherAron->value)
62  {
63  return false;
64  }
65  return true;
66  }
67 
68  bool
69  Double::operator==(const DoublePtr& other) const
70  {
71  if (!other)
72  {
73  return false;
74  }
75  return *this == *other;
76  }
77 
78  /* static methods */
79  DoublePtr
80  Double::FromAronDoubleDTO(const data::dto::AronDoublePtr& aron)
81  {
82  if (!aron)
83  {
84  return nullptr;
85  }
86  return std::make_shared<Double>(aron);
87  }
88 
89  data::dto::AronDoublePtr
91  {
92  return navigator ? navigator->toAronDoubleDTO() : nullptr;
93  }
94 
95  /* public member functions */
96  data::dto::AronDoublePtr
98  {
99  return aron;
100  }
101 
102  /* virtual implementations */
103  void
104  Double::fromString(const std::string& setter)
105  {
106  setValue(std::stod(setter));
107  }
108 
109  std::string
111  {
112  return "Double";
113  }
114 
115  std::string
117  {
118  return "armarx::aron::data::Double";
119  }
120 
121  bool
123  {
124  if (!type)
125  return true;
126  return type->getDescriptor() == type::Descriptor::DOUBLE;
127  }
128 
131  {
132  ARMARX_TRACE;
133  throw error::NotImplementedYetException(__PRETTY_FUNCTION__);
134  //return std::make_shared<type::Double>(getPath());
135  }
136 } // namespace armarx::aron::data
armarx::aron::type::Descriptor::DOUBLE
@ DOUBLE
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
detail
Definition: OpenCVUtil.cpp:127
armarx::aron::data::Descriptor
Descriptor
Definition: Descriptor.h:193
armarx::aron::data::Double::operator==
bool operator==(const Double &) const override
Definition: Double.cpp:58
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:130
armarx::aron::data::Double::FromAronDoubleDTO
static DoublePtr FromAronDoubleDTO(const data::dto::AronDoublePtr &aron)
Definition: Double.cpp:80
armarx::aron::error::NotImplementedYetException
The NotImplementedYetException class.
Definition: Exception.h:88
armarx::aron::data::Double::toAronDoubleDTO
data::dto::AronDoublePtr toAronDoubleDTO() const
Definition: Double.cpp:97
armarx::aron::data::Double::getFullName
std::string getFullName() const override
get the full str representation of this variant
Definition: Double.cpp:116
armarx::aron::Path
The Path class.
Definition: Path.h:36
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
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:122
armarx::aron::data::Double::ToAronDoubleDTO
static data::dto::AronDoublePtr ToAronDoubleDTO(const DoublePtr &navigator)
Definition: Double.cpp:90
Float.h
armarx::aron::data::Double::getShortName
std::string getShortName() const override
get a short str representation of this variant
Definition: Double.cpp:110
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:41
armarx::aron::data::Double::fromString
void fromString(const std::string &setter) override
set a primitive from a std string
Definition: Double.cpp:104
armarx::aron::data::detail::SpecializedVariantBase< data::dto::AronDouble, Double >::aron
AronDataType::PointerType aron
Definition: SpecializedVariant.h:154
armarx::aron::data::detail::PrimitiveVariant< data::dto::AronDouble, double, Double >::setValue
void setValue(const double &x)
Definition: PrimitiveVariant.h:126