Float.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 #include "Float.h"
25 
26 namespace armarx::aron::data
27 {
28  /* constructors */
29  Float::Float(const data::dto::AronFloatPtr& o, const Path& path) :
30  detail::PrimitiveVariant<data::dto::AronFloat, float, Float>::PrimitiveVariant(
31  o,
32  data::Descriptor::FLOAT,
33  path)
34  {
35  }
36 
37  Float::Float(const Path& path) :
38  detail::PrimitiveVariant<data::dto::AronFloat, float, Float>::PrimitiveVariant(
39  data::Descriptor::FLOAT,
40  path)
41  {
42  }
43 
44  Float::Float(const float d, const Path& path) :
45  detail::PrimitiveVariant<data::dto::AronFloat, float, Float>::PrimitiveVariant(
46  d,
47  data::Descriptor::FLOAT,
48  path)
49  {
50  }
51 
52  /* operators */
53  bool
54  Float::operator==(const Float& other) const
55  {
56  const auto& otherAron = other.toAronFloatDTO();
57  if (this->aron->value != otherAron->value)
58  {
59  return false;
60  }
61  return true;
62  }
63 
64  bool
65  Float::operator==(const FloatPtr& other) const
66  {
67  if (!other)
68  {
69  return false;
70  }
71  return *this == *other;
72  }
73 
74  /* static methods */
75  FloatPtr
76  Float::FromAronFloatDTO(const data::dto::AronFloatPtr& aron)
77  {
78  if (!aron)
79  {
80  return nullptr;
81  }
82  return std::make_shared<Float>(aron);
83  }
84 
85  data::dto::AronFloatPtr
86  Float::ToAronFloatDTO(const FloatPtr& navigator)
87  {
88  return navigator ? navigator->toAronFloatDTO() : nullptr;
89  }
90 
91  /* public member functions */
92  data::dto::AronFloatPtr
94  {
95  return aron;
96  }
97 
98  /* virtual implementations */
99  void
100  Float::fromString(const std::string& setter)
101  {
102  setValue(std::stof(setter));
103  }
104 
105  std::string
107  {
108  return "Float";
109  }
110 
111  std::string
113  {
114  return "armarx::aron::data::Float";
115  }
116 
117  bool
119  {
120  if (!type)
121  return true;
122  return type->getDescriptor() == type::Descriptor::FLOAT;
123  }
124 
127  {
128  ARMARX_TRACE;
129  throw error::NotImplementedYetException(__PRETTY_FUNCTION__);
130  //return std::make_shared<type::Float>(getPath());
131  }
132 } // namespace armarx::aron::data
armarx::aron::type::Descriptor::FLOAT
@ FLOAT
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::aron::data::Float::FromAronFloatDTO
static FloatPtr FromAronFloatDTO(const data::dto::AronFloatPtr &aron)
Definition: Float.cpp:76
armarx::aron::data::Float::getShortName
std::string getShortName() const override
get a short str representation of this variant
Definition: Float.cpp:106
detail
Definition: OpenCVUtil.cpp:127
armarx::aron::data::Descriptor
Descriptor
Definition: Descriptor.h:193
armarx::aron::data::Float::getFullName
std::string getFullName() const override
get the full str representation of this variant
Definition: Float.cpp:112
armarx::aron::error::NotImplementedYetException
The NotImplementedYetException class.
Definition: Exception.h:88
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::data::Float::ToAronFloatDTO
static data::dto::AronFloatPtr ToAronFloatDTO(const FloatPtr &navigator)
Definition: Float.cpp:86
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
Float.h
armarx::aron::data::Float::recalculateType
type::VariantPtr recalculateType() const override
recalculate the type of a data variant. Please not tha the mapping ist NOT bijective,...
Definition: Float.cpp:126
armarx::aron::data::Float::fullfillsType
bool fullfillsType(const type::VariantPtr &) const override
checks, if the current data variant fullfills the given type
Definition: Float.cpp:118
armarx::aron::data::Float::operator==
bool operator==(const Float &) const override
Definition: Float.cpp:54
armarx::aron::data
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:3
armarx::aron::data::Float::fromString
void fromString(const std::string &setter) override
set a primitive from a std string
Definition: Float.cpp:100
float
#define float
Definition: 16_Level.h:22
armarx::aron::data::Float::toAronFloatDTO
data::dto::AronFloatPtr toAronFloatDTO() const
Definition: Float.cpp:93
armarx::aron::data::FloatPtr
std::shared_ptr< Float > FloatPtr
Definition: forward_declarations.h:29
armarx::aron::data::Float::Float
Float(const Path &=Path())
Definition: Float.cpp:37
armarx::aron::data::detail::SpecializedVariantBase< data::dto::AronFloat, Float >::aron
AronDataType::PointerType aron
Definition: SpecializedVariant.h:154
armarx::aron::data::detail::PrimitiveVariant< data::dto::AronFloat, float, Float >::setValue
void setValue(const float &x)
Definition: PrimitiveVariant.h:126
armarx::aron::data::Float
Definition: Float.h:41