diff --git a/source/RobotAPI/components/ArViz/Client/Client.h b/source/RobotAPI/components/ArViz/Client/Client.h index f2d406fece5753b91d89cc56f26c824711efde62..84dcad9ce36dc40c34553afb085aa3cdd1925460 100644 --- a/source/RobotAPI/components/ArViz/Client/Client.h +++ b/source/RobotAPI/components/ArViz/Client/Client.h @@ -80,8 +80,8 @@ namespace viz InteractionFeedbackRange interactions() const { - InteractionFeedback* begin = (InteractionFeedback*) data_.interactions.data(); - InteractionFeedback* end = begin + data_.interactions.size(); + const InteractionFeedback* begin = reinterpret_cast<const InteractionFeedback*>(data_.interactions.data()); + const InteractionFeedback* end = begin + data_.interactions.size(); return InteractionFeedbackRange{begin, end}; } diff --git a/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h b/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h index a77f79632d3f29955f46773d0aea5c5602dfd0f9..78591128d2daddab633ef3fd04139a4c46ba2340 100644 --- a/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h +++ b/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h @@ -71,8 +71,8 @@ namespace armarx::viz PointCloud& points(std::vector<ColoredPoint> const& ps) { std::size_t memorySize = ps.size() * sizeof(ps[0]); - Ice::Byte* begin = (Ice::Byte*)ps.data(); - Ice::Byte* end = begin + memorySize; + const Ice::Byte* const begin = reinterpret_cast<const Ice::Byte*>(ps.data()); + const Ice::Byte* const end = begin + memorySize; data_->points.assign(begin, end); return *this; } @@ -92,8 +92,8 @@ namespace armarx::viz PointCloud& addPointUnchecked(ColoredPoint const& p) { - Ice::Byte* begin = (Ice::Byte*)&p; - Ice::Byte* end = begin + sizeof(p); + const Ice::Byte* const begin = reinterpret_cast<const Ice::Byte*>(&p); + const Ice::Byte* const end = begin + sizeof(p); data_->points.insert(data_->points.end(), begin, end); return *this; } @@ -391,5 +391,3 @@ namespace armarx::viz }; } - - diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp index 59e1b9eb46c1f680e16b73a63a51511cf7140f4a..076d5aa61a6d0c79e4e3a56453675308e09f7bde 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp @@ -737,15 +737,22 @@ namespace armarx::aron::codegenerator::cpp const std::string& otherInstanceAccessor) const { const auto& type = getType(); - if (type.getMaybe() == type::Maybe::OPTIONAL || type.getMaybe() == type::Maybe::RAW_PTR || - type.getMaybe() == type::Maybe::SHARED_PTR || - type.getMaybe() == type::Maybe::UNIQUE_PTR) + if (type.getMaybe() == type::Maybe::RAW_PTR || type.getMaybe() == type::Maybe::SHARED_PTR || type.getMaybe() == type::Maybe::UNIQUE_PTR) + { + CppBlockPtr b = std::make_shared<CppBlock>(); + b->addLine("if (not (static_cast<bool>(" + accessor + ") == static_cast<bool>(" + otherInstanceAccessor + "))) // check if both contain data"); + b->addLineAsBlock("return false;"); + b->addLine("if (static_cast<bool>(" + accessor + ") && static_cast<bool>(" + otherInstanceAccessor + "))"); + b->addBlock(block_if_data); + return b; + } + + if (type.getMaybe() == type::Maybe::OPTIONAL) { CppBlockPtr b = std::make_shared<CppBlock>(); - b->addLine("if (not ((bool) " + accessor + " == (bool) " + otherInstanceAccessor + - ")) // check if both contain data"); + b->addLine("if (not ( " + accessor + ".has_value() == " + otherInstanceAccessor + ".has_value())) // check if both contain data"); b->addLineAsBlock("return false;"); - b->addLine("if ((bool) " + accessor + " && (bool) " + otherInstanceAccessor + ")"); + b->addLine("if ( " + accessor + ".has_value() && " + otherInstanceAccessor + ".has_value())"); b->addBlock(block_if_data); return b; } diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp index 3ea5e25112213e292c2557dcdf02b67075a12383..be7974fb2ba04d07814a468eec39f982d55aa7c5 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp @@ -102,13 +102,13 @@ namespace armarx::aron::codegenerator::cpp::generator CppBlockPtr b = std::make_shared<CppBlock>(); std::string escaped_accessor = EscapeAccessor(cppAccessor); variantAccessor = ARON_VARIANT_RETURN_ACCESSOR + "_" + escaped_accessor; - b->addLine( - "auto " + variantAccessor + " = " + ARON_WRITER_ACCESSOR + ".writeMatrix((int) " + - std::to_string(type.getRows()) + ", " + "(int) " + std::to_string(type.getCols()) + - ", " + std::get<2>(ElementType2Cpp.at(type.getElementType())) + ", " + "\"" + - type.getDefaultValue() + "\", " + conversion::Maybe2CppString.at(type.getMaybe()) + - ", " + "armarx::aron::Path(" + ARON_PATH_ACCESSOR + ", {" + - simox::alg::join(p.getPath(), ", ") + "})); // of " + cppAccessor); + b->addLine("auto " + variantAccessor + " = " + ARON_WRITER_ACCESSOR + + ".writeMatrix(static_cast<int>( " + std::to_string(type.getRows()) + "), " + "static_cast<int>( " + + std::to_string(type.getCols()) + "), " + + std::get<2>(ElementType2Cpp.at(type.getElementType())) + ", " + "\"" + + type.getDefaultValue() + "\", " + conversion::Maybe2CppString.at(type.getMaybe()) + + ", " + "armarx::aron::Path(" + ARON_PATH_ACCESSOR + ", {" + + simox::alg::join(p.getPath(), ", ") + "})); // of " + cppAccessor); return b; } @@ -123,8 +123,8 @@ namespace armarx::aron::codegenerator::cpp::generator variantAccessor = ARON_VARIANT_RETURN_ACCESSOR + "_" + escaped_accessor; block_if_data->addLine( - variantAccessor + " = " + ARON_WRITER_ACCESSOR + ".writeNDArray({(int) " + cppAccessor + - nextEl() + "rows(), " + "(int) " + cppAccessor + nextEl() + "cols(), " + + variantAccessor + " = " + ARON_WRITER_ACCESSOR + ".writeNDArray({static_cast<int>( " + cppAccessor + + nextEl() + "rows() ), " + "static_cast<int>( " + cppAccessor + nextEl() + "cols()), " + std::to_string(std::get<1>(ElementType2Cpp.at(type.getElementType()))) + "}, " + "\"" + std::get<0>(ElementType2Cpp.at(type.getElementType())) + "\", " + "reinterpret_cast<const unsigned char*>(" + cppAccessor + nextEl() + "data()), " + diff --git a/source/RobotAPI/libraries/aron/core/data/variant/complex/NDArray.h b/source/RobotAPI/libraries/aron/core/data/variant/complex/NDArray.h index 6d4203071c29b0d1d20123f85a4263d4c74db58b..1cfc673719f6a4808a9f7e91bfc9b25a46cffb72 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/complex/NDArray.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/complex/NDArray.h @@ -57,6 +57,8 @@ namespace armarx::aron::data const Path& path = Path()); // operators + using detail::ComplexVariant<data::dto::NDArray, NDArray>::operator==; + virtual bool operator==(const NDArray&) const override; bool operator==(const NDArrayPtr&) const override; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.h b/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.h index b31f12957d1b6ca4dac0b303f0b3259be89733f0..f6c2d93955f53af91a04364ada5f3da724ae7033 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.h @@ -50,6 +50,8 @@ namespace armarx::aron::data Dict(const std::map<std::string, VariantPtr>&, const Path& path = Path()); // operators + using detail::ContainerVariant<data::dto::Dict, Dict>::operator==; + bool operator==(const Dict&) const override; bool operator==(const DictPtr&) const override; VariantPtr operator[](const std::string&) const; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/container/List.h b/source/RobotAPI/libraries/aron/core/data/variant/container/List.h index 4d7074ca6b4f6e43a1172837c07423d3eb0f281e..74d33da9af8fb260a9fe098221a1188a52d01cdd 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/container/List.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/container/List.h @@ -49,6 +49,8 @@ namespace armarx::aron::data List(const std::vector<VariantPtr>&, const Path& path = Path()); // operators + using detail::ContainerVariant<data::dto::List, List>::operator==; + bool operator==(const List&) const override; bool operator==(const ListPtr&) const override; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Bool.h b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Bool.h index 5e07b8a8e33577b268ea8ae8366291664b3012e6..94349fb2c608936b6e395a1af2090713e8372148 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Bool.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Bool.h @@ -48,6 +48,8 @@ namespace armarx::aron::data Bool(const bool, const Path& = Path()); // operators + using detail::PrimitiveVariant<data::dto::AronBool, bool, Bool>::operator==; + bool operator==(const Bool& other) const override; bool operator==(const BoolPtr&) const override; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Double.h b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Double.h index fb7a6880a9782397239243d38939d1ac22688fd4..59447e7def921da7face8213f24372bf5d5865df 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Double.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Double.h @@ -48,6 +48,8 @@ namespace armarx::aron::data Double(const double, const Path& = Path()); /* operators */ + using detail::PrimitiveVariant<data::dto::AronDouble, double, Double>::operator==; + bool operator==(const Double&) const override; bool operator==(const DoublePtr&) const override; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Float.h b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Float.h index 2d0cecb7e609df5496da3e616ffcd0fe6e249800..96f84a14c7978ab6675661c6d5fab261e0ad3b92 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Float.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Float.h @@ -48,6 +48,8 @@ namespace armarx::aron::data Float(const float, const Path& = Path()); /* operators */ + using detail::PrimitiveVariant<data::dto::AronFloat, float, Float>::operator==; + bool operator==(const Float&) const override; bool operator==(const FloatPtr&) const override; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Int.h b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Int.h index 5ee4a270f60bd2b21d8e2257c814f5dab8a0b759..738496f71bc51b4f0bdca92f57405a84a0dc2d22 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Int.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Int.h @@ -49,6 +49,8 @@ namespace armarx::aron::data Int(const int, const Path& = Path()); /* operators */ + using detail::PrimitiveVariant<data::dto::AronInt, int, Int>::operator==; + bool operator==(const Int&) const override; bool operator==(const IntPtr&) const override; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Long.h b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Long.h index 97e3496c6b984ededccbc19422ecad3b5c65f17b..c28b603aa93f3b23750a310e84e9bcc6a9e7d501 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/primitive/Long.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/primitive/Long.h @@ -48,6 +48,8 @@ namespace armarx::aron::data Long(const long, const Path& = Path()); /* operators */ + using detail::PrimitiveVariant<data::dto::AronLong, long, Long>::operator==; + bool operator==(const Long&) const override; bool operator==(const LongPtr&) const override; diff --git a/source/RobotAPI/libraries/aron/core/data/variant/primitive/String.h b/source/RobotAPI/libraries/aron/core/data/variant/primitive/String.h index 21c23698c114262b3d71658288cef82e12e4747f..def1c80315934c55073314483fcda063fbd50e76 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/primitive/String.h +++ b/source/RobotAPI/libraries/aron/core/data/variant/primitive/String.h @@ -48,6 +48,7 @@ namespace armarx::aron::data String(const std::string&, const Path& = Path()); /* operators */ + using detail::PrimitiveVariant<data::dto::AronString, std::string, String>::operator==; bool operator==(const String&) const override; bool operator==(const StringPtr&) const override;