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