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