diff --git a/source/RobotAPI/applications/AronGenerator/main.cpp b/source/RobotAPI/applications/AronGenerator/main.cpp index e235a0663216fcdfcfa84799dc7a7e324f72b1c4..afb9a62048c910804eb8c8cca7adc9273fcb7844 100644 --- a/source/RobotAPI/applications/AronGenerator/main.cpp +++ b/source/RobotAPI/applications/AronGenerator/main.cpp @@ -57,8 +57,8 @@ int main(int argc, char* argv[]) ("h,help", "Print usage"); options.add_options("file") - ("f,file", "XML file name", cxxopts::value<std::string>()->default_value("/home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml")) - ("o,output", "The output path", cxxopts::value<std::string>()->default_value("/home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/generated/")); + ("f,file", "XML file name", cxxopts::value<std::string>()->default_value("/path/to/some/xml/file.xml")) + ("o,output", "The output path", cxxopts::value<std::string>()->default_value("/path/to/some/output/folder/")); auto result = options.parse(argc, argv); @@ -106,7 +106,7 @@ int main(int argc, char* argv[]) std::cout << "--> Found " << reader.getGenerateTypes().size() << " types." << std::endl; } - codegeneration::classwriter::AronTypeClassCppWriter writer("AronTestSegment", reader.getWriters(), reader.getReaders(), reader.getUseTypes()); + codegeneration::classwriter::AronTypeClassCppWriter writer("AronTestSegment", reader.getWriters(), reader.getReaders(), reader.getUseTypes(), reader.getAdditionalIncludes()); if (verbose) { @@ -195,5 +195,5 @@ int main(int argc, char* argv[]) std::cerr << "Error in parsing cxxopts options: " << e.what() << std::endl; exit(1); } - return 0; + exit(0); } diff --git a/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.cpp b/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.cpp index 7ae852eeec344ba3d612068c3eb45aea70b1f66f..18978c4015a5ba919f9064d1fab8ffc3458eb7f4 100644 --- a/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.cpp +++ b/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.cpp @@ -43,7 +43,7 @@ namespace armarx { PropertyDefinitionsPtr defs{new ComponentPropertyDefinitions{getConfigIdentifier()}}; - defs->optional(local_memory_hostnames, "LocalMemoryHostnames", "The hostnames of the local memories, comma separated"); + defs->optional(local_memory_names, "LocalMemoryNames", "The objectnames of the local memories, comma separated"); return defs; } @@ -62,16 +62,16 @@ namespace armarx void ArMemGlobalStorage::onInitComponent() { - for (const std::string& hostname : simox::alg::split(local_memory_hostnames, ",")) + for (const std::string& name : simox::alg::split(local_memory_names, ",")) { - usingProxy(GenerateLocalMemoryObjectNameFromHostname(hostname)); + usingProxy(GenerateLocalMemoryObjectNameFromHostname(name)); } } void ArMemGlobalStorage::onConnectComponent() { - for (const std::string& hostname : simox::alg::split(local_memory_hostnames, ",")) + for (const std::string& hostname : simox::alg::split(local_memory_names, ",")) { ArMemLocalMemoryInterfacePrx localMemoryPrx = getProxy<ArMemLocalMemoryInterfacePrx>(GenerateLocalMemoryObjectNameFromHostname(hostname)); local_memories[hostname] = localMemoryPrx; diff --git a/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.h b/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.h index f3534e096425a2719ec6d460cefafc3de38b15b6..bce4df46cd1590e9bbe7c7e6ee89b8bb60d43de8 100644 --- a/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.h +++ b/source/RobotAPI/components/ArMemGlobalStorage/ArMemGlobalStorage.h @@ -63,7 +63,7 @@ namespace armarx armarx::PropertyDefinitionsPtr createPropertyDefinitions() override; private: - std::string local_memory_hostnames; + std::string local_memory_names; std::map<std::string, ArMemLocalMemoryInterfacePrx> local_memories; }; } diff --git a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp index 4ca8e4d6372e5e722a96a75f59311b3f81fd313c..41bc99495d98d9bb5d6a200b7300b551d0c6f090 100644 --- a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp +++ b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp @@ -33,26 +33,24 @@ namespace armarx { armarx::PropertyDefinitionsPtr ArMemLocalStorage::createPropertyDefinitions() { - PropertyDefinitionsPtr defs(new ComponentPropertyDefinitions(getConfigIdentifier(), false)); - defs->optional(hostname_to_use, "MockedHostname", "Use a hostname mock. Leave empty to use the real one."); + PropertyDefinitionsPtr defs(new ComponentPropertyDefinitions(getConfigIdentifier())); defs->optional(maximum_segments, "MaximumNumberOfSegments", "Maximum number of segments (<0 means infinite)"); defs->optional(maximum_entries_per_segment, "MaximumEntriesPerSegment", "Maximum number of accepted datatypes per segment (<0 means infinite)"); - defs->optional(maximum_entries_per_datatype, "MaximumEntriesPerDatatype", "Maximum number of accepted commits per datatype (<0 means infinite)"); return defs; } std::string ArMemLocalStorage::getDefaultName() const { - return GenerateLocalMemoryObjectNameFromHostname(hostname_to_use); + return GenerateLocalMemoryObjectNameFromHostname(getMyHostname()); } ArMemLocalStorage::ArMemLocalStorage() : armarx::Component(), armarx::armem::ArMemBase(), - hostname_to_use(getMyHostname()), + num_segments(0), + num_entries_per_segment(), maximum_segments(-1), - maximum_entries_per_segment(-1), - maximum_entries_per_datatype(-1) + maximum_entries_per_segment(-1) { } @@ -77,26 +75,50 @@ namespace armarx } - bool ArMemLocalStorage::hasSegment(const std::string& segment) const + ArMemLocalStorage::HasSegmentReturnType ArMemLocalStorage::hasSegment(const std::string& segment) const { auto index_pos = indexed_storage.find(segment); auto timestamped_pos = timestamped_storage.find(segment); auto hashed_pos = hashed_storage.find(segment); - return index_pos == indexed_storage.end() || timestamped_pos == timestamped_storage.end() || hashed_pos == hashed_storage.end(); + if (index_pos == indexed_storage.end() && timestamped_pos == timestamped_storage.end() && hashed_pos == hashed_storage.end()) + { + return HasSegmentReturnType::No; + } + + if (index_pos != indexed_storage.end() && timestamped_pos != timestamped_storage.end() && hashed_pos != hashed_storage.end()) + { + return HasSegmentReturnType::Yes; + } + + bool index_pos_end = (index_pos == indexed_storage.end()); + bool timestamped_pos_end = (timestamped_pos == timestamped_storage.end()); + bool hashed_pos_end = (hashed_pos == hashed_storage.end()); + ARMARX_ERROR << "The memory is in an inconsistent state. A segment was found in some containers but not in all! Resetting segment!\n" + << "The indexed storage " << (index_pos_end ? "does not contain " : "contains ") << " the segment, \n" + << "The timestamped storage " << (timestamped_pos_end ? "does not contain " : "contains ") << " the segment, \n" + << "The hashed storage " << (hashed_pos_end ? "does not contain " : "contains ") << " the segment, \n"; + return HasSegmentReturnType::InvalidState; } std::string ArMemLocalStorage::commit(const std::string& segment, long sentAt, const std::vector<aron::AronDataPtr>& data, const Ice::Current&) { // Check if segment already exists - if (!hasSegment(segment)) + HasSegmentReturnType has_segment = hasSegment(segment); + if (has_segment != HasSegmentReturnType::Yes) { // Need to allocate a new storage for a new segment ARMARX_WARNING << "A new segment '" + segment + "' registered to the memory. Allocating space for its members..."; indexed_storage[segment] = IndexedDatatypeStorage(); timestamped_storage[segment] = TimestampedDataTypeStorage(); hashed_storage[segment] = HashedDataTypeStorage(); + + if (has_segment != HasSegmentReturnType::InvalidState) + { + // Otherwise we reassign the segment again. + num_segments++; + } } IndexedDatatypeStorage& indexed_segment_storage = indexed_storage[segment]; @@ -117,8 +139,8 @@ namespace armarx entryPtr->stored_in_segment = IceUtil::Time::now().toMilliSeconds(); entryPtr->data = data; - ARMARX_INFO_S << "Saving a new commit to segment '" + segment + "'"; - std::string string_to_hash = "commit_to_" + segment + "_at_" + std::to_string(now); + ARMARX_INFO << "Saving a new commit to segment '" + segment + "'"; + std::string string_to_hash = segment + "__" + std::to_string(now); size_t hash = std::hash<std::string> {}(string_to_hash); if (timestamped_segment_storage.find(now) != timestamped_segment_storage.end()) @@ -130,9 +152,13 @@ namespace armarx ARMARX_WARNING << "The segment '" + segment + "' already contains data at the commit hash " + std::to_string(hash) + ". Overwriting value!"; } + std::string hash_as_string = std::to_string(hash); + ARMARX_DEBUG << "Storing new data with hash: " << hash_as_string; indexed_segment_storage.push_back(entryPtr); timestamped_segment_storage[now] = entryPtr; hashed_segment_storage[hash] = entryPtr; + ARMARX_DEBUG << "Stored new data with hash: " << hash_as_string; + ARMARX_DEBUG << "The current segment " << segment << " now contains " << indexed_segment_storage.size() << " elements!"; return std::to_string(hash); } @@ -151,21 +177,28 @@ namespace armarx } for (const auto& [segment, datatypeStorage] : indexed_storage) { - if (!hasSegment(segment)) - { - throw LocalException("The memory is in an invalid state. Not all storages contain the segment '" + segment + "'! Please Check!"); - } + checkStorageIntegrityForSegment(segment); } } void ArMemLocalStorage::checkStorageIntegrityForSegment(const std::string& segment) const { - + HasSegmentReturnType has_segment = hasSegment(segment); + if (has_segment != HasSegmentReturnType::Yes) + { + throw LocalException("The memory is in an invalid state. Not all storages contain the segment '" + segment + "'! Please Check!"); + } } ArMemCommitPtr ArMemLocalStorage::getLatestCommitFromSegment(const std::string& segment, const Ice::Current&) { + HasSegmentReturnType has_segment = hasSegment(segment); + if (has_segment != HasSegmentReturnType::Yes) + { + return nullptr; + } + int index = indexed_storage[segment].size() - 1; if (index >= 0) { diff --git a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h index bc228dedb60910f307eb52e9cef3ee683a164b8a..bdb4533958b80a7d283a388863c375ecb5292772 100644 --- a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h +++ b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h @@ -44,6 +44,13 @@ namespace armarx virtual public armarx::armem::ArMemLocalMemoryInterface { public: + enum HasSegmentReturnType + { + Yes, + No, + InvalidState + }; + typedef std::vector<ArMemCommitPtr> IndexedDatatypeStorage; typedef std::map<long, ArMemCommitPtr> TimestampedDataTypeStorage; typedef std::map<std::size_t, ArMemCommitPtr> HashedDataTypeStorage; @@ -52,7 +59,7 @@ namespace armarx std::string getDefaultName() const override; - bool hasSegment(const std::string&) const; + HasSegmentReturnType hasSegment(const std::string&) const; long size(const std::string&) const; ArMemCommitPtr getLatestCommitFromSegment(const std::string&, const Ice::Current& = Ice::Current()); @@ -81,11 +88,11 @@ namespace armarx std::map<std::string, TimestampedDataTypeStorage> timestamped_storage; std::map<std::string, HashedDataTypeStorage> hashed_storage; - std::string hostname_to_use; + long num_segments; + std::map<std::string, long> num_entries_per_segment; long maximum_segments; long maximum_entries_per_segment; - long maximum_entries_per_datatype; }; } } diff --git a/source/RobotAPI/interface/armem.ice b/source/RobotAPI/interface/armem.ice index f5ced2684babf02ebe711b89efbe580f82f765a1..120c340992853ced3393922216ed8f855a290d24 100644 --- a/source/RobotAPI/interface/armem.ice +++ b/source/RobotAPI/interface/armem.ice @@ -13,7 +13,8 @@ module armarx string stored_in_segment; long produce_timestamp_ms; long storage_timestamp_ms; - aron::AronDataList data; + int priority; + aron::AronDataList data; // Dict?!? }; // map storageTS to commit diff --git a/source/RobotAPI/libraries/armem/ArMemBase.cpp b/source/RobotAPI/libraries/armem/ArMemBase.cpp index 5048a42d4c4a424ff509e59b6a1dc3a1ddf63494..bc67b10d9cae27ab4e6272f2cb0cdbb77b40de3d 100644 --- a/source/RobotAPI/libraries/armem/ArMemBase.cpp +++ b/source/RobotAPI/libraries/armem/ArMemBase.cpp @@ -32,7 +32,7 @@ namespace armarx ArMemBase::ArMemBase() { - my_hostname = getMyHostname(); + my_hostname = GetMyHostname(); } std::string ArMemBase::GenerateLocalMemoryObjectNameFromHostname(const std::string& hostname) diff --git a/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.cpp b/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.cpp index a327def7f088f156497861902a3f185f33e510c3..e6e578a866da7b865ca908eecab58b369d2f4390 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.cpp +++ b/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.cpp @@ -39,10 +39,11 @@ namespace armarx { namespace classwriter { - AronTypeClassCppWriter::AronTypeClassCppWriter(const std::string& producerName, const std::set<AronWriterInfo>& writers, const std::set<AronReaderInfo>& readers, const std::vector<AronUseTypeInfo>& useTypes) : + AronTypeClassCppWriter::AronTypeClassCppWriter(const std::string& producerName, const std::set<AronWriterInfo>& writers, const std::set<AronReaderInfo>& readers, const std::vector<AronUseTypeInfo>& useTypes, const std::vector<std::string>& additionalIncludesFromFile) : producerName(producerName), writers(writers), - readers(readers) + readers(readers), + additionalIncludes(additionalIncludesFromFile) { additionalIncludes.push_back("<RobotAPI/libraries/aron/codegenerator/AronCppClass.h>"); for (const auto& useType : useTypes) @@ -56,8 +57,9 @@ namespace armarx return typeClasses; } - void AronTypeClassCppWriter::generateTypeClasses(const GenerateTypePtrList& produceTypes) + void AronTypeClassCppWriter::generateTypeClasses(const GenerateTypePtrList& produceTypes, bool onlyAddHeaderInformationToFirstClass) { + bool first = true; for (const auto& [produceObj, localProduceTypes] : produceTypes) { // Convert to Object type and create class object @@ -70,17 +72,31 @@ namespace armarx c->addInherit("virtual public armarx::aron::codegeneration::AronCppClass"); // Add includes and guard - setupIncludes(c, boost::algorithm::to_upper_copy(producerName) + "__" + boost::algorithm::to_upper_copy(c->getName()) + "__ARON_TYPE_DEFINITION_INCLUDE_GUARD"); + if (!onlyAddHeaderInformationToFirstClass or first) + { + setupIncludes(c, boost::algorithm::to_upper_copy(producerName) + "__" + boost::algorithm::to_upper_copy(c->getName()) + "__ARON_TYPE_DEFINITION_INCLUDE_GUARD"); + } // setup inner classes - for(const auto& localProduceObj : localProduceTypes) + for (const auto& localProduceObj : localProduceTypes) { CppClassPtr inner = setupCppClassFromObjectType(localProduceObj); + CppMethodPtr inner_equals = localProduceObj->toEqualsMethod(); + inner->addMethod(inner_equals); c->addInnerClass(inner); } + // ctor + CppBlockPtr ctorBlock = CppBlockPtr(new CppBlock()); + ctorBlock->addLine("initialize();"); + ctorBlock->addLine("reset();"); + c->addCtor("", ctorBlock); + // Generic methods + CppMethodPtr equals = produceObj->toEqualsMethod(); + c->addMethod(equals); + CppMethodPtr reset = produceObj->toResetMethod(); c->addMethod(reset); @@ -110,6 +126,7 @@ namespace armarx } typeClasses.push_back(c); + first = false; } } @@ -120,7 +137,7 @@ namespace armarx boost::algorithm::split(split, cppTypename, boost::is_any_of("::"), boost::token_compress_on); if (split.size() < 1) { - throw LocalException("The cpp name of an inner type was empty. Please check the type definition file if all object names are set correctly."); + throw LocalException("AronTypeClassCppWriter: The cpp name of an inner type was empty. Please check the type definition file if all object names are set correctly."); } std::vector<std::string> namespaces(split); @@ -133,42 +150,23 @@ namespace armarx c->addPublicField(child->getFullCppTypename() + " " + key + ";"); } - // operator== - std::stringstream doc; - doc << "@brief operator==() - This method checks whether all values equal another instance. \n"; - doc << "@param i - The other instance\n"; - doc << "@return - true, if all members are the same, false otherwise"; - CppMethodPtr equals = CppMethodPtr(new CppMethod("bool operator==(const " + o->getFullCppTypename() + "& i) const", doc.str())); - - for (const auto& [key, child] : o->getChildren()) - { - equals->addLine("if ( not (" + key + " == i." + key + "))"); - equals->addLine(" return false;"); - } - equals->addLine("return true;"); - c->addMethod(equals); - return c; } void AronTypeClassCppWriter::setupIncludes(CppClassPtr& c, const std::string& guard) const { - c->addClassDoc("Autogenerated class. Please do not edit. Instead, edit the corresponding .xml file."); + c->addClassDoc("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + "!!!!!!AUTOGENERATED CLASS. Please do NOT edit. Instead, edit the corresponding .xml file!!!!!!\n" + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); c->setIncludeGuard(guard); c->addInclude("<string>"); c->addInclude("<vector>"); c->addInclude("<map>"); - - c->addInclude("<Eigen/Core>"); c->addInclude("<RobotAPI/interface/aron.h>"); for (const std::string& s : additionalIncludes) { c->addInclude(s); } - CppBlockPtr ctorBlock = CppBlockPtr(new CppBlock()); - ctorBlock->addLine("initialize();"); - ctorBlock->addLine("reset();"); - c->addCtor("", ctorBlock); } } } diff --git a/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.h b/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.h index 0c7098924705596571878c2cc36d7fde32d4a168..5a685d5b6b508f72b0bca359159c12b1e04fbccd 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.h +++ b/source/RobotAPI/libraries/aron/codegenerator/codeWriters/cppWriter/AronCppWriter.h @@ -58,9 +58,9 @@ namespace armarx public: typedef std::vector<std::pair<types::AronObjectTypeNavigatorPtr, std::vector<types::AronObjectTypeNavigatorPtr>>> GenerateTypePtrList; - AronTypeClassCppWriter(const std::string&, const std::set<AronWriterInfo>&, const std::set<AronReaderInfo>&, const std::vector<AronUseTypeInfo>&); + AronTypeClassCppWriter(const std::string&, const std::set<AronWriterInfo>&, const std::set<AronReaderInfo>&, const std::vector<AronUseTypeInfo>&, const std::vector<std::string>&); - void generateTypeClasses(const GenerateTypePtrList&); + void generateTypeClasses(const GenerateTypePtrList&, bool onlyAddHeaderInformationToFirstClass = false); // Todo true is not supported at the moment since the guard is missing std::vector<CppClassPtr> getTypeClasses() const; private: diff --git a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/AronAbstractTypeReader.h b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/AronAbstractTypeReader.h index 747d0331172d45953306e21d8822c7d3d62c9546..4bd28d6f385de5c41e5b3351da6656139ad4aa5e 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/AronAbstractTypeReader.h +++ b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/AronAbstractTypeReader.h @@ -74,6 +74,10 @@ namespace armarx virtual void parseFile(const std::string& filename) = 0; virtual void parseFile(const std::filesystem::path& file) = 0; + std::vector<std::string> getAdditionalIncludes() const + { + return additionalIncludes; + } std::set<AronWriterInfo> getWriters() const { return writers; @@ -93,6 +97,7 @@ namespace armarx } protected: + std::vector<std::string> additionalIncludes; std::set<AronReaderInfo> readers; std::set<AronWriterInfo> writers; std::vector<AronUseTypeInfo> useTypes; diff --git a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.cpp b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.cpp index 689acfd6d31b424d53e8a30fe15dbe815e60f558..1fde262fd82f14f710a168908ce415618f97e832 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.cpp +++ b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.cpp @@ -44,38 +44,36 @@ namespace armarx { const std::string AronAbstractTypeXMLReaderData::ARON_TYPE_DEFINITION_TAG = "arontypedefinition"; + const std::string AronAbstractTypeXMLReaderData::ARON_INCLUDES_TAG = "includes"; const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZERS_TAG = "serializers"; const std::string AronAbstractTypeXMLReaderData::ARON_USE_TYPES_TAG = "usetypes"; const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_TYPES_TAG = "generatetypes"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_WRITERS_TAG = "writers"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_READERS_TAG = "readers"; + const std::string AronAbstractTypeXMLReaderData::ARON_INCLUDE_TAG = "include"; + const std::string AronAbstractTypeXMLReaderData::ARON_WRITERS_TAG = "writers"; + const std::string AronAbstractTypeXMLReaderData::ARON_READERS_TAG = "readers"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_WRITER_TAG = "writer"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_READER_TAG = "reader"; + const std::string AronAbstractTypeXMLReaderData::ARON_WRITER_TAG = "writer"; + const std::string AronAbstractTypeXMLReaderData::ARON_READER_TAG = "reader"; const std::string AronAbstractTypeXMLReaderData::ARON_USE_TYPE_TAG = "usetype"; const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_TYPE_TAG = "generatetype"; - const std::string AronAbstractTypeXMLReaderData::ARON_USE_TYPE_INCLUDE_ATTRIBUTE_NAME = "include"; - const std::string AronAbstractTypeXMLReaderData::ARON_USE_TYPE_NAME_ATTRIBUTE_NAME = "name"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ATTRIBUTE_NAME = "method"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_RETURN_ATTRIBUTE_NAME = "return"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ARGUMENT_ATTRIBUTE_NAME = "argumenttype"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_WRITER_NAME_ATTRIBUTE_NAME = "writer"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_READER_NAME_ATTRIBUTE_NAME = "reader"; - const std::string AronAbstractTypeXMLReaderData::ARON_SERIALIZER_INCLUDE_ATTRIBUTE_NAME = "include"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_EXTERNAL_NAME_ATTRIBUTE_NAME = "name"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_NAME_ATTRIBUTE_NAME = "name"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_TYPE_ATTRIBUTE_NAME = "type"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_CHILD_KEY_ATTRIBUTE_NAME = "key"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_LIST_TYPE_ATTRIBUTE_NAME = "listtype"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_DICT_TYPE_ATTRIBUTE_NAME = "dicttype"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_TUPLE_TYPE_ATTRIBUTE_NAME = "tupletype"; - - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_CHILD_TAG = "objectchild"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_LIST_TYPE_TAG = "listtype"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_DICT_TYPE_TAG = "dicttype"; - const std::string AronAbstractTypeXMLReaderData::ARON_PRODUCE_TUPLE_TYPE_TAG = "tupletype"; + const std::string AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME = "include"; + const std::string AronAbstractTypeXMLReaderData::ARON_METHOD_ATTRIBUTE_NAME = "method"; + const std::string AronAbstractTypeXMLReaderData::ARON_RETURN_ATTRIBUTE_NAME = "return"; + const std::string AronAbstractTypeXMLReaderData::ARON_ARGUMENT_TYPE_ATTRIBUTE_NAME = "argumenttype"; + const std::string AronAbstractTypeXMLReaderData::ARON_WRITER_ATTRIBUTE_NAME = "writer"; + const std::string AronAbstractTypeXMLReaderData::ARON_READER_ATTRIBUTE_NAME = "reader"; + const std::string AronAbstractTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME = "name"; + const std::string AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME = "type"; + const std::string AronAbstractTypeXMLReaderData::ARON_KEY_ATTRIBUTE_NAME = "key"; + const std::string AronAbstractTypeXMLReaderData::ARON_WIDTH_ATTRIBUTE_NAME = "width"; + const std::string AronAbstractTypeXMLReaderData::ARON_HEIGHT_ATTRIBUTE_NAME = "height"; + + const std::string AronAbstractTypeXMLReaderData::ARON_OBJECT_CHILD_TAG = "objectchild"; + const std::string AronAbstractTypeXMLReaderData::ARON_TYPE_TAG = "type"; + const std::string AronAbstractTypeXMLReaderData::ARON_DIMENSIONS_TAG = "dimensions"; + const std::string AronAbstractTypeXMLReaderData::ARON_DIMENSION_TAG = "dimension"; // Top Level type tags #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ @@ -84,34 +82,55 @@ namespace armarx HANDLE_ALL_ARON_TYPES_WITHOUT_CPP_TYPE #undef RUN_ARON_MACRO - void AronAbstractTypeXMLReaderData::CheckAttribute(const RapidXmlReaderNode& node, const std::string& att) + void AronAbstractTypeXMLReaderData::EnforceAttribute(const RapidXmlReaderNode& node, const std::string& att) { - if (!node.has_attribute(att.c_str())) + if (!AronAbstractTypeXMLReaderData::HasAttribute(node, att)) { - throw LocalException("A <" + node.name() + ">-tag does not have the correct attribute. Expected: " + att); + throw LocalException("AronAbstractTypeXMLReaderData: A <" + node.name() + ">-tag does not have the correct attribute. Expected: " + att); } } + bool AronAbstractTypeXMLReaderData::HasAttribute(const RapidXmlReaderNode& node, const std::string& att) + { + return node.has_attribute(att.c_str()); + } + bool AronAbstractTypeXMLReaderData::HasTagName(const RapidXmlReaderNode& node, const std::string& name) { return (boost::algorithm::to_lower_copy(name) == boost::algorithm::to_lower_copy(node.name())); } - void AronAbstractTypeXMLReaderData::CheckTagName(const RapidXmlReaderNode& node, const std::string& name) + void AronAbstractTypeXMLReaderData::EnforceTagName(const RapidXmlReaderNode& node, const std::string& name) { if (!(HasTagName(node, name))) { - throw LocalException("The node <" + node.name() + "> has the wrong tag. Expected: <" + name + ">"); + throw LocalException("AronAbstractTypeXMLReaderData: The node <" + node.name() + "> has the wrong tag. Expected: <" + name + ">"); } + } + bool AronAbstractTypeXMLReaderData::CheckMinChildSize(const RapidXmlReaderNode& node, const size_t size) + { + std::vector<RapidXmlReaderNode> children = node.nodes(); + return children.size() >= size; } - void AronAbstractTypeXMLReaderData::CheckChildSize(const RapidXmlReaderNode& node, const size_t size) + bool AronAbstractTypeXMLReaderData::CheckMaxChildSize(const RapidXmlReaderNode& node, const size_t size) { std::vector<RapidXmlReaderNode> children = node.nodes(); - if (children.size() != size) + return children.size() <= size; + } + + bool AronAbstractTypeXMLReaderData::CheckExactChildSize(const RapidXmlReaderNode& node, const size_t size) + { + std::vector<RapidXmlReaderNode> children = node.nodes(); + return children.size() == size; + } + + void AronAbstractTypeXMLReaderData::EnforceChildSize(const RapidXmlReaderNode& node, const size_t size) + { + if (!AronAbstractTypeXMLReaderData::CheckExactChildSize(node, size)) { - throw LocalException("The node <" + node.name() + "> can only have exactly " + std::to_string(size) + " children. Found " + std::to_string(children.size()) + "."); + throw LocalException("AronAbstractTypeXMLReaderData: The node <" + node.name() + "> has the wrong number of children. Expected: " + std::to_string(size) + " children but it has: " + std::to_string(node.nodes().size()) + "."); } } } diff --git a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.h b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.h index 0b37d9c998c2f02a6a2eb65f46cb3057606f0182..79d1705fe742f15d624461e3e88d08bdecf7e631 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.h +++ b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLData.h @@ -52,40 +52,38 @@ namespace armarx // Definition tags const static std::string ARON_TYPE_DEFINITION_TAG; + const static std::string ARON_INCLUDES_TAG; const static std::string ARON_SERIALIZERS_TAG; const static std::string ARON_USE_TYPES_TAG; const static std::string ARON_PRODUCE_TYPES_TAG; - const static std::string ARON_SERIALIZER_WRITERS_TAG; - const static std::string ARON_SERIALIZER_READERS_TAG; + const static std::string ARON_INCLUDE_TAG; + const static std::string ARON_WRITERS_TAG; + const static std::string ARON_READERS_TAG; - const static std::string ARON_SERIALIZER_WRITER_TAG; - const static std::string ARON_SERIALIZER_READER_TAG; + const static std::string ARON_WRITER_TAG; + const static std::string ARON_READER_TAG; const static std::string ARON_USE_TYPE_TAG; const static std::string ARON_PRODUCE_TYPE_TAG; // Attribute names - const static std::string ARON_SERIALIZER_METHOD_ATTRIBUTE_NAME; - const static std::string ARON_SERIALIZER_METHOD_RETURN_ATTRIBUTE_NAME; - const static std::string ARON_SERIALIZER_METHOD_ARGUMENT_ATTRIBUTE_NAME; - const static std::string ARON_SERIALIZER_WRITER_NAME_ATTRIBUTE_NAME; - const static std::string ARON_SERIALIZER_READER_NAME_ATTRIBUTE_NAME; - const static std::string ARON_SERIALIZER_INCLUDE_ATTRIBUTE_NAME; - const static std::string ARON_USE_TYPE_INCLUDE_ATTRIBUTE_NAME; - const static std::string ARON_USE_TYPE_NAME_ATTRIBUTE_NAME; - const static std::string ARON_PRODUCE_EXTERNAL_NAME_ATTRIBUTE_NAME; - const static std::string ARON_PRODUCE_OBJECT_NAME_ATTRIBUTE_NAME; - const static std::string ARON_PRODUCE_OBJECT_TYPE_ATTRIBUTE_NAME; - const static std::string ARON_PRODUCE_OBJECT_CHILD_KEY_ATTRIBUTE_NAME; - const static std::string ARON_PRODUCE_LIST_TYPE_ATTRIBUTE_NAME; - const static std::string ARON_PRODUCE_DICT_TYPE_ATTRIBUTE_NAME; - const static std::string ARON_PRODUCE_TUPLE_TYPE_ATTRIBUTE_NAME; + const static std::string ARON_METHOD_ATTRIBUTE_NAME; + const static std::string ARON_RETURN_ATTRIBUTE_NAME; + const static std::string ARON_ARGUMENT_TYPE_ATTRIBUTE_NAME; + const static std::string ARON_INCLUDE_ATTRIBUTE_NAME; + const static std::string ARON_READER_ATTRIBUTE_NAME; + const static std::string ARON_WRITER_ATTRIBUTE_NAME; + const static std::string ARON_NAME_ATTRIBUTE_NAME; + const static std::string ARON_KEY_ATTRIBUTE_NAME; + const static std::string ARON_TYPE_ATTRIBUTE_NAME; + const static std::string ARON_WIDTH_ATTRIBUTE_NAME; + const static std::string ARON_HEIGHT_ATTRIBUTE_NAME; // Second level tags. Only important if in specific top level tag - const static std::string ARON_PRODUCE_OBJECT_CHILD_TAG; - const static std::string ARON_PRODUCE_LIST_TYPE_TAG; - const static std::string ARON_PRODUCE_DICT_TYPE_TAG; - const static std::string ARON_PRODUCE_TUPLE_TYPE_TAG; + const static std::string ARON_OBJECT_CHILD_TAG; + const static std::string ARON_TYPE_TAG; + const static std::string ARON_DIMENSIONS_TAG; + const static std::string ARON_DIMENSION_TAG; // Top Level type tags #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ @@ -94,10 +92,14 @@ namespace armarx HANDLE_ALL_ARON_TYPES_WITHOUT_CPP_TYPE #undef RUN_ARON_MACRO - static void CheckAttribute(const RapidXmlReaderNode& node, const std::string& att); + static void EnforceAttribute(const RapidXmlReaderNode& node, const std::string& att); + static bool HasAttribute(const RapidXmlReaderNode& node, const std::string& att); static bool HasTagName(const RapidXmlReaderNode& node, const std::string& name); - static void CheckTagName(const RapidXmlReaderNode& node, const std::string& name); - static void CheckChildSize(const RapidXmlReaderNode& node, const size_t size); + static void EnforceTagName(const RapidXmlReaderNode& node, const std::string& name); + static bool CheckMinChildSize(const RapidXmlReaderNode& node, const size_t size); + static bool CheckMaxChildSize(const RapidXmlReaderNode& node, const size_t size); + static bool CheckExactChildSize(const RapidXmlReaderNode& node, const size_t size); + static void EnforceChildSize(const RapidXmlReaderNode& node, const size_t size); }; } } diff --git a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.cpp b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.cpp index 9667584ebd658df1cb7f60ed9dc031a0684a93ec..834495b6c2c06fd51c562b9d451345b878e62f78 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.cpp +++ b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.cpp @@ -67,67 +67,180 @@ namespace armarx RapidXmlReaderNode root = reader->getRoot(); // Check Header - AronAbstractTypeXMLReaderData::CheckTagName(root, AronAbstractTypeXMLReaderData::ARON_TYPE_DEFINITION_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(root, AronAbstractTypeXMLReaderData::ARON_TYPE_DEFINITION_TAG); - AronAbstractTypeXMLReaderData::CheckChildSize(root, 3); + AronAbstractTypeXMLReaderData::CheckMaxChildSize(root, 4); std::vector<RapidXmlReaderNode> children = root.nodes(); - AronAbstractTypeXMLReaderData::CheckTagName(children[0], AronAbstractTypeXMLReaderData::ARON_SERIALIZERS_TAG); - AronAbstractTypeXMLReaderData::CheckTagName(children[1], AronAbstractTypeXMLReaderData::ARON_USE_TYPES_TAG); - AronAbstractTypeXMLReaderData::CheckTagName(children[2], AronAbstractTypeXMLReaderData::ARON_PRODUCE_TYPES_TAG); + int includes_index = -1; + int serializers_index = -1; + int use_types_index = -1; + int produce_types_index = -1; - // Check Serializers - AronAbstractTypeXMLReaderData::CheckChildSize(children[0], 2); - std::vector<RapidXmlReaderNode> serializers = children[0].nodes(); - AronAbstractTypeXMLReaderData::CheckTagName(serializers[0], AronAbstractTypeXMLReaderData::ARON_SERIALIZER_WRITERS_TAG); - AronAbstractTypeXMLReaderData::CheckTagName(serializers[1], AronAbstractTypeXMLReaderData::ARON_SERIALIZER_READERS_TAG); - - for (const auto& serializer : serializers[0].nodes()) + int index = 0; + for (const auto& child : children) { - this->writers.insert(readWriter(serializer)); + if (AronAbstractTypeXMLReaderData::HasTagName(child, AronAbstractTypeXMLReaderData::ARON_INCLUDES_TAG)) + { + if (includes_index != -1) + { + throw LocalException("AronAbstractTypeXMLReader: Already found an include tag. Please check the xml file."); + } + else + { + includes_index = index; + } + } + else if (AronAbstractTypeXMLReaderData::HasTagName(child, AronAbstractTypeXMLReaderData::ARON_SERIALIZERS_TAG)) + { + if (serializers_index != -1) + { + throw LocalException("AronAbstractTypeXMLReader: Already found a serializers tag. Please check the xml file."); + } + else + { + serializers_index = index; + } + } + else if (AronAbstractTypeXMLReaderData::HasTagName(child, AronAbstractTypeXMLReaderData::ARON_USE_TYPES_TAG)) + { + if (use_types_index != -1) + { + throw LocalException("AronAbstractTypeXMLReader: Already found an use type tag. Please check the xml file."); + } + else + { + use_types_index = index; + } + } + else if (AronAbstractTypeXMLReaderData::HasTagName(child, AronAbstractTypeXMLReaderData::ARON_PRODUCE_TYPES_TAG)) + { + if (produce_types_index != -1) + { + throw LocalException("AronAbstractTypeXMLReader: Already found an generate type tag. Please check the xml file."); + } + else + { + produce_types_index = index; + } + } + index++; } - for (const auto& serializer : serializers[1].nodes()) + + // 1. Check includes + if (includes_index != -1) { - this->readers.insert(readReader(serializer)); + std::vector<RapidXmlReaderNode> includes = children[includes_index].nodes(); + for (const auto& include : includes) + { + this->additionalIncludes.push_back(readInclude(include)); + } } - // Check UseTypes - for (const auto& receiveType : children[1].nodes()) + // 2. Check Serializers + if (serializers_index != -1) { - this->useTypes.push_back(readUseType(receiveType)); + AronAbstractTypeXMLReaderData::CheckMaxChildSize(children[serializers_index], 2); + std::vector<RapidXmlReaderNode> serializers = children[serializers_index].nodes(); + + int writers_index = -1; + int readers_index = -1; + + index = 0; + for (const auto& serializer : serializers) + { + if (AronAbstractTypeXMLReaderData::HasTagName(serializer, AronAbstractTypeXMLReaderData::ARON_WRITERS_TAG)) + { + if (writers_index != -1) + { + throw LocalException("AronAbstractTypeXMLReader: Already found an writers tag. Please check the xml file."); + } + else + { + writers_index = index; + } + } + else if (AronAbstractTypeXMLReaderData::HasTagName(serializer, AronAbstractTypeXMLReaderData::ARON_READERS_TAG)) + { + if (readers_index != -1) + { + throw LocalException("AronAbstractTypeXMLReader: Already found a readers tag. Please check the xml file."); + } + else + { + readers_index = index; + } + } + index++; + } + + if (writers_index != -1) + { + for (const auto& serializer : serializers[writers_index].nodes()) + { + this->writers.insert(readWriter(serializer)); + } + } + if (readers_index != -1) + { + for (const auto& serializer : serializers[readers_index].nodes()) + { + this->readers.insert(readReader(serializer)); + } + } } - // Add UseTypes to Factory - std::vector<std::string> useObjectNames; - for (const auto& useType : useTypes) + // 3. Check UseTypes + if (use_types_index != -1) { - useObjectNames.push_back(useType.typeName); + for (const auto& receiveType : children[use_types_index].nodes()) + { + this->useTypes.push_back(readUseType(receiveType)); + } + + // Add UseTypes to Factory + std::vector<std::string> useObjectNames; + for (const auto& useType : useTypes) + { + useObjectNames.push_back(useType.typeName); + } + Factory.AddTopLevelObjectNames(useObjectNames); } - Factory.AddTopLevelObjectNames(useObjectNames); - // Check ProduceTypes - for (const auto& produceType : children[2].nodes()) + // 4. Check ProduceTypes + if (produce_types_index != -1) { - readGenerateType(produceType); + for (const auto& produceType : children[produce_types_index].nodes()) + { + readGenerateType(produceType); + } + generateTypes = Factory.GetAllProducedTopLevelObjects(); } - generateTypes = Factory.GetAllProducedTopLevelObjects(); + } + + std::string AronAbstractTypeXMLReader::readInclude(const RapidXmlReaderNode& node) const + { + AronAbstractTypeXMLReaderData::EnforceTagName(node, AronAbstractTypeXMLReaderData::ARON_INCLUDE_TAG); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME); + const std::string include = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME.c_str()); + return include; } AronWriterInfo AronAbstractTypeXMLReader::readWriter(const RapidXmlReaderNode& node) const { - AronAbstractTypeXMLReaderData::CheckTagName(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_WRITER_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(node, AronAbstractTypeXMLReaderData::ARON_WRITER_TAG); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ATTRIBUTE_NAME); - const std::string methodname = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_METHOD_ATTRIBUTE_NAME); + const std::string methodname = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_METHOD_ATTRIBUTE_NAME.c_str()); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_RETURN_ATTRIBUTE_NAME); - const std::string returntype = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_RETURN_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_RETURN_ATTRIBUTE_NAME); + const std::string returntype = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_RETURN_ATTRIBUTE_NAME.c_str()); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_WRITER_NAME_ATTRIBUTE_NAME); - const std::string writer = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_WRITER_NAME_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_WRITER_ATTRIBUTE_NAME); + const std::string writer = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_WRITER_ATTRIBUTE_NAME.c_str()); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_INCLUDE_ATTRIBUTE_NAME); - const std::string include = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_INCLUDE_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME); + const std::string include = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME.c_str()); AronWriterInfo info; info.methodName = methodname; @@ -140,19 +253,19 @@ namespace armarx AronReaderInfo AronAbstractTypeXMLReader::readReader(const RapidXmlReaderNode& node) const { - AronAbstractTypeXMLReaderData::CheckTagName(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_READER_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(node, AronAbstractTypeXMLReaderData::ARON_READER_TAG); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ATTRIBUTE_NAME); - const std::string methodname = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_METHOD_ATTRIBUTE_NAME); + const std::string methodname = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_METHOD_ATTRIBUTE_NAME.c_str()); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ARGUMENT_ATTRIBUTE_NAME); - const std::string returntype = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_METHOD_ARGUMENT_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_ARGUMENT_TYPE_ATTRIBUTE_NAME); + const std::string returntype = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_ARGUMENT_TYPE_ATTRIBUTE_NAME.c_str()); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_READER_NAME_ATTRIBUTE_NAME); - const std::string reader = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_READER_NAME_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_READER_ATTRIBUTE_NAME); + const std::string reader = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_READER_ATTRIBUTE_NAME.c_str()); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_SERIALIZER_INCLUDE_ATTRIBUTE_NAME); - const std::string include = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_SERIALIZER_INCLUDE_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME); + const std::string include = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME.c_str()); AronReaderInfo info; info.methodName = methodname; @@ -165,13 +278,13 @@ namespace armarx AronUseTypeInfo AronAbstractTypeXMLReader::readUseType(const RapidXmlReaderNode& node) const { - AronAbstractTypeXMLReaderData::CheckTagName(node, AronAbstractTypeXMLReaderData::ARON_USE_TYPE_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(node, AronAbstractTypeXMLReaderData::ARON_USE_TYPE_TAG); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_USE_TYPE_INCLUDE_ATTRIBUTE_NAME); - const std::string include = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_USE_TYPE_INCLUDE_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME); + const std::string include = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_INCLUDE_ATTRIBUTE_NAME.c_str()); - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_USE_TYPE_NAME_ATTRIBUTE_NAME); - const std::string name = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_USE_TYPE_NAME_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME); + const std::string name = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME.c_str()); AronUseTypeInfo info; info.typeName = name; @@ -182,7 +295,7 @@ namespace armarx types::AronObjectTypeNavigatorPtr AronAbstractTypeXMLReader::readGenerateType(const RapidXmlReaderNode& node) const { - AronAbstractTypeXMLReaderData::CheckTagName(node, AronAbstractTypeXMLReaderData::ARON_PRODUCE_TYPE_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(node, AronAbstractTypeXMLReaderData::ARON_PRODUCE_TYPE_TAG); return types::AronObjectTypeNavigator::DynamicCast(Factory.createSpecific(node, AronNavigatorPath())); } } diff --git a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.h b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.h index 2b4186f7d0d3c02ecc4cf701586d30bf082dc693..aceb7e51b023f5443e9130ece8829dc32068ffd8 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.h +++ b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReader.h @@ -60,6 +60,7 @@ namespace armarx private: void parse(const RapidXmlReaderPtr& node); + std::string readInclude(const RapidXmlReaderNode& node) const; AronWriterInfo readWriter(const RapidXmlReaderNode& node) const; AronReaderInfo readReader(const RapidXmlReaderNode& node) const; AronUseTypeInfo readUseType(const RapidXmlReaderNode& node) const; diff --git a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.cpp b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.cpp index 1d7452b590c0aaf30b58fadf5957562f07b28c12..08c961c3a8f70062e0457def4a1a0002f58811b2 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.cpp +++ b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.cpp @@ -55,7 +55,7 @@ namespace armarx HANDLE_CONTAINER_TYPES HANDLE_EXTERNAL_TYPES - //HANDLE_COMPLEX_TYPES + HANDLE_COMPLEX_TYPES #undef RUN_ARON_MACRO @@ -103,8 +103,8 @@ namespace armarx // External types::AronAbstractTypeNavigatorPtr AronExternalTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const { - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_PRODUCE_EXTERNAL_NAME_ATTRIBUTE_NAME); - const std::string name = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_PRODUCE_EXTERNAL_NAME_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME); + const std::string name = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME.c_str()); // check whether type exists for (const auto& [x, _] : AllTopLevelObjectNames) @@ -129,8 +129,8 @@ namespace armarx // Object types::AronAbstractTypeNavigatorPtr AronObjectTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const { - AronAbstractTypeXMLReaderData::CheckAttribute(node, AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_NAME_ATTRIBUTE_NAME); - const std::string name = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_NAME_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME); + const std::string name = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME.c_str()); if (AronAbstractTypeXMLReaderData::HasTagName(node, AronAbstractTypeXMLReaderData::ARON_PRODUCE_TYPE_TAG)) { @@ -149,11 +149,11 @@ namespace armarx for (const RapidXmlReaderNode& objectChild : node.nodes()) { - AronAbstractTypeXMLReaderData::CheckTagName(objectChild, AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_CHILD_TAG); - AronAbstractTypeXMLReaderData::CheckChildSize(objectChild, 1); + AronAbstractTypeXMLReaderData::EnforceTagName(objectChild, AronAbstractTypeXMLReaderData::ARON_OBJECT_CHILD_TAG); + AronAbstractTypeXMLReaderData::EnforceChildSize(objectChild, 1); - AronAbstractTypeXMLReaderData::CheckAttribute(objectChild, AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_CHILD_KEY_ATTRIBUTE_NAME); - const std::string key = objectChild.attribute_value(AronAbstractTypeXMLReaderData::ARON_PRODUCE_OBJECT_CHILD_KEY_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceAttribute(objectChild, AronAbstractTypeXMLReaderData::ARON_KEY_ATTRIBUTE_NAME); + const std::string key = objectChild.attribute_value(AronAbstractTypeXMLReaderData::ARON_KEY_ATTRIBUTE_NAME.c_str()); std::vector<RapidXmlReaderNode> children = objectChild.nodes(); types::AronAbstractTypeNavigatorPtr childNavigator = create(children[0], AronNavigatorPath(path, key)); @@ -176,25 +176,25 @@ namespace armarx return aronObjectType; } - // List + // List type (List) types::AronAbstractTypeNavigatorPtr AronListTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const { - if (node.has_attribute(AronAbstractTypeXMLReaderData::ARON_PRODUCE_LIST_TYPE_ATTRIBUTE_NAME.c_str())) + if (node.has_attribute(AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME.c_str())) { - AronAbstractTypeXMLReaderData::CheckChildSize(node, 0); - const std::string acceptedType = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_PRODUCE_LIST_TYPE_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceChildSize(node, 0); + const std::string acceptedType = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME.c_str()); return types::AronAbstractTypeNavigator::GetAronAbstractTypePtrByName(acceptedType); } else { - AronAbstractTypeXMLReaderData::CheckChildSize(node, 1); + AronAbstractTypeXMLReaderData::EnforceChildSize(node, 1); std::vector<RapidXmlReaderNode> nodeChildren = node.nodes(); const RapidXmlReaderNode listTypeDeclarationNode = nodeChildren[0]; - AronAbstractTypeXMLReaderData::CheckTagName(listTypeDeclarationNode, AronAbstractTypeXMLReaderData::ARON_PRODUCE_LIST_TYPE_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(listTypeDeclarationNode, AronAbstractTypeXMLReaderData::ARON_TYPE_TAG); - AronAbstractTypeXMLReaderData::CheckChildSize(listTypeDeclarationNode, 1); + AronAbstractTypeXMLReaderData::EnforceChildSize(listTypeDeclarationNode, 1); std::vector<RapidXmlReaderNode> listTypeNodeChildren = listTypeDeclarationNode.nodes(); const RapidXmlReaderNode typeNode = listTypeNodeChildren[0]; types::AronAbstractTypeNavigatorPtr type = create(typeNode, AronNavigatorPath(path, "type")); @@ -203,24 +203,24 @@ namespace armarx } } - // Dict + // List type (Dict) types::AronAbstractTypeNavigatorPtr AronDictTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const { - AronAbstractTypeXMLReaderData::CheckChildSize(node, 1); + AronAbstractTypeXMLReaderData::EnforceChildSize(node, 1); std::vector<RapidXmlReaderNode> nodeChildren = node.nodes(); const RapidXmlReaderNode dictTypeDeclarationNode = nodeChildren[0]; - if (dictTypeDeclarationNode.has_attribute(AronAbstractTypeXMLReaderData::ARON_PRODUCE_DICT_TYPE_ATTRIBUTE_NAME.c_str())) + if (dictTypeDeclarationNode.has_attribute(AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME.c_str())) { - AronAbstractTypeXMLReaderData::CheckChildSize(dictTypeDeclarationNode, 0); - const std::string acceptedType = dictTypeDeclarationNode.attribute_value(AronAbstractTypeXMLReaderData::ARON_PRODUCE_DICT_TYPE_ATTRIBUTE_NAME.c_str()); + AronAbstractTypeXMLReaderData::EnforceChildSize(dictTypeDeclarationNode, 0); + const std::string acceptedType = dictTypeDeclarationNode.attribute_value(AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME.c_str()); return types::AronAbstractTypeNavigator::GetAronAbstractTypePtrByName(acceptedType); } else { - AronAbstractTypeXMLReaderData::CheckTagName(dictTypeDeclarationNode, AronAbstractTypeXMLReaderData::ARON_PRODUCE_DICT_TYPE_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(dictTypeDeclarationNode, AronAbstractTypeXMLReaderData::ARON_TYPE_TAG); - AronAbstractTypeXMLReaderData::CheckChildSize(dictTypeDeclarationNode, 1); + AronAbstractTypeXMLReaderData::EnforceChildSize(dictTypeDeclarationNode, 1); std::vector<RapidXmlReaderNode> dictTypeNodeChildren = dictTypeDeclarationNode.nodes(); const RapidXmlReaderNode typeNode = dictTypeNodeChildren[0]; types::AronAbstractTypeNavigatorPtr type = create(typeNode, AronNavigatorPath(path, "type")); @@ -228,7 +228,7 @@ namespace armarx } } - // Tuple + // List types (Tuple) types::AronAbstractTypeNavigatorPtr AronTupleTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const { std::vector<types::AronAbstractTypeNavigatorPtr> types; @@ -242,18 +242,18 @@ namespace armarx unsigned int i = 0; for (const RapidXmlReaderNode& tupleTypeDeclarationNode : nodeChildren) { - AronAbstractTypeXMLReaderData::CheckTagName(tupleTypeDeclarationNode, AronAbstractTypeXMLReaderData::ARON_PRODUCE_TUPLE_TYPE_TAG); + AronAbstractTypeXMLReaderData::EnforceTagName(tupleTypeDeclarationNode, AronAbstractTypeXMLReaderData::ARON_TYPE_TAG); - if (tupleTypeDeclarationNode.has_attribute(AronAbstractTypeXMLReaderData::ARON_PRODUCE_TUPLE_TYPE_ATTRIBUTE_NAME.c_str())) + if (tupleTypeDeclarationNode.has_attribute(AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME.c_str())) { - AronAbstractTypeXMLReaderData::CheckChildSize(tupleTypeDeclarationNode, 0); + AronAbstractTypeXMLReaderData::EnforceChildSize(tupleTypeDeclarationNode, 0); - const std::string typeName = tupleTypeDeclarationNode.attribute_value(AronAbstractTypeXMLReaderData::ARON_PRODUCE_TUPLE_TYPE_ATTRIBUTE_NAME.c_str()); + const std::string typeName = tupleTypeDeclarationNode.attribute_value(AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME.c_str()); types::AronAbstractTypeNavigatorPtr type = types::AronAbstractTypeNavigator::GetAronAbstractTypePtrByName(typeName); } else { - AronAbstractTypeXMLReaderData::CheckChildSize(tupleTypeDeclarationNode, 1); + AronAbstractTypeXMLReaderData::EnforceChildSize(tupleTypeDeclarationNode, 1); std::vector<RapidXmlReaderNode> typeNodeChildren = tupleTypeDeclarationNode.nodes(); const RapidXmlReaderNode typeNode = typeNodeChildren[0]; @@ -265,13 +265,38 @@ namespace armarx return types::AronAbstractTypeNavigatorPtr(new types::AronTupleTypeNavigator(types, path)); } - // Blob - /*types::AronAbstractTypeNavigatorPtr AronBlobTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const + // Complex type (IVTCByteImage) + types::AronAbstractTypeNavigatorPtr AronIVTCByteImageTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const { - AronAbstractTypeXMLReaderData::checkChildSize(node, 0); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_WIDTH_ATTRIBUTE_NAME); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_HEIGHT_ATTRIBUTE_NAME); + AronAbstractTypeXMLReaderData::EnforceAttribute(node, AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME); - return types::AronAbstractTypeNavigatorPtr(new types::AronBlobTypeNavigator("TODO", path)); - }*/ + int width = std::stoi(node.attribute_value(AronAbstractTypeXMLReaderData::ARON_WIDTH_ATTRIBUTE_NAME.c_str())); + int height = std::stoi(node.attribute_value(AronAbstractTypeXMLReaderData::ARON_HEIGHT_ATTRIBUTE_NAME.c_str())); + std::string type = node.attribute_value(AronAbstractTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME.c_str());; + + + return types::AronAbstractTypeNavigatorPtr(new types::AronIVTCByteImageTypeNavigator(width, height, type, path)); + } + + // Complex type (EigenMatrix) + types::AronAbstractTypeNavigatorPtr AronEigenMatrixTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const + { + throw LocalException("AronTupleTypeXMLReaderFactory: Not implemented yet."); + } + + // Complex type (OpenCVMat) + types::AronAbstractTypeNavigatorPtr AronOpenCVMatTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const + { + throw LocalException("AronTupleTypeXMLReaderFactory: Not implemented yet."); + } + + // Complex type (PCLPointcloud) + types::AronAbstractTypeNavigatorPtr AronPCLPointcloudTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronNavigatorPath& path) const + { + throw LocalException("AronTupleTypeXMLReaderFactory: Not implemented yet."); + } } } } diff --git a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.h b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.h index a5797edc87fda519976797070a9b615d1ac7fa91..7f6f7750b6c72ef7e06c62301ff7a289bd54a975 100644 --- a/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.h +++ b/source/RobotAPI/libraries/aron/codegenerator/typeReaders/xmlReader/AronAbstractTypeXMLReaderFactory.h @@ -84,6 +84,7 @@ namespace armarx HANDLE_CONTAINER_TYPES HANDLE_EXTERNAL_TYPES + HANDLE_COMPLEX_TYPES #undef RUN_ARON_MACRO diff --git a/source/RobotAPI/libraries/aron/data/AronDataNavigatorFactory.cpp b/source/RobotAPI/libraries/aron/data/AronDataNavigatorFactory.cpp index 8f259df8678d7e2f398dc30dedf858d314a6dd86..73ec25e4f0faf328204aff1a49a601bbdb91285c 100644 --- a/source/RobotAPI/libraries/aron/data/AronDataNavigatorFactory.cpp +++ b/source/RobotAPI/libraries/aron/data/AronDataNavigatorFactory.cpp @@ -44,11 +44,11 @@ namespace armarx HANDLE_CONTAINER_DATA #undef RUN_ARON_MACRO - /*#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - {AronTypeResolver::GetTypeForAronDataTypeId(typeid(Aron##upperType##Type)), AronDataNavigatorFactoryPtrnew Aron##upperType##TypeNavigatorFactory())}, \ +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + {AronResolver::GetTypeForAronDataTypeId(typeid(Aron##upperType)), AronDataNavigatorFactoryPtr(new Aron##upperType##DataNavigatorFactory())}, \ - HANDLE_COMPLEX_DATA - #undef RUN_ARON_MACRO*/ + HANDLE_COMPLEX_DATA +#undef RUN_ARON_MACRO #define RUN_ARON_MACRO(cppType, upperType, lowerType, capsType) \ {AronResolver::GetTypeForAronDataTypeId(typeid(Aron##upperType)), AronDataNavigatorFactoryPtr(new AronPrimitiveDataNavigatorFactory<Aron##upperType, cppType>())}, \ diff --git a/source/RobotAPI/libraries/aron/data/AronDictDataNavigator.cpp b/source/RobotAPI/libraries/aron/data/AronDictDataNavigator.cpp index 503d257c3b07e863d106fa4794b740bce70a96b5..f5bcde3b561e18bc24206918fd65f7dfeed358fb 100644 --- a/source/RobotAPI/libraries/aron/data/AronDictDataNavigator.cpp +++ b/source/RobotAPI/libraries/aron/data/AronDictDataNavigator.cpp @@ -87,7 +87,12 @@ namespace armarx auto it = childrenNavigators.find(key); if (it == childrenNavigators.end()) { - throw LocalException("AronDictDataNavigator: Could not find key '" + key + "'. The path was: " + pathToString()); + std::string all_keys = ""; + for (const auto& child : this->getAllKeys()) + { + all_keys += child + ", "; + } + throw LocalException("AronDictDataNavigator: Could not find key '" + key + "'. Found keys: " + all_keys + ". The path was: " + pathToString()); } return it->second; } diff --git a/source/RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.cpp b/source/RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.cpp index 0d17764e02dd6806b4fd560783b71cd9b722e37f..f2f2cca69d28d1462b5f5e448de8e9f4970b164e 100644 --- a/source/RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.cpp +++ b/source/RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.cpp @@ -122,6 +122,7 @@ namespace armarx AronDataNavigatorReaderTokenPtr token = stack.top(); data::AronDataNavigatorPtr nav = token->getElementAndIncreaseCnt(); data::AronBlobDataNavigatorPtr casted = data::AronBlobDataNavigator::DynamicCast(nav); + return casted->getData(); } diff --git a/source/RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.cpp b/source/RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.cpp index dd5d3f6551e5c8d48000670ef4d02de074fac18c..3e9c97db47f132e7db8644b8646be55f3532149a 100644 --- a/source/RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.cpp +++ b/source/RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.cpp @@ -119,6 +119,8 @@ namespace armarx AronDataNavigatorWriterTokenPtr token = stack.top(); data::AronBlobDataNavigatorPtr aron(new data::AronBlobDataNavigator(AronNavigatorPath())); aron->setData(elements, data); + token->addElement(aron); + return true; } diff --git a/source/RobotAPI/libraries/aron/test/CMakeLists.txt b/source/RobotAPI/libraries/aron/test/CMakeLists.txt index 07f169f1b7e0ef35e25add67dda8ef718f026a67..def98c5f47af0ec1105a7fd090406e228782d9c9 100644 --- a/source/RobotAPI/libraries/aron/test/CMakeLists.txt +++ b/source/RobotAPI/libraries/aron/test/CMakeLists.txt @@ -1,11 +1,35 @@ SET(TEST_NAME aronTest) + +find_package(Eigen3 QUIET) +armarx_build_if(Eigen3_FOUND "Eigen3 not available") +if(Eigen3_FOUND) + include_directories(${Eigen3_INCLUDE_DIR}) +endif() + +find_package(Simox QUIET) +armarx_build_if(Simox_FOUND "Simox not available") +if(Simox_FOUND) + include_directories(${Simox_INCLUDE_DIR}) +endif() + +find_package(IVT COMPONENTS ivt ivtopencv QUIET) +armarx_build_if(IVT_FOUND "IVT not available") +if(IVT_FOUND) + include_directories(${IVT_INCLUDE_DIRS}) +endif() + # Libs required for the tests -SET(LIBS ${LIBS} ArmarXCore aron) +SET(LIBS ${LIBS} ArmarXCore aron ivt ivtopencv) SET(ARON_XML_FILES xmls/HumanPose.xml xmls/DictTest.xml + xmls/ListTest.xml + xmls/NaturalIK.xml + xmls/ObjectTest.xml + xmls/PrimitiveTest.xml + xmls/ImageTest.xml ) generateAronCppInterface() diff --git a/source/RobotAPI/libraries/aron/test/aronTest.cpp b/source/RobotAPI/libraries/aron/test/aronTest.cpp index db02761681325ad3816923a7f0094e9252de72bb..16da880fcabc38dece1c6e790d14da1b1b44459d 100644 --- a/source/RobotAPI/libraries/aron/test/aronTest.cpp +++ b/source/RobotAPI/libraries/aron/test/aronTest.cpp @@ -29,6 +29,12 @@ #include <cstdlib> #include <ctime> +// IVT +#include <Image/ByteImage.h> + +// Eigen +#include <Eigen/Core> + // Boost #include <boost/algorithm/string.hpp> @@ -40,22 +46,25 @@ #include <ArmarXCore/libraries/cppgen/CppClass.h> // Generated File -#include "generated/NaturalIK.h" -#include "generated/ListTest.h" -#include "generated/DictTest.h" -#include "generated/PrimitiveTest.h" -#include "generated/ObjectTest.h" +#include "aron/NaturalIK.aron.generated.h" +#include "aron/ListTest.aron.generated.h" +#include "aron/DictTest.aron.generated.h" +#include "aron/PrimitiveTest.aron.generated.h" +#include "aron/ObjectTest.aron.generated.h" +#include "aron/ImageTest.aron.generated.h" -#include <Eigen/Core> - using namespace armarx; using namespace aron; -int generateRandom(int max, int min) +void initialize_random() { std::srand(std::time(nullptr)); - int random = std::rand() % max + min; +} + +int generateRandom(int max, int min) +{ + int random = (std::rand() % max) + min; return random; } @@ -70,6 +79,16 @@ std::string generateRandomWord() return words[i]; } +std::vector<unsigned char> generateRandomBlob(unsigned int size) +{ + std::vector<unsigned char> new_blob(size, 0); + for (unsigned int i = 0; i < size; ++i) + { + new_blob[i] = (generateRandom(127, 0)); + } + return new_blob; +} + AronDataPtr generateAronDataFromType(const AronAbstractTypePtr& type) { { @@ -233,13 +252,23 @@ void initializeRandomly(AronDataPtr& data, const AronAbstractTypePtr& type) } } - // TODO Complex + // Complex { - AronEigenMatrixTypePtr EigenMatrixType = AronEigenMatrixTypePtr::dynamicCast(type); - if (EigenMatrixType) + AronEigenMatrixTypePtr eigenMatrixType = AronEigenMatrixTypePtr::dynamicCast(type); + if (eigenMatrixType) + { + AronBlobPtr blob = AronBlobPtr::dynamicCast(data); + BOOST_CHECK_NE(blob.get(), nullptr); + return; + } + + AronIVTCByteImageTypePtr ivtCByteImageType = AronIVTCByteImageTypePtr::dynamicCast(type); + if (ivtCByteImageType) { AronBlobPtr blob = AronBlobPtr::dynamicCast(data); BOOST_CHECK_NE(blob.get(), nullptr); + + blob->data = generateRandomBlob(blob->data.size()); return; } } @@ -338,6 +367,8 @@ void runTestWithInstances(T& k, T& k2) BOOST_AUTO_TEST_CASE(AronTests) { + initialize_random(); + NaturalIKResult k; NaturalIKResult k2; runTestWithInstances<NaturalIKResult>(k, k2); @@ -361,4 +392,8 @@ BOOST_AUTO_TEST_CASE(AronTests) ObjectTest o2; ObjectTest o22; runTestWithInstances<ObjectTest>(o2, o22); + + ImageTest i; + ImageTest i2; + runTestWithInstances<ImageTest>(i, i2); } diff --git a/source/RobotAPI/libraries/aron/test/generated/DictTest.h b/source/RobotAPI/libraries/aron/test/generated/DictTest.h deleted file mode 100644 index 47247cd011ea77c1ce70c0b32af5ad6ca728fe16..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/test/generated/DictTest.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * This file is part of ArmarX. - * - * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), - * Karlsruhe Institute of Technology (KIT), all rights reserved. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - ************************************************************************* - * WARNING: This file is autogenerated. - * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/DictTest.xml - * Please do not edit since your changes may be overwritten on the next generation - * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - ************************************************************************* - */ - - -#ifndef ARONTESTSEGMENT__DICTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTSEGMENT__DICTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class DictTest - : virtual public armarx::aron::codegeneration::AronCppClass - { - public: - std::map<std::string, float> dict; - - public: - DictTest() - { - initialize(); - reset(); - } - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const armarx::DictTest& i) const - { - if ( not (dict == i.dict)) - return false; - return true; - } - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - dict.clear(); - } - /** - * @brief initialize() - This method initializeses special base-class members. - * @return - nothing - */ - virtual void initialize() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - armarx::aron::AronFloatType::PointerType aronTypeRoot_dict_dicttype = armarx::aron::AronFloatType::PointerType(new armarx::aron::AronFloatType()); - armarx::aron::AronDictType::PointerType aronTypeRoot_dict = armarx::aron::AronDictType::PointerType(new armarx::aron::AronDictType(aronTypeRoot_dict_dicttype)); - aronTypeRoot_objectiteratorcontainer["dict"] = aronTypeRoot_dict; - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::DictTest", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief write() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("dict"); - w.writeStartDict(); - for (const auto& [dict_dictkey, dict_dictval] : dict) - { - w.writeKey(dict_dictkey); - w.writeFloat(dict_dictval); - } - w.writeEndDict(); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("dict"); - r.readStartDict(); - while(!r.readEndDict()) - { - std::string dict_dictkey = r.readKey(); - float dict_dictiterator; - dict_dictiterator = r.readFloat(); - dict[dict_dictkey] = dict_dictiterator; - } - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class DictTest -} // namespace armarx - -#endif // ARONTESTSEGMENT__DICTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD diff --git a/source/RobotAPI/libraries/aron/test/generated/ListTest.h b/source/RobotAPI/libraries/aron/test/generated/ListTest.h deleted file mode 100644 index e325c483e728f39b2b400c1524389b8a7096c852..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/test/generated/ListTest.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - * This file is part of ArmarX. - * - * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), - * Karlsruhe Institute of Technology (KIT), all rights reserved. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - ************************************************************************* - * WARNING: This file is autogenerated. - * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/ListTest.xml - * Please do not edit since your changes may be overwritten on the next generation - * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - ************************************************************************* - */ - - -#ifndef ARONTESTSEGMENT__LISTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTSEGMENT__LISTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class ListTest - : virtual public armarx::aron::codegeneration::AronCppClass - { - protected: - class ListClass - { - public: - bool element0; - bool element1; - bool element2; - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const ListClass& i) const - { - if ( not (element0 == i.element0)) - return false; - if ( not (element1 == i.element1)) - return false; - if ( not (element2 == i.element2)) - return false; - return true; - } - }; // class ListClass - - public: - std::vector<bool> anotherboolList; - std::vector<bool> boolList; - std::vector<double> doubleList; - std::vector<float> floatList; - std::vector<int> intList; - std::vector<long> longList; - std::vector<ListClass> objectList; - std::vector<std::string> stringList; - - public: - ListTest() - { - initialize(); - reset(); - } - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const armarx::ListTest& i) const - { - if ( not (anotherboolList == i.anotherboolList)) - return false; - if ( not (boolList == i.boolList)) - return false; - if ( not (doubleList == i.doubleList)) - return false; - if ( not (floatList == i.floatList)) - return false; - if ( not (intList == i.intList)) - return false; - if ( not (longList == i.longList)) - return false; - if ( not (objectList == i.objectList)) - return false; - if ( not (stringList == i.stringList)) - return false; - return true; - } - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - anotherboolList.clear(); - boolList.clear(); - doubleList.clear(); - floatList.clear(); - intList.clear(); - longList.clear(); - objectList.clear(); - stringList.clear(); - } - /** - * @brief initialize() - This method initializeses special base-class members. - * @return - nothing - */ - virtual void initialize() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_anotherboolList_listtype = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - armarx::aron::AronListType::PointerType aronTypeRoot_anotherboolList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_anotherboolList_listtype)); - aronTypeRoot_objectiteratorcontainer["anotherboolList"] = aronTypeRoot_anotherboolList; - armarx::aron::AronBoolType::PointerType aronTypeRoot_boolList_listtype = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - armarx::aron::AronListType::PointerType aronTypeRoot_boolList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_boolList_listtype)); - aronTypeRoot_objectiteratorcontainer["boolList"] = aronTypeRoot_boolList; - armarx::aron::AronDoubleType::PointerType aronTypeRoot_doubleList_listtype = armarx::aron::AronDoubleType::PointerType(new armarx::aron::AronDoubleType()); - armarx::aron::AronListType::PointerType aronTypeRoot_doubleList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_doubleList_listtype)); - aronTypeRoot_objectiteratorcontainer["doubleList"] = aronTypeRoot_doubleList; - armarx::aron::AronFloatType::PointerType aronTypeRoot_floatList_listtype = armarx::aron::AronFloatType::PointerType(new armarx::aron::AronFloatType()); - armarx::aron::AronListType::PointerType aronTypeRoot_floatList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_floatList_listtype)); - aronTypeRoot_objectiteratorcontainer["floatList"] = aronTypeRoot_floatList; - armarx::aron::AronIntType::PointerType aronTypeRoot_intList_listtype = armarx::aron::AronIntType::PointerType(new armarx::aron::AronIntType()); - armarx::aron::AronListType::PointerType aronTypeRoot_intList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_intList_listtype)); - aronTypeRoot_objectiteratorcontainer["intList"] = aronTypeRoot_intList; - armarx::aron::AronLongType::PointerType aronTypeRoot_longList_listtype = armarx::aron::AronLongType::PointerType(new armarx::aron::AronLongType()); - armarx::aron::AronListType::PointerType aronTypeRoot_longList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_longList_listtype)); - aronTypeRoot_objectiteratorcontainer["longList"] = aronTypeRoot_longList; - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectList_listtype_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_objectList_listtype_element0 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectList_listtype_objectiteratorcontainer["element0"] = aronTypeRoot_objectList_listtype_element0; - armarx::aron::AronBoolType::PointerType aronTypeRoot_objectList_listtype_element1 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectList_listtype_objectiteratorcontainer["element1"] = aronTypeRoot_objectList_listtype_element1; - armarx::aron::AronBoolType::PointerType aronTypeRoot_objectList_listtype_element2 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectList_listtype_objectiteratorcontainer["element2"] = aronTypeRoot_objectList_listtype_element2; - armarx::aron::AronObjectType::PointerType aronTypeRoot_objectList_listtype = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("ListClass", aronTypeRoot_objectList_listtype_objectiteratorcontainer)); - armarx::aron::AronListType::PointerType aronTypeRoot_objectList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_objectList_listtype)); - aronTypeRoot_objectiteratorcontainer["objectList"] = aronTypeRoot_objectList; - armarx::aron::AronStringType::PointerType aronTypeRoot_stringList_listtype = armarx::aron::AronStringType::PointerType(new armarx::aron::AronStringType()); - armarx::aron::AronListType::PointerType aronTypeRoot_stringList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_stringList_listtype)); - aronTypeRoot_objectiteratorcontainer["stringList"] = aronTypeRoot_stringList; - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::ListTest", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief write() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("anotherboolList"); - w.writeStartList(); - for(unsigned int anotherboolList_listiterator = 0; anotherboolList_listiterator < anotherboolList.size(); ++anotherboolList_listiterator) - { - w.writeBool(anotherboolList[anotherboolList_listiterator]); - } - w.writeEndList(); - w.writeKey("boolList"); - w.writeStartList(); - for(unsigned int boolList_listiterator = 0; boolList_listiterator < boolList.size(); ++boolList_listiterator) - { - w.writeBool(boolList[boolList_listiterator]); - } - w.writeEndList(); - w.writeKey("doubleList"); - w.writeStartList(); - for(unsigned int doubleList_listiterator = 0; doubleList_listiterator < doubleList.size(); ++doubleList_listiterator) - { - w.writeDouble(doubleList[doubleList_listiterator]); - } - w.writeEndList(); - w.writeKey("floatList"); - w.writeStartList(); - for(unsigned int floatList_listiterator = 0; floatList_listiterator < floatList.size(); ++floatList_listiterator) - { - w.writeFloat(floatList[floatList_listiterator]); - } - w.writeEndList(); - w.writeKey("intList"); - w.writeStartList(); - for(unsigned int intList_listiterator = 0; intList_listiterator < intList.size(); ++intList_listiterator) - { - w.writeInt(intList[intList_listiterator]); - } - w.writeEndList(); - w.writeKey("longList"); - w.writeStartList(); - for(unsigned int longList_listiterator = 0; longList_listiterator < longList.size(); ++longList_listiterator) - { - w.writeLong(longList[longList_listiterator]); - } - w.writeEndList(); - w.writeKey("objectList"); - w.writeStartList(); - for(unsigned int objectList_listiterator = 0; objectList_listiterator < objectList.size(); ++objectList_listiterator) - { - w.writeStartDict(); - w.writeKey("element0"); - w.writeBool(objectList[objectList_listiterator].element0); - w.writeKey("element1"); - w.writeBool(objectList[objectList_listiterator].element1); - w.writeKey("element2"); - w.writeBool(objectList[objectList_listiterator].element2); - w.writeEndDict(); - } - w.writeEndList(); - w.writeKey("stringList"); - w.writeStartList(); - for(unsigned int stringList_listiterator = 0; stringList_listiterator < stringList.size(); ++stringList_listiterator) - { - w.writeString(stringList[stringList_listiterator]); - } - w.writeEndList(); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("anotherboolList"); - r.readStartList(); - while(!r.readEndList()) - { - bool anotherboolList_listiterator; - anotherboolList_listiterator = r.readBool(); - anotherboolList.push_back(anotherboolList_listiterator); - } - r.readMember("boolList"); - r.readStartList(); - while(!r.readEndList()) - { - bool boolList_listiterator; - boolList_listiterator = r.readBool(); - boolList.push_back(boolList_listiterator); - } - r.readMember("doubleList"); - r.readStartList(); - while(!r.readEndList()) - { - double doubleList_listiterator; - doubleList_listiterator = r.readDouble(); - doubleList.push_back(doubleList_listiterator); - } - r.readMember("floatList"); - r.readStartList(); - while(!r.readEndList()) - { - float floatList_listiterator; - floatList_listiterator = r.readFloat(); - floatList.push_back(floatList_listiterator); - } - r.readMember("intList"); - r.readStartList(); - while(!r.readEndList()) - { - int intList_listiterator; - intList_listiterator = r.readInt(); - intList.push_back(intList_listiterator); - } - r.readMember("longList"); - r.readStartList(); - while(!r.readEndList()) - { - long longList_listiterator; - longList_listiterator = r.readLong(); - longList.push_back(longList_listiterator); - } - r.readMember("objectList"); - r.readStartList(); - while(!r.readEndList()) - { - ListClass objectList_listiterator; - r.readStartDict(); - r.readMember("element0"); - objectList_listiterator.element0 = r.readBool(); - r.readMember("element1"); - objectList_listiterator.element1 = r.readBool(); - r.readMember("element2"); - objectList_listiterator.element2 = r.readBool(); - r.readEndDict(); - objectList.push_back(objectList_listiterator); - } - r.readMember("stringList"); - r.readStartList(); - while(!r.readEndList()) - { - std::string stringList_listiterator; - stringList_listiterator = r.readString(); - stringList.push_back(stringList_listiterator); - } - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class ListTest -} // namespace armarx - -#endif // ARONTESTSEGMENT__LISTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD diff --git a/source/RobotAPI/libraries/aron/test/generated/NaturalIK.h b/source/RobotAPI/libraries/aron/test/generated/NaturalIK.h deleted file mode 100644 index b92ab591fa908ec486d3c00569d5002605072088..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/test/generated/NaturalIK.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * This file is part of ArmarX. - * - * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), - * Karlsruhe Institute of Technology (KIT), all rights reserved. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - ************************************************************************* - * WARNING: This file is autogenerated. - * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml - * Timestamp of generation: Mon Aug 31 14:07:08 2020 - * Please do not edit since your changes may be overwritten on the next generation - * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - ************************************************************************* - */ - - -#ifndef ARONTESTSEGMENT__NATURALIKRESULT__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTSEGMENT__NATURALIKRESULT__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class NaturalIKResult - : virtual public armarx::aron::codegeneration::AronCppClass - { - public: - std::vector<float> jointValues; - bool reached; - - public: - NaturalIKResult() - { - initialize(); - reset(); - } - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const armarx::NaturalIKResult& i) const - { - if (not(jointValues == i.jointValues)) - { - return false; - } - if (not(reached == i.reached)) - { - return false; - } - return true; - } - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - jointValues.clear(); - reached = {}; - } - /** - * @brief initialize() - This method initializeses special base-class members. - * @return - nothing - */ - virtual void initialize() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - armarx::aron::AronFloatType::PointerType aronTypeRoot_jointValues_listtype = armarx::aron::AronFloatType::PointerType(new armarx::aron::AronFloatType()); - armarx::aron::AronListType::PointerType aronTypeRoot_jointValues = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_jointValues_listtype)); - aronTypeRoot_objectiteratorcontainer["jointValues"] = aronTypeRoot_jointValues; - armarx::aron::AronBoolType::PointerType aronTypeRoot_reached = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectiteratorcontainer["reached"] = aronTypeRoot_reached; - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::NaturalIKResult", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief write() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("jointValues"); - w.writeStartList(); - for (unsigned int jointValues_listiterator = 0; jointValues_listiterator < jointValues.size(); ++jointValues_listiterator) - { - w.writeFloat(jointValues[jointValues_listiterator]); - } - w.writeEndList(); - w.writeKey("reached"); - w.writeBool(reached); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("jointValues"); - r.readStartList(); - while (!r.readEndList()) - { - float jointValues_listiterator; - jointValues_listiterator = r.readFloat(); - jointValues.push_back(jointValues_listiterator); - } - r.readMember("reached"); - reached = r.readBool(); - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class NaturalIKResult -} // namespace armarx - -#endif // ARONTESTSEGMENT__NATURALIKRESULT__ARON_TYPE_DEFINITION_INCLUDE_GUARD diff --git a/source/RobotAPI/libraries/aron/test/generated/ObjectTest.h b/source/RobotAPI/libraries/aron/test/generated/ObjectTest.h deleted file mode 100644 index 09fc9ac3fd0215122885d69afd86d917b39a49f8..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/test/generated/ObjectTest.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - * This file is part of ArmarX. - * - * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), - * Karlsruhe Institute of Technology (KIT), all rights reserved. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - ************************************************************************* - * WARNING: This file is autogenerated - * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/ObjectTest.xml - * Timestamp of generation: Tue Jul 28 18:11:50 2020 - * Please do not edit since your changes may be overwritten on the next generation - * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - ************************************************************************* - */ - - -#ifndef ARONTESTSEGMENT__SIMPLECLASS__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTSEGMENT__SIMPLECLASS__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class SimpleClass - : virtual public armarx::aron::codegeneration::AronCppClass - { - public: - bool the_bool; - - public: - SimpleClass() - { - initialize(); - reset(); - } - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const armarx::SimpleClass& i) const - { - if ( not (the_bool == i.the_bool)) - return false; - return true; - } - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - the_bool = {}; - } - /** - * @brief initialize() - This method initializeses special base-class members. - * @return - nothing - */ - virtual void initialize() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_the_bool = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectiteratorcontainer["the_bool"] = aronTypeRoot_the_bool; - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::SimpleClass", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief write() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("the_bool"); - w.writeBool(the_bool); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("the_bool"); - the_bool = r.readBool(); - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class SimpleClass -} // namespace armarx - -#endif // ARONTESTSEGMENT__SIMPLECLASS__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -// ************* -// Here comes another auto-generated class. Don't mind the duplicated includes - everything is guarded! -// ************* - -#ifndef ARONTESTSEGMENT__OBJECTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTSEGMENT__OBJECTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class ObjectTest - : virtual public armarx::aron::codegeneration::AronCppClass - { - protected: - class OtherFancyObject - { - public: - bool blarg; - int other_blarg; - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const OtherFancyObject& i) const - { - if ( not (blarg == i.blarg)) - return false; - if ( not (other_blarg == i.other_blarg)) - return false; - return true; - } - }; // class OtherFancyObject - - class VisionClass - { - public: - bool blarg; - int other_object; - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const VisionClass& i) const - { - if ( not (blarg == i.blarg)) - return false; - if ( not (other_object == i.other_object)) - return false; - return true; - } - }; // class VisionClass - - public: - VisionClass another_local_object; - OtherFancyObject local_object; - - public: - ObjectTest() - { - initialize(); - reset(); - } - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const armarx::ObjectTest& i) const - { - if ( not (another_local_object == i.another_local_object)) - return false; - if ( not (local_object == i.local_object)) - return false; - return true; - } - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - another_local_object.blarg = {}; - another_local_object.other_object = {}; - local_object.blarg = {}; - local_object.other_blarg = {}; - } - /** - * @brief initialize() - This method initializeses special base-class members. - * @return - nothing - */ - virtual void initialize() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_another_local_object_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_another_local_object_blarg = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_another_local_object_objectiteratorcontainer["blarg"] = aronTypeRoot_another_local_object_blarg; - armarx::aron::AronIntType::PointerType aronTypeRoot_another_local_object_other_object = armarx::aron::AronIntType::PointerType(new armarx::aron::AronIntType()); - aronTypeRoot_another_local_object_objectiteratorcontainer["other_object"] = aronTypeRoot_another_local_object_other_object; - armarx::aron::AronObjectType::PointerType aronTypeRoot_another_local_object = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("VisionClass", aronTypeRoot_another_local_object_objectiteratorcontainer)); - aronTypeRoot_objectiteratorcontainer["another_local_object"] = aronTypeRoot_another_local_object; - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_local_object_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_local_object_blarg = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_local_object_objectiteratorcontainer["blarg"] = aronTypeRoot_local_object_blarg; - armarx::aron::AronIntType::PointerType aronTypeRoot_local_object_other_blarg = armarx::aron::AronIntType::PointerType(new armarx::aron::AronIntType()); - aronTypeRoot_local_object_objectiteratorcontainer["other_blarg"] = aronTypeRoot_local_object_other_blarg; - armarx::aron::AronObjectType::PointerType aronTypeRoot_local_object = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("OtherFancyObject", aronTypeRoot_local_object_objectiteratorcontainer)); - aronTypeRoot_objectiteratorcontainer["local_object"] = aronTypeRoot_local_object; - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::ObjectTest", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief write() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("another_local_object"); - w.writeStartDict(); - w.writeKey("blarg"); - w.writeBool(another_local_object.blarg); - w.writeKey("other_object"); - w.writeInt(another_local_object.other_object); - w.writeEndDict(); - w.writeKey("local_object"); - w.writeStartDict(); - w.writeKey("blarg"); - w.writeBool(local_object.blarg); - w.writeKey("other_blarg"); - w.writeInt(local_object.other_blarg); - w.writeEndDict(); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("another_local_object"); - r.readStartDict(); - r.readMember("blarg"); - another_local_object.blarg = r.readBool(); - r.readMember("other_object"); - another_local_object.other_object = r.readInt(); - r.readEndDict(); - r.readMember("local_object"); - r.readStartDict(); - r.readMember("blarg"); - local_object.blarg = r.readBool(); - r.readMember("other_blarg"); - local_object.other_blarg = r.readInt(); - r.readEndDict(); - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class ObjectTest -} // namespace armarx - -#endif // ARONTESTSEGMENT__OBJECTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD diff --git a/source/RobotAPI/libraries/aron/test/generated/PrimitiveTest.h b/source/RobotAPI/libraries/aron/test/generated/PrimitiveTest.h deleted file mode 100644 index 8505b602f7d6dd57a0d6e6a03795e1383b8c6228..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/test/generated/PrimitiveTest.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * This file is part of ArmarX. - * - * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), - * Karlsruhe Institute of Technology (KIT), all rights reserved. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - ************************************************************************* - * WARNING: This file is autogenerated. - * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/PrimitiveTest.xml - * Please do not edit since your changes may be overwritten on the next generation - * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - ************************************************************************* - */ - - -#ifndef ARONTESTSEGMENT__PRIMITIVETEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTSEGMENT__PRIMITIVETEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class PrimitiveTest - : virtual public armarx::aron::codegeneration::AronCppClass - { - public: - bool the_bool; - double the_double; - float the_float; - int the_int; - long the_long; - std::string the_string; - - public: - PrimitiveTest() - { - initialize(); - reset(); - } - - public: - /** - * @brief operator==() - This method checks whether all values equal another instance. - * @param i - The other instance - * @return - true, if all members are the same, false otherwise - */ - bool operator==(const armarx::PrimitiveTest& i) const - { - if ( not (the_bool == i.the_bool)) - return false; - if ( not (the_double == i.the_double)) - return false; - if ( not (the_float == i.the_float)) - return false; - if ( not (the_int == i.the_int)) - return false; - if ( not (the_long == i.the_long)) - return false; - if ( not (the_string == i.the_string)) - return false; - return true; - } - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - the_bool = {}; - the_double = {}; - the_float = {}; - the_int = {}; - the_long = {}; - the_string = {}; - } - /** - * @brief initialize() - This method initializeses special base-class members. - * @return - nothing - */ - virtual void initialize() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_the_bool = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectiteratorcontainer["the_bool"] = aronTypeRoot_the_bool; - armarx::aron::AronDoubleType::PointerType aronTypeRoot_the_double = armarx::aron::AronDoubleType::PointerType(new armarx::aron::AronDoubleType()); - aronTypeRoot_objectiteratorcontainer["the_double"] = aronTypeRoot_the_double; - armarx::aron::AronFloatType::PointerType aronTypeRoot_the_float = armarx::aron::AronFloatType::PointerType(new armarx::aron::AronFloatType()); - aronTypeRoot_objectiteratorcontainer["the_float"] = aronTypeRoot_the_float; - armarx::aron::AronIntType::PointerType aronTypeRoot_the_int = armarx::aron::AronIntType::PointerType(new armarx::aron::AronIntType()); - aronTypeRoot_objectiteratorcontainer["the_int"] = aronTypeRoot_the_int; - armarx::aron::AronLongType::PointerType aronTypeRoot_the_long = armarx::aron::AronLongType::PointerType(new armarx::aron::AronLongType()); - aronTypeRoot_objectiteratorcontainer["the_long"] = aronTypeRoot_the_long; - armarx::aron::AronStringType::PointerType aronTypeRoot_the_string = armarx::aron::AronStringType::PointerType(new armarx::aron::AronStringType()); - aronTypeRoot_objectiteratorcontainer["the_string"] = aronTypeRoot_the_string; - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::PrimitiveTest", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief write() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("the_bool"); - w.writeBool(the_bool); - w.writeKey("the_double"); - w.writeDouble(the_double); - w.writeKey("the_float"); - w.writeFloat(the_float); - w.writeKey("the_int"); - w.writeInt(the_int); - w.writeKey("the_long"); - w.writeLong(the_long); - w.writeKey("the_string"); - w.writeString(the_string); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("the_bool"); - the_bool = r.readBool(); - r.readMember("the_double"); - the_double = r.readDouble(); - r.readMember("the_float"); - the_float = r.readFloat(); - r.readMember("the_int"); - the_int = r.readInt(); - r.readMember("the_long"); - the_long = r.readLong(); - r.readMember("the_string"); - the_string = r.readString(); - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class PrimitiveTest -} // namespace armarx - -#endif // ARONTESTSEGMENT__PRIMITIVETEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD diff --git a/source/RobotAPI/libraries/aron/test/generated/output.generated.h b/source/RobotAPI/libraries/aron/test/generated/output.generated.h deleted file mode 100644 index e78beefa4467582905e32f2b8fa14b9c84bf5e4c..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/test/generated/output.generated.h +++ /dev/null @@ -1,383 +0,0 @@ -#ifndef ARONTESTPRODUCER__LISTCLASS__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTPRODUCER__LISTCLASS__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class ListClass - : virtual public armarx::aron::codegeneration::AronCppClass - { - public: - bool element0; - bool element1; - bool element2; - - public: - ListClass() - { - reset(); - } - - public: - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - element0 = {}; - element1 = {}; - element2 = {}; - } - /** - * @brief reset() - This method sets special base-class members. - * @return - nothing - */ - virtual void setup() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_element0 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectiteratorcontainer["element0"] = (aronTypeRoot_element0); - armarx::aron::AronBoolType::PointerType aronTypeRoot_element1 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectiteratorcontainer["element1"] = (aronTypeRoot_element1); - armarx::aron::AronBoolType::PointerType aronTypeRoot_element2 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectiteratorcontainer["element2"] = (aronTypeRoot_element2); - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::ListClass", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief read() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("element0"); - w.writeBool(element0); - w.writeKey("element1"); - w.writeBool(element1); - w.writeKey("element2"); - w.writeBool(element2); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("element0"); - element0 = r.readBool(); - r.readMember("element1"); - element1 = r.readBool(); - r.readMember("element2"); - element2 = r.readBool(); - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class ListClass -} // namespace armarx - -#endif // ARONTESTPRODUCER__LISTCLASS__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#ifndef ARONTESTPRODUCER__LISTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD -#define ARONTESTPRODUCER__LISTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD - -#include <string> -#include <vector> -#include <map> -#include <Eigen/Core> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> -#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> - -namespace armarx -{ - class ListTest - : virtual public armarx::aron::codegeneration::AronCppClass - { - public: - std::vector<bool> anotherboolList; - std::vector<bool> boolList; - std::vector<double> doubleList; - std::vector<float> floatList; - std::vector<int> intList; - std::vector<long> longList; - std::vector<armarx::ListClass> objectList; - std::vector<std::string> stringList; - - public: - ListTest() - { - reset(); - } - - public: - /** - * @brief reset() - This method resets all member variables to default. - * @return - nothing - */ - virtual void reset() override - { - anotherboolList.clear(); - boolList.clear(); - doubleList.clear(); - floatList.clear(); - intList.clear(); - longList.clear(); - objectList.clear(); - stringList.clear(); - } - /** - * @brief reset() - This method sets special base-class members. - * @return - nothing - */ - virtual void setup() override - { - // setup aronType - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_anotherboolList_listtype = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - armarx::aron::AronListType::PointerType aronTypeRoot_anotherboolList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_anotherboolList_listtype)); - aronTypeRoot_objectiteratorcontainer["anotherboolList"] = (aronTypeRoot_anotherboolList); - armarx::aron::AronBoolType::PointerType aronTypeRoot_boolList_listtype = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - armarx::aron::AronListType::PointerType aronTypeRoot_boolList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_boolList_listtype)); - aronTypeRoot_objectiteratorcontainer["boolList"] = (aronTypeRoot_boolList); - armarx::aron::AronDoubleType::PointerType aronTypeRoot_doubleList_listtype = armarx::aron::AronDoubleType::PointerType(new armarx::aron::AronDoubleType()); - armarx::aron::AronListType::PointerType aronTypeRoot_doubleList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_doubleList_listtype)); - aronTypeRoot_objectiteratorcontainer["doubleList"] = (aronTypeRoot_doubleList); - armarx::aron::AronFloatType::PointerType aronTypeRoot_floatList_listtype = armarx::aron::AronFloatType::PointerType(new armarx::aron::AronFloatType()); - armarx::aron::AronListType::PointerType aronTypeRoot_floatList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_floatList_listtype)); - aronTypeRoot_objectiteratorcontainer["floatList"] = (aronTypeRoot_floatList); - armarx::aron::AronIntType::PointerType aronTypeRoot_intList_listtype = armarx::aron::AronIntType::PointerType(new armarx::aron::AronIntType()); - armarx::aron::AronListType::PointerType aronTypeRoot_intList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_intList_listtype)); - aronTypeRoot_objectiteratorcontainer["intList"] = (aronTypeRoot_intList); - armarx::aron::AronLongType::PointerType aronTypeRoot_longList_listtype = armarx::aron::AronLongType::PointerType(new armarx::aron::AronLongType()); - armarx::aron::AronListType::PointerType aronTypeRoot_longList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_longList_listtype)); - aronTypeRoot_objectiteratorcontainer["longList"] = (aronTypeRoot_longList); - std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectList_listtype_objectiteratorcontainer; - armarx::aron::AronBoolType::PointerType aronTypeRoot_objectList_listtype_element0 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectList_listtype_objectiteratorcontainer["element0"] = (aronTypeRoot_objectList_listtype_element0); - armarx::aron::AronBoolType::PointerType aronTypeRoot_objectList_listtype_element1 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectList_listtype_objectiteratorcontainer["element1"] = (aronTypeRoot_objectList_listtype_element1); - armarx::aron::AronBoolType::PointerType aronTypeRoot_objectList_listtype_element2 = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); - aronTypeRoot_objectList_listtype_objectiteratorcontainer["element2"] = (aronTypeRoot_objectList_listtype_element2); - armarx::aron::AronObjectType::PointerType aronTypeRoot_objectList_listtype = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::ListClass", aronTypeRoot_objectList_listtype_objectiteratorcontainer)); - armarx::aron::AronListType::PointerType aronTypeRoot_objectList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_objectList_listtype)); - aronTypeRoot_objectiteratorcontainer["objectList"] = (aronTypeRoot_objectList); - armarx::aron::AronStringType::PointerType aronTypeRoot_stringList_listtype = armarx::aron::AronStringType::PointerType(new armarx::aron::AronStringType()); - armarx::aron::AronListType::PointerType aronTypeRoot_stringList = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_stringList_listtype)); - aronTypeRoot_objectiteratorcontainer["stringList"] = (aronTypeRoot_stringList); - armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::ListTest", aronTypeRoot_objectiteratorcontainer)); - aronType = aronTypeRoot; - } - /** - * @brief read() - This method returns a new type from the member data types using a writer implementation. - * @param w - The writer implementation - * @return - the result of the writer implementation - */ - virtual void write(armarx::aron::io::AronWriter& w) const override - { - w.writeStartDict(); - w.writeKey("anotherboolList"); - w.writeStartList(); - for(unsigned int anotherboolList_listiterator = 0; anotherboolList_listiterator < anotherboolList.size(); ++anotherboolList_listiterator) - { - w.writeBool(anotherboolList[anotherboolList_listiterator]); - } - w.writeEndList(); - w.writeKey("boolList"); - w.writeStartList(); - for(unsigned int boolList_listiterator = 0; boolList_listiterator < boolList.size(); ++boolList_listiterator) - { - w.writeBool(boolList[boolList_listiterator]); - } - w.writeEndList(); - w.writeKey("doubleList"); - w.writeStartList(); - for(unsigned int doubleList_listiterator = 0; doubleList_listiterator < doubleList.size(); ++doubleList_listiterator) - { - w.writeDouble(doubleList[doubleList_listiterator]); - } - w.writeEndList(); - w.writeKey("floatList"); - w.writeStartList(); - for(unsigned int floatList_listiterator = 0; floatList_listiterator < floatList.size(); ++floatList_listiterator) - { - w.writeFloat(floatList[floatList_listiterator]); - } - w.writeEndList(); - w.writeKey("intList"); - w.writeStartList(); - for(unsigned int intList_listiterator = 0; intList_listiterator < intList.size(); ++intList_listiterator) - { - w.writeInt(intList[intList_listiterator]); - } - w.writeEndList(); - w.writeKey("longList"); - w.writeStartList(); - for(unsigned int longList_listiterator = 0; longList_listiterator < longList.size(); ++longList_listiterator) - { - w.writeLong(longList[longList_listiterator]); - } - w.writeEndList(); - w.writeKey("objectList"); - w.writeStartList(); - for(unsigned int objectList_listiterator = 0; objectList_listiterator < objectList.size(); ++objectList_listiterator) - { - w.writeStartDict(); - w.writeKey("element0"); - w.writeBool(objectList[objectList_listiterator].element0); - w.writeKey("element1"); - w.writeBool(objectList[objectList_listiterator].element1); - w.writeKey("element2"); - w.writeBool(objectList[objectList_listiterator].element2); - w.writeEndDict(); - } - w.writeEndList(); - w.writeKey("stringList"); - w.writeStartList(); - for(unsigned int stringList_listiterator = 0; stringList_listiterator < stringList.size(); ++stringList_listiterator) - { - w.writeString(stringList[stringList_listiterator]); - } - w.writeEndList(); - w.writeEndDict(); - } - /** - * @brief read() - This method sets the struct members to new values given in a reader implementation. - * @param r - The reader implementation - * @return - nothing - */ - virtual void read(armarx::aron::io::AronReader& r) override - { - reset(); - - r.readStartDict(); - r.readMember("anotherboolList"); - r.readStartList(); - while(!r.readEndList()) - { - bool anotherboolList_listiterator; - anotherboolList_listiterator = r.readBool(); - anotherboolList.push_back(anotherboolList_listiterator); - } - r.readMember("boolList"); - r.readStartList(); - while(!r.readEndList()) - { - bool boolList_listiterator; - boolList_listiterator = r.readBool(); - boolList.push_back(boolList_listiterator); - } - r.readMember("doubleList"); - r.readStartList(); - while(!r.readEndList()) - { - double doubleList_listiterator; - doubleList_listiterator = r.readDouble(); - doubleList.push_back(doubleList_listiterator); - } - r.readMember("floatList"); - r.readStartList(); - while(!r.readEndList()) - { - float floatList_listiterator; - floatList_listiterator = r.readFloat(); - floatList.push_back(floatList_listiterator); - } - r.readMember("intList"); - r.readStartList(); - while(!r.readEndList()) - { - int intList_listiterator; - intList_listiterator = r.readInt(); - intList.push_back(intList_listiterator); - } - r.readMember("longList"); - r.readStartList(); - while(!r.readEndList()) - { - long longList_listiterator; - longList_listiterator = r.readLong(); - longList.push_back(longList_listiterator); - } - r.readMember("objectList"); - r.readStartList(); - while(!r.readEndList()) - { - armarx::ListClass objectList_listiterator; - r.readStartDict(); - r.readMember("element0"); - objectList_listiterator.element0 = r.readBool(); - r.readMember("element1"); - objectList_listiterator.element1 = r.readBool(); - r.readMember("element2"); - objectList_listiterator.element2 = r.readBool(); - r.readEndDict(); - objectList.push_back(objectList_listiterator); - } - r.readMember("stringList"); - r.readStartList(); - while(!r.readEndList()) - { - std::string stringList_listiterator; - stringList_listiterator = r.readString(); - stringList.push_back(stringList_listiterator); - } - r.readEndDict(); - } - /** - * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. - * @return - the result of the writer implementation - */ - armarx::aron::AronDataPtr toAron() const - { - armarx::aron::io::AronDataNavigatorWriter writer; - this->write(writer); - return writer.getResult(); - } - /** - * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. - * @return - nothing - */ - void fromAron(const armarx::aron::AronDataPtr& input) - { - armarx::aron::io::AronDataNavigatorReader reader(input); - this->read(reader); - } - }; // class ListTest -} // namespace armarx - -#endif // ARONTESTPRODUCER__LISTTEST__ARON_TYPE_DEFINITION_INCLUDE_GUARD diff --git a/source/RobotAPI/libraries/aron/test/xmls/DictTest.xml b/source/RobotAPI/libraries/aron/test/xmls/DictTest.xml index 5757b9392ee398c23ba3215c038c55d133fb085a..ab83ff2457d1903cda941ca7a2f96a61ae5bd61e 100644 --- a/source/RobotAPI/libraries/aron/test/xmls/DictTest.xml +++ b/source/RobotAPI/libraries/aron/test/xmls/DictTest.xml @@ -1,6 +1,8 @@ <!--Some fancy comment --> <?xml version="1.0" encoding="UTF-8" ?> <AronTypeDefinition> + <Includes> + </Includes> <Serializers> <Writers> </Writers> @@ -13,9 +15,9 @@ <GenerateType name='armarx::DictTest'> <objectchild key='dict'> <Dict> - <DictType> + <Type> <Float /> - </DictType> + </Type> </Dict> </ObjectChild> </GenerateType> diff --git a/source/RobotAPI/libraries/aron/test/xmls/HumanPose.xml b/source/RobotAPI/libraries/aron/test/xmls/HumanPose.xml index ab39fae3b5fd5be0de040c47fd77fd4eadf77254..f31b3f76b78adc7586df0f19bdb7c62071bb2b15 100644 --- a/source/RobotAPI/libraries/aron/test/xmls/HumanPose.xml +++ b/source/RobotAPI/libraries/aron/test/xmls/HumanPose.xml @@ -1,7 +1,8 @@ -<!--This class contains the data structure for NaturalIKResults --> +<!--This class contains the data structure for OpenPoseEstimationResults --> <?xml version="1.0" encoding="UTF-8" ?> <AronTypeDefinition> - + <Includes> + </Includes> <Serializers> <Writers> @@ -16,7 +17,7 @@ </UseTypes> <GenerateTypes> - <GenerateType name='armarx::NaturalIKResult'> + <GenerateType name='armarx::OpenPoseEstimationResult'> <ObjectChild key='reached'> <Bool /> @@ -24,9 +25,9 @@ <ObjectChild key='jointValues'> <List> - <ListType> + <Type> <Float /> - </ListType> + </Type> </List> </ObjectChild> diff --git a/source/RobotAPI/libraries/aron/test/xmls/ImageTest.xml b/source/RobotAPI/libraries/aron/test/xmls/ImageTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..9dea22928b95200ecad0424988839dd3ab80c719 --- /dev/null +++ b/source/RobotAPI/libraries/aron/test/xmls/ImageTest.xml @@ -0,0 +1,15 @@ +<!--Some fancy comment --> +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <Includes> + <Include include="<Eigen/Core>" /> + <Include include="<Image/ByteImage.h>" /> + </Includes> + <GenerateTypes> + <GenerateType name='armarx::ImageTest'> + <ObjectChild key='the_ivt_image'> + <IVTCByteImage width="25" height="25" type="CByteImage::ImageType::eGrayScale" /> + </ObjectChild> + </GenerateType> + </GenerateTypes> +</AronTypeDefinition> diff --git a/source/RobotAPI/libraries/aron/test/xmls/ListTest.xml b/source/RobotAPI/libraries/aron/test/xmls/ListTest.xml index 3cb8666d888ae9742027dcae7ab1ad55a94521d1..5bb792dddcb4594fa043b9a206058af27b26ddce 100644 --- a/source/RobotAPI/libraries/aron/test/xmls/ListTest.xml +++ b/source/RobotAPI/libraries/aron/test/xmls/ListTest.xml @@ -1,68 +1,63 @@ <!--Some fancy comment --> <?xml version="1.0" encoding="UTF-8" ?> <AronTypeDefinition> - <Serializers> - <Writers> - </Writers> - <Readers> - </Readers> - </Serializers> - <UseTypes> - </UseTypes> + <Includes> + <include include="<Eigen/Core>" /> + </Includes> <GenerateTypes> <GenerateType name='armarx::ListTest'> <ObjectChild key='floatList'> <List> - <ListType> + <Type> <Float /> - </ListType> + </Type> </List> </ObjectChild> <ObjectChild key='intList'> <List> - <ListType> + <Type> <Int /> - </ListType> + </Type> </List> </ObjectChild> <ObjectChild key='doubleList'> <List> - <ListType> + <Type> <Double /> - </ListType> + </Type> </List> </ObjectChild> <ObjectChild key='longList'> <List> - <ListType> + <Type> <Long /> - </ListType> + </Type> </List> </ObjectChild> <ObjectChild key='stringList'> <List> - <ListType> + <Type> <String /> - </ListType> + </Type> </List> </ObjectChild> <ObjectChild key='boolList'> <List> - <ListType> + <Type> <Bool /> - </ListType> + </Type> </List> </ObjectChild> <ObjectChild key='anotherboolList'> <List> - <ListType> + <Type> <Bool /> - </ListType> + </Type> </List> </ObjectChild> <ObjectChild key='objectList'> <List> - <ListType> + <Type> <Object name='ListClass'> <ObjectChild key='element0'> <Bool /> @@ -74,7 +69,7 @@ <Bool /> </ObjectChild> </Object> - </ListType> + </Type> </List> </ObjectChild> </GenerateType> diff --git a/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml b/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml index ab39fae3b5fd5be0de040c47fd77fd4eadf77254..4c388859eb2ab1256fda51caf0ad33b291ce7141 100644 --- a/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml +++ b/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml @@ -1,7 +1,8 @@ <!--This class contains the data structure for NaturalIKResults --> <?xml version="1.0" encoding="UTF-8" ?> <AronTypeDefinition> - + <Includes> + </Includes> <Serializers> <Writers> @@ -24,9 +25,9 @@ <ObjectChild key='jointValues'> <List> - <ListType> + <Type> <Float /> - </ListType> + </Type> </List> </ObjectChild> diff --git a/source/RobotAPI/libraries/aron/test/xmls/ObjectTest.xml b/source/RobotAPI/libraries/aron/test/xmls/ObjectTest.xml index 19d48b8e5ff3986d22825b7aa1e9a6dbb39d6a25..2504e9f5eb7ff87485f9f1a040cdc942a1098e3f 100644 --- a/source/RobotAPI/libraries/aron/test/xmls/ObjectTest.xml +++ b/source/RobotAPI/libraries/aron/test/xmls/ObjectTest.xml @@ -1,6 +1,8 @@ <!--Some fancy comment --> <?xml version="1.0" encoding="UTF-8" ?> <AronTypeDefinition> + <Includes> + </Includes> <Serializers> <Writers> </Writers> diff --git a/source/RobotAPI/libraries/aron/test/xmls/PrimitiveTest.xml b/source/RobotAPI/libraries/aron/test/xmls/PrimitiveTest.xml index 4bf6e14022c300e226ba8aad827dd086752928e0..72dfa26a7b27d1997ef0bade957cb6e686671abc 100644 --- a/source/RobotAPI/libraries/aron/test/xmls/PrimitiveTest.xml +++ b/source/RobotAPI/libraries/aron/test/xmls/PrimitiveTest.xml @@ -1,6 +1,8 @@ <!--Some fancy comment --> <?xml version="1.0" encoding="UTF-8" ?> <AronTypeDefinition> + <Includes> + </Includes> <Serializers> <Writers> </Writers> diff --git a/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.cpp index 6c7e59e441368fd479631fe7e29d1684e1e21ced..0317e49261f52ff4709685c5a04de7e194973434 100644 --- a/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.cpp @@ -230,6 +230,20 @@ namespace armarx return m; } + CppMethodPtr AronAbstractTypeNavigator::toEqualsMethod() const + { + std::stringstream doc; + doc << "@brief operator==() - This method checks whether all values equal another instance. \n"; + doc << "@param i - The other instance\n"; + doc << "@return - true, if all members are the same, false otherwise"; + + CppMethodPtr m = CppMethodPtr(new CppMethod("bool operator==(const " + this->getFullCppTypename() + "& i) const", doc.str())); + CppBlockPtr b = this->getEqualsBlock("", "i"); + b->addLine("return true;"); + m->setBlock(b); + return m; + } + // static methods AronAbstractTypeNavigatorPtr AronAbstractTypeNavigator::GetAronAbstractTypePtrByName(const std::string& name) { diff --git a/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.h index 61c7798d1718b6bd78a09281cd0dbfdf08d9a55a..0bb2143f4c352692d571acec942e7141086d497c 100644 --- a/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronAbstractTypeNavigator.h @@ -97,6 +97,9 @@ namespace armarx CppMethodPtr toReadMethod() const; virtual CppBlockPtr getReadBlock(const std::string&) const = 0; + CppMethodPtr toEqualsMethod() const; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const = 0; + virtual AronAbstractTypePtr getResult() const override = 0; // static methods diff --git a/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.cpp index 00e521c7bc5fa99f6c1b5c9f010b95fb8258d20a..8f639bc89050bce54ee068bb5d9d5b8907cae431 100644 --- a/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.cpp @@ -127,6 +127,14 @@ namespace armarx b->addBlock(b2); return b; } + + CppBlockPtr AronDictTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + b->addLine("if (not (" + accessor + " == " + otherInstanceAccessor + "))"); + b->addLine("\t return false;"); + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.h index b92bf96ce844510e6109388aea9deedc4893a66b..e115f0f80ad73c773231bbb8c6bd562a7585c1f8 100644 --- a/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronDictTypeNavigator.h @@ -62,6 +62,7 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: // members diff --git a/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.cpp index 3d7b1091b75b22d8b87faf7eb62bc7f15d4c08d1..34e76e4829052642ec3520316a041258e8871d2a 100644 --- a/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.cpp @@ -130,10 +130,15 @@ namespace armarx CppBlockPtr AronEigenMatrixTypeNavigator::getReadBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - // b->addLine(accessor + " = " + getFullCppTypename() + "(reinterpret_cast<" + usedType + "*>(r.readBlob())); // Eigen already performs memcpy"); return b; } + + CppBlockPtr AronEigenMatrixTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.h index a5bd0012ef83374b4f7b5a51a17140c5f19a2cc7..a3c5ecc6317df01bf2557e65f7e927eded574b99 100644 --- a/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronEigenMatrixTypeNavigator.h @@ -60,6 +60,7 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: // members diff --git a/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.cpp index abb4fde18ba1ed4f869c5750632ad1c97f2ae54d..0b20a776b027fcd225e7025c54c5fc6427928dab 100644 --- a/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.cpp @@ -83,6 +83,14 @@ namespace armarx b->addLine(accessor + ".read(w);"); return b; } + + CppBlockPtr AronExternalTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + b->addLine("if (not (" + accessor + " == " + otherInstanceAccessor + "))"); + b->addLine("\t return false;"); + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.h index c6c6c381761be93e1edc4ffb99b6a2490b727009..6afc460906002a11b4a71cb1137006eafd27c5c6 100644 --- a/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronExternalTypeNavigator.h @@ -59,6 +59,8 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; + private: // members diff --git a/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.cpp index 4487ce55ccda3e875364b986ac210c2c822dd36f..29ae4047fa2aed9318238183a251826cd3555862 100644 --- a/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.cpp @@ -34,17 +34,17 @@ namespace armarx namespace types { - const std::set<std::string> AronIVTCByteImageTypeNavigator::acceptedTypes = + const std::map<std::string, unsigned int> AronIVTCByteImageTypeNavigator::acceptedTypes = { - {"CByteImage::ImageType::eGrayScale"}, - {"CByteImage::ImageType::eRGB24"}, - {"CByteImage::ImageType::eRGB24Split"} + {"CByteImage::ImageType::eGrayScale", 1}, + {"CByteImage::ImageType::eRGB24", 3}, + {"CByteImage::ImageType::eRGB24Split", 3} }; // constructors AronIVTCByteImageTypeNavigator::AronIVTCByteImageTypeNavigator(const unsigned int w, const unsigned int h, const std::string& t, const AronNavigatorPath& path) : AronNavigator<AronTypeDescriptor, AronAbstractType>::AronNavigator(AronTypeDescriptor::eAronIVTCByteImageType), - AronAbstractTypeNavigator(AronTypeDescriptor::eAronIVTCByteImageType, "CByteImage", boost::core::demangle(typeid(AronBlob).name()), boost::core::demangle(typeid(AronIVTCByteImageType).name())), + AronAbstractTypeNavigator(AronTypeDescriptor::eAronIVTCByteImageType, "std::shared_ptr<CByteImage>", boost::core::demangle(typeid(AronBlob).name()), boost::core::demangle(typeid(AronIVTCByteImageType).name())), width(w), height(h), type(new AronIVTCByteImageType()) @@ -53,20 +53,15 @@ namespace armarx type->height = h; type->typeName = t; - bool found = false; - for (const auto& typeName : acceptedTypes) + auto i = acceptedTypes.find(t); + if (acceptedTypes.find(t) == acceptedTypes.end()) { - if (typeName == t) - { - this->usedType = typeName; - found = true; - break; - } + throw LocalException("AronIVTCByteImageTypeNavigator: Could not find the typename '" + t + "' in accepted types."); } - - if (!found) + else { - throw LocalException("AronIVTCByteImageTypeNavigator: Could not find the typename '" + t + "' in accepted types."); + this->usedType = i->first; + this->elementSize = i->second; } } @@ -87,7 +82,7 @@ namespace armarx CppBlockPtr AronIVTCByteImageTypeNavigator::getResetBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine(accessor + " = " + getFullCppTypename() + "();"); + b->addLine(accessor + " = " + getFullCppTypename() + "(new CByteImage(" + std::to_string(this->width) + ", " + std::to_string(this->height) + ", " + this->usedType + "));"); return b; } @@ -101,7 +96,7 @@ namespace armarx CppBlockPtr AronIVTCByteImageTypeNavigator::getWriteBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writeBlob(reinterpret_cast<unsigned char*>(" + accessor + ".pixels));"); + b->addLine("w.writeBlob(" + std::to_string(this->width * this->height * this->elementSize) + ", reinterpret_cast<unsigned char*>(" + accessor + "->pixels));"); return b; } @@ -109,8 +104,18 @@ namespace armarx { CppBlockPtr b = CppBlockPtr(new CppBlock()); //CByteImage(int nImageWidth, int nImageHeight, ImageType imageType, bool bHeaderOnly = false); - b->addLine(accessor + " = " + getFullCppTypename() + "(" + std::to_string(width) + ", " + std::to_string(height) + ", " + usedType + ", false);"); - b->addLine("memcpy(" + accessor + ".pixels, reinterpret_cast<unsiged char*>(r.readBlob()), " + accessor + ".width * " + accessor + ".height * " + accessor + ".bytesPerPixel);"); + b->addLine(accessor + " = " + getFullCppTypename() + "(new CByteImage(" + std::to_string(width) + ", " + std::to_string(height) + ", " + usedType + ", false));"); + b->addLine("memcpy(" + accessor + "->pixels, reinterpret_cast<unsigned char*>(r.readBlob()), " + std::to_string(this->width * this->height * this->elementSize) + ");"); + return b; + } + + CppBlockPtr AronIVTCByteImageTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + b->addLine("if (not (" + accessor + "->IsCompatible(" + otherInstanceAccessor + ".get())))"); + b->addLine("\t return false;"); + b->addLine("if (not (memcmp(" + accessor + "->pixels, " + otherInstanceAccessor + "->pixels, " + std::to_string(this->width * this->height * this->elementSize) + ") == 0))"); + b->addLine("\t return false;"); return b; } } diff --git a/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.h index a3c69efe4becbe58d489e5114d22192842cab2b5..6202d71e39ce145ff98e28d9c027c67668071344 100644 --- a/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronIVTCByteImageTypeNavigator.h @@ -60,13 +60,15 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: // members - static const std::set<std::string> acceptedTypes; + static const std::map<std::string, unsigned int> acceptedTypes; std::string usedType; unsigned int width; unsigned int height; + unsigned int elementSize; AronIVTCByteImageTypePtr type; }; } diff --git a/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.cpp index e3cc04075ee91dcc184ee93c88756877144fdb70..618d69aca7b3846d77e8fec8dc314b00990a01cf 100644 --- a/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.cpp @@ -119,6 +119,14 @@ namespace armarx b->addBlock(b2); return b; } + + CppBlockPtr AronListTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + b->addLine("if (not (" + accessor + " == " + otherInstanceAccessor + "))"); + b->addLine("\t return false;"); + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.h index 04e39056c4c61be8b4d49b7c9ae56e1036cf2f10..4eb09c4cd55b544a87870de886a453b8e6422700 100644 --- a/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronListTypeNavigator.h @@ -60,6 +60,7 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: // members diff --git a/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.cpp index d28e5503c9083846e879c772b42269d8dd25a21e..942ee2b63be8c82686588098c1b2e3b6dce8f488 100644 --- a/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.cpp @@ -145,6 +145,25 @@ namespace armarx b->addLine("r.readEndDict();"); return b; } + + CppBlockPtr AronObjectTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + if (accessor == "") // object defintiion + { + for (const auto& [key, child] : this->getChildren()) + { + CppBlockPtr b2 = child->getEqualsBlock(key, otherInstanceAccessor + "." + key); + b = CppBlock::mergeBlocks(b, b2); + } + } + else // object usage with existing operator== + { + b->addLine("if (not (" + accessor + " == " + otherInstanceAccessor + "))"); + b->addLine("\t return false;"); + } + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.h index c9ac78785dd0c7b555a2ad0ad5bf4da2565efda8..1a65dcf28217825ce82689e6f715d82671282156 100644 --- a/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronObjectTypeNavigator.h @@ -66,6 +66,7 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: // members diff --git a/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.cpp index ffe078bd6b28f201f9b2743e3e5c3f97e6d057db..9d21a938e7073d21364fa598de46adccc6a590d5 100644 --- a/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.cpp @@ -111,6 +111,12 @@ namespace armarx //b->addLine(accessor + " = " + getFullCppTypename() + "({" + implodeDimensionVector(dimensions) + "}, " + usedType + ", reinterpret_cast<unsigned char*>(r.readBlob()), 0);"); return b; } + + CppBlockPtr AronOpenCVMatTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.h index caeeeba4297b4fd6edca9fd53b5deef4c72825e0..ca5c232a764cd1052433ecb42bb7ed44ed0aff20 100644 --- a/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronOpenCVMatTypeNavigator.h @@ -60,6 +60,7 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: // members diff --git a/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.cpp index 177e580c03e7aee2bc7507782a6e6add68aa95f1..406791501c3a880ee21aa40af9addd6b9a068583 100644 --- a/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.cpp @@ -112,6 +112,12 @@ namespace armarx b->addLine("memcpy(" + accessor + ".points.data(), reinterpret_cast<" + usedType + "*>(r.readBlob()), " + accessor + ".width * " + accessor + ".height);"); return b; } + + CppBlockPtr AronPCLPointcloudTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.h index 8737f4745afa33e18378ba7052b0458cbaf28f16..d9c7fbdfff29a8805dc3434d16d66a72c5f10920 100644 --- a/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronPCLPointcloudTypeNavigator.h @@ -60,6 +60,7 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: // members diff --git a/source/RobotAPI/libraries/aron/types/AronPrimitiveTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronPrimitiveTypeNavigator.h index 495474a20b59b2eb77cf0690f842a91c09a31c60..40fff2417fffd715d3d5cb0dc689e5748d601c24 100644 --- a/source/RobotAPI/libraries/aron/types/AronPrimitiveTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronPrimitiveTypeNavigator.h @@ -103,6 +103,14 @@ namespace armarx return b; } + CppBlockPtr getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const override + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + b->addLine("if (not (" + accessor + " == " + otherInstanceAccessor + "))"); + b->addLine("\t return false;"); + return b; + } + private: // members typename AronAbstractTypeType::PointerType type; diff --git a/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.cpp b/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.cpp index 3324161bbf02684bdf1a5b1f007fb53257b78882..5729a019ca94bcadcac33c6b6aa0b89154c861ff 100644 --- a/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.cpp @@ -161,6 +161,14 @@ namespace armarx b->addLine("r.readEndList();"); return b; } + + CppBlockPtr AronTupleTypeNavigator::getEqualsBlock(const std::string& accessor, const std::string& otherInstanceAccessor) const + { + CppBlockPtr b = CppBlockPtr(new CppBlock()); + b->addLine("if (not (" + accessor + " == " + otherInstanceAccessor + "))"); + b->addLine("\t return false;"); + return b; + } } } } diff --git a/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.h b/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.h index 32808ba09b9ceebb101aad13f3134430e1375b57..9e1ce2919a35cf9efb469e452c3a282b544ded15 100644 --- a/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/types/AronTupleTypeNavigator.h @@ -65,6 +65,7 @@ namespace armarx virtual CppBlockPtr getResetBlock(const std::string&) const override; virtual CppBlockPtr getWriteBlock(const std::string&) const override; virtual CppBlockPtr getReadBlock(const std::string&) const override; + virtual CppBlockPtr getEqualsBlock(const std::string&, const std::string&) const override; private: