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