diff --git a/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp index cb2ba76bf3a1a2bf3f739c52692ef5ebf0f8cb4a..07b09a338d33e9aade018ae890d712ca7c69a819 100644 --- a/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp +++ b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp @@ -61,7 +61,7 @@ namespace armarx void ExampleMemory::onInitComponent() { // Usually, the memory server will specify a number of core segments with a specific aron type. - workingMemory().addCoreSegment("ExampleData", armem::example::ExampleData::toAronType()); + workingMemory().addCoreSegment("ExampleData", armem::example::ExampleData::ToAronType()); // For illustration purposes, we add more segments (without types). bool trim = true; diff --git a/source/RobotAPI/components/armem/server/ExampleMemory/test/ExampleMemoryTest.cpp b/source/RobotAPI/components/armem/server/ExampleMemory/test/ExampleMemoryTest.cpp index c3d2b817956435a450b1f3ae0a91ebc20044c314..5526876a302cd9658036a9603b753e47fd721121 100644 --- a/source/RobotAPI/components/armem/server/ExampleMemory/test/ExampleMemoryTest.cpp +++ b/source/RobotAPI/components/armem/server/ExampleMemory/test/ExampleMemoryTest.cpp @@ -39,7 +39,7 @@ namespace armem = armarx::armem; BOOST_AUTO_TEST_CASE(test_ExampleData_type) { - armarx::aron::type::ObjectPtr type = ExampleData::toAronType(); + armarx::aron::type::ObjectPtr type = ExampleData::ToAronType(); BOOST_CHECK_EQUAL(type->childrenSize(), 16); diff --git a/source/RobotAPI/components/armem/server/GraspMemory/GraspMemory.cpp b/source/RobotAPI/components/armem/server/GraspMemory/GraspMemory.cpp index 144f9edcd76acbbe536084229dfe440804add7e2..e1b4bfd86c1b66ce9401aa75278e63e5e304e876 100644 --- a/source/RobotAPI/components/armem/server/GraspMemory/GraspMemory.cpp +++ b/source/RobotAPI/components/armem/server/GraspMemory/GraspMemory.cpp @@ -40,11 +40,11 @@ namespace armarx::armem::server::grasp workingMemory().name() = memoryName; workingMemory().addCoreSegment("GraspCandidate", - armarx::grasping::arondto::GraspCandidate::toAronType()); + armarx::grasping::arondto::GraspCandidate::ToAronType()); workingMemory().addCoreSegment("BimanualGraspCandidate", - armarx::grasping::arondto::BimanualGraspCandidate::toAronType()); + armarx::grasping::arondto::BimanualGraspCandidate::ToAronType()); workingMemory().addCoreSegment("KnownGraspCandidate", - armarx::armem::grasping::arondto::KnownGraspInfo::toAronType()); + armarx::armem::grasping::arondto::KnownGraspInfo::ToAronType()); knownGraspProviderSegment.init(); } diff --git a/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp b/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp index 485a5e07d83fd42776d0f959186b4b4c764b1bf5..1ddbdb5a9efa1c2c98b4baefdb1e805a9af90fb8 100644 --- a/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp +++ b/source/RobotAPI/components/skills/SkillProviderExample/SkillProviderExample.cpp @@ -16,7 +16,7 @@ namespace armarx::skills::provider "This skill logs a message on ARMARX_IMPORTANT", {}, 1000, - armarx::skills::Example::HelloWorldAcceptedType::toAronType() + armarx::skills::Example::HelloWorldAcceptedType::ToAronType() }) {} Skill::Status HelloWorldSkill::_execute(const aron::data::DictPtr& d, const CallbackT&) diff --git a/source/RobotAPI/libraries/armem_gui/instance/sanitize_typename.cpp b/source/RobotAPI/libraries/armem_gui/instance/sanitize_typename.cpp index bc4b1878fba11a5e9621735b9bee19e72548b05c..bc941f8aac4ccc2d8440eec70c1014b3f713c7bc 100644 --- a/source/RobotAPI/libraries/armem_gui/instance/sanitize_typename.cpp +++ b/source/RobotAPI/libraries/armem_gui/instance/sanitize_typename.cpp @@ -7,7 +7,7 @@ #include <RobotAPI/libraries/armem/aron/MemoryID.aron.generated.h> -const std::string armarx::armem::gui::instance::rawMemoryIDTypeName = armarx::armem::arondto::MemoryID::toAronType()->getFullName(); +const std::string armarx::armem::gui::instance::rawMemoryIDTypeName = armarx::armem::arondto::MemoryID::ToAronType()->getFullName(); const std::string armarx::armem::gui::instance::sanitizedMemoryIDTypeName = "MemoryID"; diff --git a/source/RobotAPI/libraries/armem_motions/server/MotionSegment.cpp b/source/RobotAPI/libraries/armem_motions/server/MotionSegment.cpp index 0122739bc280f1b99ce932d7a72b2779556888d6..7b83360d50562977bf629a9ca4116f1c91089219 100644 --- a/source/RobotAPI/libraries/armem_motions/server/MotionSegment.cpp +++ b/source/RobotAPI/libraries/armem_motions/server/MotionSegment.cpp @@ -20,7 +20,7 @@ namespace armarx::armem::server::motions::mdb::segment { MDBMotionSegment::MDBMotionSegment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - Base(memoryToIceAdapter, "MotionDatabase", "Motion", armarx::motion::mdb::arondto::MDBReference::toAronType()) + Base(memoryToIceAdapter, "MotionDatabase", "Motion", armarx::motion::mdb::arondto::MDBReference::ToAronType()) { } diff --git a/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.cpp index 2c60cb9bd35ab7b3010e5b5f5fb0e719d0817f98..59a9a3474a82235d8bf19a7ee3510084c35f96f2 100644 --- a/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.cpp @@ -42,7 +42,7 @@ namespace armarx::armem::server::obj::attachments { ARMARX_CHECK_NOT_NULL(iceMemory.workingMemory); - coreSegment = &iceMemory.workingMemory->addCoreSegment(p.coreSegmentName, arondto::Robot::toAronType()); + coreSegment = &iceMemory.workingMemory->addCoreSegment(p.coreSegmentName, arondto::Robot::ToAronType()); coreSegment->setMaxHistorySize(p.maxHistorySize); } diff --git a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp index 2eed2afc7ee6d391a0ef084cc218d330e5776b01..a0e9bce51558d7fb39caf50a331919dc16034793 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp @@ -22,7 +22,7 @@ namespace armarx::armem::server::obj::clazz { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - SpecializedCoreSegment(memoryToIceAdapter, "Class", arondto::ObjectClass::toAronType(), -1) + SpecializedCoreSegment(memoryToIceAdapter, "Class", arondto::ObjectClass::ToAronType(), -1) { } diff --git a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp index 96369565e92c7747a33f627e6b8f98ab20ff52c7..f28cd81e1767d5e2ba6b983b8bbe9efed4958ef4 100644 --- a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp @@ -46,7 +46,7 @@ namespace armarx::armem::server::obj::instance Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : SpecializedCoreSegment(memoryToIceAdapter, "Instance", - arondto::ObjectInstance::toAronType(), 64) + arondto::ObjectInstance::ToAronType(), 64) { oobbCache.setFetchFn([this](const ObjectID & id) -> std::optional<simox::OrientedBoxf> { diff --git a/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp index cada3f5609ba137007e80cf8b3b2c102e1db591a..185356425ca3d657014f2b0e0b2e56631e443f4f 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp @@ -26,7 +26,7 @@ namespace armarx::armem::server::robot_state::description { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - Base(memoryToIceAdapter, "Description", arondto::RobotDescription::toAronType()) + Base(memoryToIceAdapter, "Description", arondto::RobotDescription::ToAronType()) { } @@ -47,7 +47,7 @@ namespace armarx::armem::server::robot_state::description const Time now = TimeUtil::GetTime(); const MemoryID providerID = segmentPtr->id().withProviderSegmentName(robotDescription.name); - segmentPtr->addProviderSegment(providerID.providerSegmentName, arondto::RobotDescription::toAronType()); + segmentPtr->addProviderSegment(providerID.providerSegmentName, arondto::RobotDescription::ToAronType()); EntityUpdate update; update.entityID = providerID.withEntityName("description"); diff --git a/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp index 897858e4cfa215623682d4034a61beb74681e488..e5a017d97720a9b66dc4047af37209d91313f02c 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp @@ -26,7 +26,7 @@ namespace armarx::armem::server::robot_state::localization { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - Base(memoryToIceAdapter, "Localization", arondto::Transform::toAronType(), 1024) + Base(memoryToIceAdapter, "Localization", arondto::Transform::ToAronType(), 1024) { } diff --git a/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp index 4f2c301e0c80f5230eecc672ad76e6c3b1f8567f..9bf3f1e8129fe0d2f2194d1f9e223077678e93f0 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp @@ -16,7 +16,7 @@ namespace armarx::armem::server::robot_state::proprioception { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - Base(memoryToIceAdapter, "Proprioception", arondto::Proprioception::toAronType(), 1024) + Base(memoryToIceAdapter, "Proprioception", arondto::Proprioception::ToAronType(), 1024) { } diff --git a/source/RobotAPI/libraries/armem_skills/server/segment/ExecutableSkillLibrarySegment.cpp b/source/RobotAPI/libraries/armem_skills/server/segment/ExecutableSkillLibrarySegment.cpp index 3c9d18f33ad2e7a07b38913795b385b77a9e7f91..1419ddf440ad718bc6c4252c7678b2c607534ab2 100644 --- a/source/RobotAPI/libraries/armem_skills/server/segment/ExecutableSkillLibrarySegment.cpp +++ b/source/RobotAPI/libraries/armem_skills/server/segment/ExecutableSkillLibrarySegment.cpp @@ -10,7 +10,7 @@ namespace armarx::skills::segment { ExecutableSkillLibraryCoreSegment::ExecutableSkillLibraryCoreSegment(armem::server::MemoryToIceAdapter& iceMemory): - Base(iceMemory, CoreSegmentName, skills::arondto::SkillDescription::toAronType()) + Base(iceMemory, CoreSegmentName, skills::arondto::SkillDescription::ToAronType()) { } diff --git a/source/RobotAPI/libraries/armem_skills/server/segment/SkillExecutionRequestSegment.cpp b/source/RobotAPI/libraries/armem_skills/server/segment/SkillExecutionRequestSegment.cpp index 57151c646f1206a45e689714c37dfac3508aeb88..5068cb04d910100a936b6934ef30fcaafb599f48 100644 --- a/source/RobotAPI/libraries/armem_skills/server/segment/SkillExecutionRequestSegment.cpp +++ b/source/RobotAPI/libraries/armem_skills/server/segment/SkillExecutionRequestSegment.cpp @@ -12,7 +12,7 @@ namespace armarx::skills::segment { SkillExecutionRequestCoreSegment::SkillExecutionRequestCoreSegment(armem::server::MemoryToIceAdapter& iceMemory): - Base(iceMemory, CoreSegmentName/*, skills::arondto::SkillExecutionRequest::toAronType()*/) + Base(iceMemory, CoreSegmentName/*, skills::arondto::SkillExecutionRequest::ToAronType()*/) { } diff --git a/source/RobotAPI/libraries/armem_skills/server/segment/StatechartListenerSegment.cpp b/source/RobotAPI/libraries/armem_skills/server/segment/StatechartListenerSegment.cpp index b3c4e1599ef66329f10a1e09fd7efa132acaba26..cee0e3a18293dfa15534ece89c8d40f6afdca8cd 100644 --- a/source/RobotAPI/libraries/armem_skills/server/segment/StatechartListenerSegment.cpp +++ b/source/RobotAPI/libraries/armem_skills/server/segment/StatechartListenerSegment.cpp @@ -6,7 +6,7 @@ namespace armarx::skills::segment { StatechartListenerProviderSegment::StatechartListenerProviderSegment(armem::server::MemoryToIceAdapter& iceMemory): - Base(iceMemory, "StatechartListener", "Transitions", arondto::Statechart::Transition::toAronType()) + Base(iceMemory, "StatechartListener", "Transitions", arondto::Statechart::Transition::ToAronType()) { } diff --git a/source/RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/Writer.cpp b/source/RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/Writer.cpp index 4524241501e40896ee26150bde92ae85713fadb7..4ed774fb7f798efb5c5f3bf16cadaae5be22eb52 100644 --- a/source/RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/Writer.cpp +++ b/source/RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/Writer.cpp @@ -54,13 +54,13 @@ namespace armarx::aron::codegenerator::cpp { // The toAron Serializer is visible by default - codegenerator::WriterInfo toAronType; - toAronType.methodName = "toAronType"; - toAronType.returnType = "armarx::aron::type::ObjectPtr"; - toAronType.writerClassType = "armarx::aron::type::writer::VariantWriter"; - toAronType.include = "<RobotAPI/libraries/aron/core/type/rw/writer/variant/VariantWriter.h>"; - toAronType.enforceConversion = "armarx::aron::type::Object::DynamicCastAndCheck"; - initialTypeWriters.push_back(toAronType); + codegenerator::WriterInfo ToAronType; + ToAronType.methodName = "ToAronType"; + ToAronType.returnType = "armarx::aron::type::ObjectPtr"; + ToAronType.writerClassType = "armarx::aron::type::writer::VariantWriter"; + ToAronType.include = "<RobotAPI/libraries/aron/core/type/rw/writer/variant/VariantWriter.h>"; + ToAronType.enforceConversion = "armarx::aron::type::Object::DynamicCastAndCheck"; + initialTypeWriters.push_back(ToAronType); } // toJSON Method @@ -128,17 +128,31 @@ namespace armarx::aron::codegenerator::cpp generator::ObjectClass generator(*type); CppClassPtr c = setupBasicCppClass(publicGenerateObjectType, generator); + + if (!type->getTemplates().empty()) + { + std::vector<std::string> tmpl; + std::vector<std::string> tmpl_requires; + for (auto& t : type->getTemplates()) + { + tmpl_requires.push_back("armarx::aron::codegenerator::cpp::isAronGeneratedClass<" + t + ">"); + tmpl.push_back("class " + t); + } + std::string templateDef = "template <" + simox::alg::join(tmpl, ", ") + ">"; + std::string requiresDef = "requires " + simox::alg::join(tmpl_requires, " && "); + c->setTemplates(templateDef + "\n" + requiresDef); + } setupMemberFields(c, publicGenerateObjectType.doc_members, generator); if (type->getExtends() != nullptr) { generator::ObjectClass extendsSerializer(*type->getExtends()); - c->addInherit("public " + extendsSerializer.getFullCppTypename()); + c->addInherit("public " + extendsSerializer.getFullInstantiatedCppTypename()); } else { - c->addInherit("public armarx::aron::codegenerator::cpp::AronCppClass"); - c->addInclude("<RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/AronCppClass.h>"); + c->addInherit("public armarx::aron::codegenerator::cpp::AronGeneratedClass"); + c->addInclude("<RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/AronGeneratedClass.h>"); } for (const std::string& s : additionalIncludes) @@ -208,8 +222,8 @@ namespace armarx::aron::codegenerator::cpp CppClassPtr c = setupBasicCppClass(publicGenerateIntEnumType, generator); setupMemberFields(c, publicGenerateIntEnumType.doc_values, generator); - c->addInherit("public armarx::aron::codegenerator::cpp::AronCppClass"); - c->addInclude("<RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/AronCppClass.h>"); + c->addInherit("public armarx::aron::codegenerator::cpp::AronGeneratedClass"); + c->addInclude("<RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/AronGeneratedClass.h>"); // ctor c->addCtor(generator.toCopyCtor(c->getName())); @@ -243,18 +257,19 @@ namespace armarx::aron::codegenerator::cpp CppClassPtr Writer::setupBasicCppClass(const typereader::GenerateInfo& info, const Generator& gen) const { - const std::string cppTypename = gen.getFullCppTypename(); - std::vector<std::string> split = simox::alg::split(cppTypename, "::"); - if (split.size() < 1) + const auto& type = gen.getType(); + if (type.getMaybe() != type::Maybe::eNone) { - throw error::AronException(__PRETTY_FUNCTION__, "The cpp name of an inner type was empty. Please check the type definition file if all object names are set correctly."); + // Should not happen since we check the maybe flag on creation of the generator. However, better to double check + throw error::ValueNotValidException(__PRETTY_FUNCTION__, "Somehow the maybe flag of a top level object declaration is set. This is not valid!", std::to_string((int) type.getMaybe()) + " aka " + type::defaultconversion::string::Maybe2String.at(type.getMaybe()), type.getPath()); } - std::vector<std::string> namespaces(split); - namespaces.pop_back(); + const std::string classCppTypename = gen.getClassCppTypename(); - CppClassPtr c = std::make_shared<CppClass>(namespaces, split[split.size() - 1]); + std::vector<std::string> namespaces = info.getNamespaces(); + std::string rawObjectName = info.getNameWithoutNamespace(); + CppClassPtr c = std::make_shared<CppClass>(namespaces, rawObjectName); // Add includes and guard std::string classDoc = "******************************************\n" "* AUTOGENERATED CLASS. Please do NOT edit.\n" @@ -272,8 +287,9 @@ namespace armarx::aron::codegenerator::cpp c->addInclude("<vector>"); c->addInclude("<map>"); c->addInclude("<RobotAPI/interface/aron.h>"); + c->addInclude("<RobotAPI/libraries/aron/core/data/converter/variant/VariantConverter.h>"); - c->addPublicField(std::string("using ") + OWN_TYPE_NAME + " = " + cppTypename + ";"); + c->addPublicField(std::string("using ") + OWN_TYPE_NAME + " = " + classCppTypename + ";"); // ctor c->addCtor(gen.toCtor(c->getName()));