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