diff --git a/source/RobotAPI/interface/aron/Aron.ice b/source/RobotAPI/interface/aron/Aron.ice index d40861c7613951de469ed29093b99e2e0e29e1f2..dc88e0484490476691ee98e3c3bf338964c02e6d 100644 --- a/source/RobotAPI/interface/aron/Aron.ice +++ b/source/RobotAPI/interface/aron/Aron.ice @@ -24,11 +24,16 @@ RUN_ARON_MACRO(String, string, STRING) \ RUN_ARON_MACRO(Bool, bool, BOOL) +#define ARON_VERSION "beta 0.2.2" + + module armarx { module aron { + const string VERSION = ARON_VERSION; + /************************* * General Definitions *** ************************/ @@ -53,6 +58,7 @@ module armarx }; class AronType { + //string VERSION = ARON_VERSION; Maybe maybe = Maybe::eNone; // Every type can have a maye type flag or not } sequence<AronType> AronTypeList; @@ -93,7 +99,9 @@ module armarx ************************/ module data { - class AronData { }; + class AronData { + //string VERSION = ARON_VERSION; + }; sequence<AronData> AronDataList; dictionary<string, AronData> AronDataDict; diff --git a/source/RobotAPI/libraries/armem_robot_state/client/common/RobotReader.cpp b/source/RobotAPI/libraries/armem_robot_state/client/common/RobotReader.cpp index 2d8319dc9f6517c41e9a38225ad4dbd11b9ae607..46d4b1014dba8dfe1ed59a8343395b9063e4050d 100644 --- a/source/RobotAPI/libraries/armem_robot_state/client/common/RobotReader.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/client/common/RobotReader.cpp @@ -242,7 +242,7 @@ namespace armarx::armem::robot_state template <typename AronClass> std::optional<AronClass> tryCast(const wm::EntityInstance& item) { - static_assert(std::is_base_of<armarx::aron::cppcodegenerator::AronCppClass, + static_assert(std::is_base_of<armarx::aron::cppserializer::AronCppClass, AronClass>::value); try @@ -327,4 +327,4 @@ namespace armarx::armem::robot_state return robot::convertRobotDescription(instance); } -} // namespace armarx::armem::robot_state \ No newline at end of file +} // namespace armarx::armem::robot_state diff --git a/source/RobotAPI/libraries/aron/core/Descriptor.h b/source/RobotAPI/libraries/aron/core/Descriptor.h index de3493429af6d051cec8d0d3f473b41f218a522b..10833d329cfec0d594375a1c12d9f83b28c46570 100644 --- a/source/RobotAPI/libraries/aron/core/Descriptor.h +++ b/source/RobotAPI/libraries/aron/core/Descriptor.h @@ -46,7 +46,7 @@ namespace armarx::aron::type eUnknown = -1 }; - const std::map<type::Descriptor, std::string> _descriptorstring = + const std::map<type::Descriptor, std::string> _descriptor2string = { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ { Descriptor::e##upperType, "armarx::aron::type::Descriptor::e" + std::string(#upperType) }, @@ -58,10 +58,10 @@ namespace armarx::aron::type inline std::string DESCRIPTOR_TO_STRING(const type::Descriptor d) { - return type::_descriptorstring.at(d); + return type::_descriptor2string.at(d); } - const std::map<type::Maybe, std::string> _maybestring = + const std::map<type::Maybe, std::string> _maybe2string = { {type::Maybe::eNone, "armarx::aron::type::Maybe::eNone"}, {type::Maybe::eOptional, "armarx::aron::type::Maybe::eOptional"}, @@ -72,7 +72,28 @@ namespace armarx::aron::type inline std::string MAYBE_TO_STRING(const type::Maybe d) { - return type::_maybestring.at(d); + return type::_maybe2string.at(d); + } + + const std::map<std::string, type::Descriptor> _string2descriptor = + { +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + { "armarx::aron::type::Descriptor::e" + std::string(#upperType), Descriptor::e##upperType }, \ + { std::string(#upperType), Descriptor::e##upperType }, \ + { std::string(#lowerType), Descriptor::e##upperType }, \ + { std::string(#capsType), Descriptor::e##upperType }, + + HANDLE_ALL_ARON_TYPES +#undef RUN_ARON_MACRO + {"armarx::aron::type::Descriptor::eUnknown", Descriptor::eUnknown}, + {"Unknown", Descriptor::eUnknown}, + {"unknown", Descriptor::eUnknown}, + {"UNKNOWN", Descriptor::eUnknown} + }; + + inline type::Descriptor STRING_TO_DESCRIPTOR(const std::string& s) + { + return type::_string2descriptor.at(s); } } @@ -88,7 +109,7 @@ namespace armarx::aron::data eUnknown = -1 }; - const std::map<data::Descriptor, std::string> _descriptorstring = + const std::map<data::Descriptor, std::string> _descriptor2string = { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ { Descriptor::e##upperType, "armarx::aron::data::Descriptor::e" + std::string(#upperType) }, @@ -100,6 +121,27 @@ namespace armarx::aron::data inline std::string DESCRIPTOR_TO_STRING(const data::Descriptor d) { - return data::_descriptorstring.at(d); + return data::_descriptor2string.at(d); + } + + const std::map<std::string, data::Descriptor> _string2descriptor = + { +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + { "armarx::aron::data::Descriptor::e" + std::string(#upperType), Descriptor::e##upperType }, \ + { std::string(#upperType), Descriptor::e##upperType }, \ + { std::string(#lowerType), Descriptor::e##upperType }, \ + { std::string(#capsType), Descriptor::e##upperType }, + + HANDLE_ALL_ARON_DATA +#undef RUN_ARON_MACRO + {"armarx::aron::data::Descriptor::eUnknown", Descriptor::eUnknown}, + {"Unknown", Descriptor::eUnknown}, + {"unknown", Descriptor::eUnknown}, + {"UNKNOWN", Descriptor::eUnknown} + }; + + inline data::Descriptor STRING_TO_DESCRIPTOR(const std::string& s) + { + return data::_string2descriptor.at(s); } } diff --git a/source/RobotAPI/libraries/aron/core/Exception.h b/source/RobotAPI/libraries/aron/core/Exception.h index 5bd308a21ec12862a8a8c7859e3b7dc40f827f15..025328edaa8360ed6a31864b91d4dcb030c8ff60 100644 --- a/source/RobotAPI/libraries/aron/core/Exception.h +++ b/source/RobotAPI/libraries/aron/core/Exception.h @@ -158,6 +158,18 @@ namespace armarx::aron::error { } + + StringNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const std::string& input, const std::string& expectation) : + AronException(caller, method, reason + ". Got: " + input + ". Expected: " + expectation) + { + + } + + StringNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const std::string& input, const std::string& expectation, const Path& path) : + AronException(caller, method, reason + ". Got: " + input + ". Expected: " + expectation, path) + { + + } }; class IndexNotValidException : diff --git a/source/RobotAPI/libraries/aron/core/io/Data.h b/source/RobotAPI/libraries/aron/core/io/Data.h index 717ab255c523f727a9b150f6ed3d360acb08c421..6f9fe8ca878a6f7a8f697af1295fd6f0ccbe581b 100644 --- a/source/RobotAPI/libraries/aron/core/io/Data.h +++ b/source/RobotAPI/libraries/aron/core/io/Data.h @@ -26,7 +26,7 @@ // ArmarX #include <ArmarXCore/core/exceptions/Exception.h> - +#include <RobotAPI/libraries/aron/core/Descriptor.h> #include <RobotAPI/libraries/aron/core/Config.h> @@ -39,9 +39,13 @@ namespace armarx::aron::io Data() = delete; public: - // TODO: Remove copy from ReaderWriter - static constexpr const char* READER_WRITER_NAME_SLUG = "__ARON_NAME"; - static constexpr const char* READER_WRITER_MAYBE_SLUG = "__MAYBE"; + static constexpr const char* READER_WRITER_MAYBE_SLUG = "__ARON_MAYBE"; + static constexpr const char* READER_WRITER_TYPE_SLUG = "__ARON_TYPE"; + static constexpr const char* READER_WRITER_VERSION_SLUG = "__ARON_VERSION"; + + static constexpr const char* READER_WRITER_VALUE_SLUG = "__ARON_VALUE"; + + static constexpr const char* READER_WRITER_OBJECT_NAME_SLUG = "__ARON_OBJECT_NAME"; static constexpr const char* READER_WRITER_DICT_ACCEPTED_TYPE_SLUG = "__ARON_DICT_ACCEPTED_TYPE"; static constexpr const char* READER_WRITER_LIST_ACCEPTED_TYPE_SLUG = "__ARON_LIST_ACCEPTED_TYPE"; @@ -52,15 +56,12 @@ namespace armarx::aron::io static constexpr const char* READER_WRITER_NDARRAY_DATA_SLUG = "__ARON_NDARRAY_DATA"; static constexpr const char* READER_WRITER_INT_ENUM_NAME_SLUG = "__ARON_INT_ENUM_NAME"; - static constexpr const char* READER_WRITER_INT_ENUM_VALUE_SLUG = "__ARON_INT_ENUM_VALUE"; static constexpr const char* READER_WRITER_ENUM_KEY_SLUG = "__ARON_ENUM_KEY"; - static constexpr const char* READER_WRITER_PRIMITIVE_NAME_SLUG = "__ARON_PRIMITIVE_NAME"; - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ static constexpr const char* READER_WRITER_##capsType##_TYPENAME_SLUG = #capsType; - HANDLE_PRIMITIVE_TYPES + HANDLE_ALL_ARON_TYPES #undef RUN_ARON_MACRO }; } diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/Reader.h b/source/RobotAPI/libraries/aron/core/io/dataIO/Reader.h index ac4ee93d1a485b171859455f7ba9522eb09ba59a..8191457b3895e5dfaaae4b2e4603fae3b518261e 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/Reader.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/Reader.h @@ -79,6 +79,6 @@ namespace armarx::aron::dataIO virtual void loadMember(const std::string&) = 0; // Helper functions - virtual data::Descriptor getTypeOfNext(const type::Descriptor hint = type::Descriptor::eUnknown) const = 0; + virtual data::Descriptor getTypeOfNext() const = 0; }; } diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/converter/Converter.cpp b/source/RobotAPI/libraries/aron/core/io/dataIO/converter/Converter.cpp index a7629cd5ca59cf7f5af11adfb4cb0305fe94db23..1e124a8080ec1ec5aa53b8563068b1c0b176e2d1 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/converter/Converter.cpp +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/converter/Converter.cpp @@ -35,7 +35,10 @@ namespace armarx::aron::dataIO { type::Descriptor t_desc = expectedStructure != nullptr ? expectedStructure->getDescriptor() : type::Descriptor::eUnknown; //std::cout << "Expected Structure: " << type::DESCRIPTOR_TO_STRING(t_desc) << std::endl; - data::Descriptor desc = reader.getTypeOfNext(t_desc); + data::Descriptor desc = reader.getTypeOfNext(); + + // TODO check expected type and read type + switch (desc) { case data::Descriptor::eDict: diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/ReaderToken.h b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/ReaderToken.h index 9e22a2acd622c4d38c1dd923445c91c9760208e7..fc3868d16583dd7de9bd2712029b56ce67a7d884 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/ReaderToken.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/ReaderToken.h @@ -45,7 +45,7 @@ namespace armarx::aron::dataIO // Interface - virtual data::Descriptor getTypeOfNext(const type::Descriptor hint = type::Descriptor::eUnknown) const = 0; + virtual data::Descriptor getTypeOfNext() const = 0; virtual ElementTypename getNextElement() const = 0; virtual bool hasNextElement() const = 0; diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.cpp b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.cpp index 665b1b125ad5ec27425576d52a471501fd813cd7..58a778a865bd1beda0db793228b4acf24a3b257f 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.cpp +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.cpp @@ -42,7 +42,7 @@ namespace armarx::aron::dataIO::reader input(n) { auto current_nav_casted = datanavigator::DictNavigator::DynamicCastAndCheck(input); - auto newToken = std::make_shared<NavigatorReaderToken>(data::Descriptor::eDict, current_nav_casted); + auto newToken = std::make_shared<NavigatorReaderToken>(current_nav_casted); stack.push(newToken); } @@ -70,7 +70,7 @@ namespace armarx::aron::dataIO::reader auto current_nav_casted = datanavigator::DictNavigator::DynamicCastAndCheck(current_nav); int c = current_nav->childrenSize(); - auto newToken = std::make_shared<NavigatorReaderToken>(data::Descriptor::eDict, current_nav_casted); + auto newToken = std::make_shared<NavigatorReaderToken>(current_nav_casted); stack.push(newToken); return {c, true}; } @@ -110,7 +110,7 @@ namespace armarx::aron::dataIO::reader auto current_nav_casted = datanavigator::ListNavigator::DynamicCastAndCheck(current_nav); int c = current_nav->childrenSize(); - auto newToken = std::make_shared<NavigatorReaderToken>(data::Descriptor::eList, current_nav_casted); + auto newToken = std::make_shared<NavigatorReaderToken>(current_nav_casted); stack.push(newToken); return {c, true}; } @@ -253,20 +253,13 @@ namespace armarx::aron::dataIO::reader } // Helper functions - data::Descriptor NavigatorReader::getTypeOfNext(const type::Descriptor hint) const + data::Descriptor NavigatorReader::getTypeOfNext() const { if (stack.empty()) { - if (hint == type::Descriptor::eUnknown) - { - return data::Descriptor::eDict; - } - else - { - return Resolver::GetCorresponding(hint); - } + return data::Descriptor::eDict; } auto token = stack.top(); - return token->getTypeOfNext(hint); + return token->getTypeOfNext(); } } diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.h b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.h index 547f6be8fc7b964ef6074e49f90e293a1e56d7bb..0b1c5739ecb1a0112e29ffc7cb2822f892b303bd 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReader.h @@ -68,7 +68,7 @@ namespace armarx::aron::dataIO::reader virtual std::string readKey() override; virtual void loadMember(const std::string&) override; - virtual data::Descriptor getTypeOfNext(const type::Descriptor hint = type::Descriptor::eUnknown) const override; + virtual data::Descriptor getTypeOfNext() const override; private: bool readFirstStartDict = false; diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReaderToken.h b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReaderToken.h index a11b6161388e5e87356715ad33037ec673b75369..6941b5f4ec9c3e2566a7717e7675c673399a171d 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReaderToken.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/navigator/NavigatorReaderToken.h @@ -46,9 +46,9 @@ namespace armarx::aron::dataIO::reader public: // constructors NavigatorReaderToken() = delete; - NavigatorReaderToken(const data::Descriptor desc, const datanavigator::NavigatorPtr& data) + NavigatorReaderToken(const datanavigator::NavigatorPtr& data) { - descriptor = desc; + descriptor = data->getDescriptor(); element = data; switch (descriptor) @@ -65,11 +65,11 @@ namespace armarx::aron::dataIO::reader break; } default: - throw error::DescriptorNotValidException("NavigatorReaderToken", "NavigatorReaderToken", "Received an invalid instance for a reader token.", desc); + throw error::DescriptorNotValidException("NavigatorReaderToken", "NavigatorReaderToken", "Received an invalid instance for a reader token.", descriptor); } } - data::Descriptor getTypeOfNext(const type::Descriptor hint = type::Descriptor::eUnknown) const override + data::Descriptor getTypeOfNext() const override { const datanavigator::NavigatorPtr next = getNextElement(); return next->getDescriptor(); diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp index 619466c574a00f6e756324111e06c4b60c4c4571..67560f75256df7661eff8fa9b6152dcb1a8e7b54 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp @@ -41,7 +41,17 @@ namespace armarx::aron::dataIO::reader NlohmannJSONReader::NlohmannJSONReader(const nlohmann::json& n) : input(n) { - auto newToken = std::make_shared<NlohmannJSONReaderToken>(data::Descriptor::eDict, n); + if (!n.is_object()) + { + throw error::AronException("NlohmannJSONReader", "NlohmannJSONReader", "Allowed are only objects in reader"); + } + + if (n.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_DICT_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readStartList", "The json is not of dict type!", n[io::Data::READER_WRITER_TYPE_SLUG], io::Data::READER_WRITER_DICT_TYPENAME_SLUG); + } + + auto newToken = std::make_shared<NlohmannJSONReaderToken>(n); stack.push(newToken); } @@ -66,8 +76,18 @@ namespace armarx::aron::dataIO::reader return {0, false}; } + if (!current_json.is_object()) + { + throw error::AronException("NlohmannJSONReader", "readStartDict", "The json is not an object. Every part of the data must be an object containing the type and the value."); + } + + if (current_json.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_DICT_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readStartList", "The json is not of dict type!", current_json.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_DICT_TYPENAME_SLUG); + } + int c = current_json.size(); - auto newToken = std::make_shared<NlohmannJSONReaderToken>(data::Descriptor::eDict, current_json); + auto newToken = std::make_shared<NlohmannJSONReaderToken>(current_json); stack.push(newToken); return {c, true}; } @@ -103,8 +123,18 @@ namespace armarx::aron::dataIO::reader return {0, false}; } + if (!current_json.is_object()) + { + throw error::AronException("NlohmannJSONReader", "readStartList", "The json is not an object. Every part of the data must be an object containing the type and the value."); + } + + if (current_json.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_LIST_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readStartList", "The json is not of list type!", current_json.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_LIST_TYPENAME_SLUG); + } + int c = current_json.size(); - auto newToken = std::make_shared<NlohmannJSONReaderToken>(data::Descriptor::eList, current_json); + auto newToken = std::make_shared<NlohmannJSONReaderToken>(current_json); stack.push(newToken); return {c, true}; } @@ -137,8 +167,14 @@ namespace armarx::aron::dataIO::reader lastToken->increaseCounter(); return {{}, "", false}; } - std::vector<int> dims = current_json[io::Data::READER_WRITER_NDARRAY_DIMENSIONS_SLUG]; - std::string type = current_json[io::Data::READER_WRITER_NDARRAY_TYPE_SLUG]; + + if (current_json.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_NDARRAY_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readStartNDArray", "The json is not of ndarray type!", current_json.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_NDARRAY_TYPENAME_SLUG); + } + + std::vector<int> dims = current_json.at(io::Data::READER_WRITER_NDARRAY_DIMENSIONS_SLUG); + std::string type = current_json.at(io::Data::READER_WRITER_NDARRAY_TYPE_SLUG); return {dims, type, true}; } @@ -152,8 +188,8 @@ namespace armarx::aron::dataIO::reader auto lastToken = stack.top(); auto current_json = lastToken->getNextElement(); - std::vector<int> dims = current_json[io::Data::READER_WRITER_NDARRAY_DIMENSIONS_SLUG]; - std::vector<unsigned char> d = current_json[io::Data::READER_WRITER_NDARRAY_DATA_SLUG]; + std::vector<int> dims = current_json.at(io::Data::READER_WRITER_NDARRAY_DIMENSIONS_SLUG); + std::vector<unsigned char> d = current_json.at(io::Data::READER_WRITER_NDARRAY_DATA_SLUG); memcpy(data, d.data(), std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>())); } @@ -168,6 +204,7 @@ namespace armarx::aron::dataIO::reader lastToken->increaseCounter(); return {false}; } + return {true}; } @@ -175,48 +212,84 @@ namespace armarx::aron::dataIO::reader { auto lastToken = stack.top(); auto j = lastToken->getNextElement(); + + if (j.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_INT_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readEndPrimitive", "The json is not of int type!", j.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_INT_TYPENAME_SLUG); + } + lastToken->increaseCounter(); - t = j; + t = j.at(io::Data::READER_WRITER_VALUE_SLUG); } void NlohmannJSONReader::readEndPrimitive(long& t) { auto lastToken = stack.top(); auto j = lastToken->getNextElement(); + + if (j.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_LONG_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readEndPrimitive", "The json is not of long type!", j.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_LONG_TYPENAME_SLUG); + } + lastToken->increaseCounter(); - t = j; + t = j.at(io::Data::READER_WRITER_VALUE_SLUG); } void NlohmannJSONReader::readEndPrimitive(float& t) { auto lastToken = stack.top(); auto j = lastToken->getNextElement(); + + if (j.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_FLOAT_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readEndPrimitive", "The json is not of float type!", j.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_FLOAT_TYPENAME_SLUG); + } + lastToken->increaseCounter(); - t = j; + t = j.at(io::Data::READER_WRITER_VALUE_SLUG); } void NlohmannJSONReader::readEndPrimitive(double& t) { auto lastToken = stack.top(); auto j = lastToken->getNextElement(); + + if (j.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_DOUBLE_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readEndPrimitive", "The json is not of double type!", j.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_DOUBLE_TYPENAME_SLUG); + } + lastToken->increaseCounter(); - t = j; + t = j.at(io::Data::READER_WRITER_VALUE_SLUG); } void NlohmannJSONReader::readEndPrimitive(std::string& t) { auto lastToken = stack.top(); auto j = lastToken->getNextElement(); + + if (j.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_STRING_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readEndPrimitive", "The json is not of string type!", j.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_STRING_TYPENAME_SLUG); + } + lastToken->increaseCounter(); - t = j; + t = j.at(io::Data::READER_WRITER_VALUE_SLUG); } void NlohmannJSONReader::readEndPrimitive(bool& t) { auto lastToken = stack.top(); auto j = lastToken->getNextElement(); + + if (j.at(io::Data::READER_WRITER_TYPE_SLUG) != io::Data::READER_WRITER_BOOL_TYPENAME_SLUG) + { + throw error::StringNotValidException("NlohmannJSONReader", "readEndPrimitive", "The json is not of bool type!", j.at(io::Data::READER_WRITER_TYPE_SLUG), io::Data::READER_WRITER_BOOL_TYPENAME_SLUG); + } + lastToken->increaseCounter(); - t = j; + t = j.at(io::Data::READER_WRITER_VALUE_SLUG); } std::string NlohmannJSONReader::readKey() @@ -232,20 +305,13 @@ namespace armarx::aron::dataIO::reader } // Helper functions - data::Descriptor NlohmannJSONReader::getTypeOfNext(const type::Descriptor hint) const + data::Descriptor NlohmannJSONReader::getTypeOfNext() const { if (stack.empty()) { - if (hint == type::Descriptor::eUnknown) - { - return data::Descriptor::eDict; - } - else - { - return Resolver::GetCorresponding(hint); - } + return data::Descriptor::eDict; } auto token = stack.top(); - return token->getTypeOfNext(hint); + return token->getTypeOfNext(); } } diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h index 0285398f239d0816b1e4958901c9764315c5dc58..84ac1f42cb1d6743a1ec1e5f2099dccbb157ca2c 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h @@ -66,7 +66,7 @@ namespace armarx::aron::dataIO::reader virtual std::string readKey() override; virtual void loadMember(const std::string&) override; - virtual data::Descriptor getTypeOfNext(const type::Descriptor hint = type::Descriptor::eUnknown) const override; + virtual data::Descriptor getTypeOfNext() const override; private: bool readFirstStartDict = false; diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h index 7711670ddf4b45cf5602ae617089366c8b85db58..58f38d9d14677173ec054076dcf790efc3228cef 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h @@ -50,9 +50,14 @@ namespace armarx::aron::dataIO::reader // constructors NlohmannJSONReaderToken() = delete; - NlohmannJSONReaderToken(const data::Descriptor desc, const nlohmann::json& data) + NlohmannJSONReaderToken(const nlohmann::json& data) { - descriptor = desc; + if (!data.is_object()) + { + throw error::AronException("NlohmannJSONReaderToken", "NlohmannJSONReaderToken", "Received an invalid json instance for a reader. Allowed are only objects."); + } + + descriptor = data::STRING_TO_DESCRIPTOR(data.at(io::Data::READER_WRITER_TYPE_SLUG)); element = data; switch (descriptor) @@ -61,61 +66,36 @@ namespace armarx::aron::dataIO::reader { for (auto it = data.begin(); it != data.end(); ++it) { + if (it.key() == io::Data::READER_WRITER_TYPE_SLUG || it.key() == io::Data::READER_WRITER_VERSION_SLUG) + { + continue; + } allMemberNames.push_back(it.key()); } - childrenSize = data.size(); + childrenSize = allMemberNames.size(); break; } case data::Descriptor::eList: { - childrenSize = data.size(); + childrenSize = data.at(io::Data::READER_WRITER_VALUE_SLUG).size(); break; } default: - throw error::DescriptorNotValidException("NlohmannJSONReaderToken", "NlohmannJSONReaderToken", "Received an invalid instance for a reader token.", desc); + throw error::DescriptorNotValidException("NlohmannJSONReaderToken", "NlohmannJSONReaderToken", "Received an invalid instance for a reader token.", descriptor); } } - data::Descriptor getTypeOfNext(const type::Descriptor hint) const override + data::Descriptor getTypeOfNext() const override { const nlohmann::json next = getNextElement(); - if (next.is_object()) - { - // Check if specific NDArray key exists - if (next.find(io::Data::READER_WRITER_NDARRAY_DATA_SLUG) != next.end()) - { - return data::Descriptor::eNDArray; - } - return data::Descriptor::eDict; - } - if (next.is_array()) + if (next.is_null()) { - return data::Descriptor::eList; + return data::Descriptor::eUnknown; } - if (next.is_number_integer()) - { - data::Descriptor d = Resolver::GetFirstIfRelated( - Resolver::GetCorresponding(hint), - data::Descriptor::eLong); - return d; - } - if (next.is_number_float()) - { - data::Descriptor d = Resolver::GetFirstIfRelated( - Resolver::GetCorresponding(hint), - data::Descriptor::eDouble); - return d; - } - if (next.is_boolean()) - { - return data::Descriptor::eBool; - } - if (next.is_string()) - { - return data::Descriptor::eString; - } - throw error::AronException("NlohmannJSONReaderToken", "getTypeOfNextElement", "Could not determine the type of an nlohmann::json object. Could not convert to data::Descriptor enum."); + std::string type_as_str = next.at(io::Data::READER_WRITER_NDARRAY_DATA_SLUG); + data::Descriptor desc = data::STRING_TO_DESCRIPTOR(type_as_str); + return desc; } nlohmann::json getNextElement() const override @@ -129,12 +109,12 @@ namespace armarx::aron::dataIO::reader { case data::Descriptor::eDict: { - nlohmann::json ret = element[getCurrentKey()]; + nlohmann::json ret = element.at(getCurrentKey()); return ret; } case data::Descriptor::eList: { - nlohmann::json ret = element[currentIndex]; + nlohmann::json ret = element.at(io::Data::READER_WRITER_VALUE_SLUG).at(currentIndex); return ret; } default: @@ -148,13 +128,13 @@ namespace armarx::aron::dataIO::reader { case data::Descriptor::eDict: { - nlohmann::json ret = element[getCurrentKey()]; + nlohmann::json ret = element.at(getCurrentKey()); return !ret.is_null(); } case data::Descriptor::eList: { - nlohmann::json ret = element[currentIndex]; - return !ret.is_null(); + auto size = element.at(io::Data::READER_WRITER_VALUE_SLUG).size(); + return size >= currentIndex; } default: throw error::DescriptorNotValidException("NlohmannJSONReaderToken", "hasData", "Could not resove a type of a json. Allowed are only container types due to performance", descriptor); diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriter.cpp b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriter.cpp index 633d62ea3861db6bbefeb160ae0df3fe98d5bc15..8777b5d0c9691d75a6dce7c780c4e3f6c5c6ce04 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriter.cpp +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriter.cpp @@ -52,7 +52,7 @@ namespace armarx::aron::dataIO::writer { Path path = generatePath(); auto data = std::make_shared<datanavigator::DictNavigator>(path); - auto new_token = std::make_shared<NavigatorWriterToken>(data::Descriptor::eDict, data); + auto new_token = std::make_shared<NavigatorWriterToken>(data); stack.push(new_token); } @@ -72,7 +72,7 @@ namespace armarx::aron::dataIO::writer { Path path = generatePath(); auto data = std::make_shared<datanavigator::ListNavigator>(path); - auto new_token = std::make_shared<NavigatorWriterToken>(data::Descriptor::eList, data); + auto new_token = std::make_shared<NavigatorWriterToken>(data); stack.push(new_token); } diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriterToken.h b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriterToken.h index 7e8a53a773f728196ba28c4ebcd963279265102d..c7de6070ec9688fcd39a5bd6d2b027c82de70224 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriterToken.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/navigator/NavigatorWriterToken.h @@ -45,11 +45,11 @@ namespace armarx::aron::dataIO::writer public: // constructor NavigatorWriterToken() = delete; - NavigatorWriterToken(const data::Descriptor desc, const datanavigator::NavigatorPtr& d) + NavigatorWriterToken(const datanavigator::NavigatorPtr& d) { ARMARX_CHECK_NOT_NULL(d); - descriptor = desc; + descriptor = d->getDescriptor(); element = d; } diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp index 9e5517b65b29066827cd1e133b3aa2618afd92be..269c14e4cf1663cdee884e77c06e6ffa8b88ac76 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp @@ -32,7 +32,8 @@ namespace armarx::aron::dataIO::writer void NlohmannJSONWriter::writeStartDict() { nlohmann::json data; - auto new_token = std::make_shared<NlohmannJSONWriterToken>(data::Descriptor::eDict, data); + data[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_DICT_TYPENAME_SLUG; + auto new_token = std::make_shared<NlohmannJSONWriterToken>(data); stack.push(new_token); } @@ -51,7 +52,9 @@ namespace armarx::aron::dataIO::writer void NlohmannJSONWriter::writeStartList() { nlohmann::json data; - auto new_token = std::make_shared<NlohmannJSONWriterToken>(data::Descriptor::eList, data); + data[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_LIST_TYPENAME_SLUG; + data[io::Data::READER_WRITER_VALUE_SLUG] = {}; + auto new_token = std::make_shared<NlohmannJSONWriterToken>(data); stack.push(new_token); } @@ -72,6 +75,7 @@ namespace armarx::aron::dataIO::writer { NlohmannJSONWriterTokenPtr token = stack.top(); nlohmann::json j; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_NDARRAY_TYPENAME_SLUG; j[io::Data::READER_WRITER_NDARRAY_DIMENSIONS_SLUG] = dims; j[io::Data::READER_WRITER_NDARRAY_TYPE_SLUG] = t; int elements = std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()); @@ -85,42 +89,54 @@ namespace armarx::aron::dataIO::writer void NlohmannJSONWriter::writePrimitive(const int x) { auto token = stack.top(); - nlohmann::json j(x); + nlohmann::json j; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_INT_TYPENAME_SLUG; + j[io::Data::READER_WRITER_VALUE_SLUG] = x; token->addElement(j); } void NlohmannJSONWriter::writePrimitive(const long x) { auto token = stack.top(); - nlohmann::json j(x); + nlohmann::json j; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_LONG_TYPENAME_SLUG; + j[io::Data::READER_WRITER_VALUE_SLUG] = x; token->addElement(j); } void NlohmannJSONWriter::writePrimitive(const float x) { auto token = stack.top(); - nlohmann::json j(x); + nlohmann::json j; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_FLOAT_TYPENAME_SLUG; + j[io::Data::READER_WRITER_VALUE_SLUG] = x; token->addElement(j); } void NlohmannJSONWriter::writePrimitive(const double x) { auto token = stack.top(); - nlohmann::json j(x); + nlohmann::json j; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_DOUBLE_TYPENAME_SLUG; + j[io::Data::READER_WRITER_VALUE_SLUG] = x; token->addElement(j); } void NlohmannJSONWriter::writePrimitive(const std::string& x) { auto token = stack.top(); - nlohmann::json j(x); + nlohmann::json j; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_STRING_TYPENAME_SLUG; + j[io::Data::READER_WRITER_VALUE_SLUG] = x; token->addElement(j); } void NlohmannJSONWriter::writePrimitive(const bool x) { auto token = stack.top(); - nlohmann::json j(x); + nlohmann::json j; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_BOOL_TYPENAME_SLUG; + j[io::Data::READER_WRITER_VALUE_SLUG] = x; token->addElement(j); } diff --git a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h index 9f37b4993a86c7006cfe8ad98b40ea006c09ff53..ef8ded6b28d1b9ca65bfdf9a3470e39157030390 100644 --- a/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h +++ b/source/RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h @@ -47,9 +47,9 @@ namespace armarx::aron::dataIO::writer public: // constructor NlohmannJSONWriterToken() = delete; - NlohmannJSONWriterToken(const data::Descriptor desc, const nlohmann::json& d) + NlohmannJSONWriterToken(const nlohmann::json& d) { - descriptor = desc; + descriptor = data::STRING_TO_DESCRIPTOR(d[io::Data::READER_WRITER_TYPE_SLUG]); element = d; } @@ -66,7 +66,7 @@ namespace armarx::aron::dataIO::writer } case data::Descriptor::eList: { - element.push_back(n); + element[io::Data::READER_WRITER_VALUE_SLUG].push_back(n); currentIndex++; break; } diff --git a/source/RobotAPI/libraries/aron/core/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h b/source/RobotAPI/libraries/aron/core/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h index 3d3503af2567199be5ebf627f45813f2b220c606..d95638c1a2c3d3b1f4c6ebf835a454f8831ea924 100644 --- a/source/RobotAPI/libraries/aron/core/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h +++ b/source/RobotAPI/libraries/aron/core/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h @@ -59,7 +59,7 @@ namespace armarx::aron::typeIO::reader { for (auto& [key, val] : type.get<nlohmann::json::object_t>()) { - if (key == io::Data::READER_WRITER_NAME_SLUG) + if (key == io::Data::READER_WRITER_OBJECT_NAME_SLUG) { continue; } @@ -67,7 +67,7 @@ namespace armarx::aron::typeIO::reader allMemberNames.push_back(key); } childrenSize = allMemberNames.size(); - elementName = element[io::Data::READER_WRITER_NAME_SLUG]; + elementName = element[io::Data::READER_WRITER_OBJECT_NAME_SLUG]; break; } case type::Descriptor::eDict: diff --git a/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp b/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp index 72b3962e7803d7b8b981506a61e02608704e33ba..1ce3afe2394a3a20aa89948db49f97493d45865f 100644 --- a/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp +++ b/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp @@ -29,7 +29,7 @@ namespace armarx::aron::typeIO::writer void NlohmannJSONWriter::writeStartObject(const WriteStartObjectInput& o) { nlohmann::json data; - data[io::Data::READER_WRITER_NAME_SLUG] = o.name; + data[io::Data::READER_WRITER_OBJECT_NAME_SLUG] = o.name; data[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; auto new_token = std::make_shared<NlohmannJSONWriterToken>(type::Descriptor::eObject, data); stack.push(new_token); @@ -207,7 +207,7 @@ namespace armarx::aron::typeIO::writer { auto token = stack.top(); nlohmann::json j; - j[io::Data::READER_WRITER_PRIMITIVE_NAME_SLUG] = io::Data::READER_WRITER_INT_TYPENAME_SLUG; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_INT_TYPENAME_SLUG; j[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; token->addElement(j); } @@ -216,7 +216,7 @@ namespace armarx::aron::typeIO::writer { auto token = stack.top(); nlohmann::json j; - j[io::Data::READER_WRITER_PRIMITIVE_NAME_SLUG] = io::Data::READER_WRITER_LONG_TYPENAME_SLUG; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_LONG_TYPENAME_SLUG; j[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; token->addElement(j); } @@ -225,7 +225,7 @@ namespace armarx::aron::typeIO::writer { auto token = stack.top(); nlohmann::json j; - j[io::Data::READER_WRITER_PRIMITIVE_NAME_SLUG] = io::Data::READER_WRITER_FLOAT_TYPENAME_SLUG; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_FLOAT_TYPENAME_SLUG; j[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; token->addElement(j); } @@ -234,7 +234,7 @@ namespace armarx::aron::typeIO::writer { auto token = stack.top(); nlohmann::json j; - j[io::Data::READER_WRITER_PRIMITIVE_NAME_SLUG] = io::Data::READER_WRITER_DOUBLE_TYPENAME_SLUG; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_DOUBLE_TYPENAME_SLUG; j[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; token->addElement(j); } @@ -243,7 +243,7 @@ namespace armarx::aron::typeIO::writer { auto token = stack.top(); nlohmann::json j; - j[io::Data::READER_WRITER_PRIMITIVE_NAME_SLUG] = io::Data::READER_WRITER_STRING_TYPENAME_SLUG; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_STRING_TYPENAME_SLUG; j[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; token->addElement(j); } @@ -252,7 +252,7 @@ namespace armarx::aron::typeIO::writer { auto token = stack.top(); nlohmann::json j; - j[io::Data::READER_WRITER_PRIMITIVE_NAME_SLUG] = io::Data::READER_WRITER_BOOL_TYPENAME_SLUG; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_BOOL_TYPENAME_SLUG; j[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; token->addElement(j); } @@ -261,7 +261,7 @@ namespace armarx::aron::typeIO::writer { auto token = stack.top(); nlohmann::json j; - j[io::Data::READER_WRITER_PRIMITIVE_NAME_SLUG] = io::Data::READER_WRITER_TIME_TYPENAME_SLUG; + j[io::Data::READER_WRITER_TYPE_SLUG] = io::Data::READER_WRITER_TIME_TYPENAME_SLUG; j[io::Data::READER_WRITER_MAYBE_SLUG] = o.maybe; token->addElement(j); } diff --git a/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h b/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h index ea4410885b98ece7ee08e8c0ffb1c7443253c5f6..bea71d05b68deca116a253bbf9891ef29f7393a3 100644 --- a/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h +++ b/source/RobotAPI/libraries/aron/core/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h @@ -92,7 +92,7 @@ namespace armarx::aron::typeIO::writer { throw error::DescriptorNotValidException("NlohmannJSONWriterToken", "setName", "Cant set the name of a non-object token.", desc); } - element[io::Data::READER_WRITER_NAME_SLUG] = n; + element[io::Data::READER_WRITER_OBJECT_NAME_SLUG] = n; } }; } diff --git a/source/RobotAPI/libraries/aron/core/test/CMakeLists.txt b/source/RobotAPI/libraries/aron/core/test/CMakeLists.txt index 4215b607c91b739d41ddc5ef4b0f661d405fa531..d491c12363d7c088250599c7ff88dd6f62f25506 100644 --- a/source/RobotAPI/libraries/aron/core/test/CMakeLists.txt +++ b/source/RobotAPI/libraries/aron/core/test/CMakeLists.txt @@ -57,6 +57,6 @@ armarx_enable_aron_file_generation_for_target( xmls/PoseTest.xml xmls/PositionTest.xml xmls/PrimitiveTest.xml - #xmls/OptionalTest.xml + xmls/OptionalTest.xml #ENABLE_DEBUG_INFO ) diff --git a/source/RobotAPI/libraries/aron/core/test/aronTest.cpp b/source/RobotAPI/libraries/aron/core/test/aronTest.cpp index 17a3ddf27e63d92ba187a0babf4850006873a6ea..92efc6508c634ae3d411b75092bbf5572f78be96 100644 --- a/source/RobotAPI/libraries/aron/core/test/aronTest.cpp +++ b/source/RobotAPI/libraries/aron/core/test/aronTest.cpp @@ -90,7 +90,7 @@ using namespace aron; template <typename T> void runTestWithInstances(T& k1, T& k2) { - bool echo = true; + bool echo = false; Randomizer r; @@ -229,9 +229,10 @@ void runTestWithInstances(T& k1, T& k2) BOOST_CHECK_EQUAL((k1_aron_json_str == direct_k1_aron_json_str), true); armarx::aron::dataIO::reader::NlohmannJSONReader json_reader_for_k2(k1_aron_json); - k2.read(json_reader_for_k2); + k2.read(json_reader_for_k2); k2.write(json_writer_for_k2); + nlohmann::json k2_aron_json = json_writer_for_k2.getResult(); std::string k2_aron_json_str = k2_aron_json.dump(4);