diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/CodeWriter.h b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/CodeWriter.h index 8649037d81255c299cb37d5e10c420b7df54fd6e..0e17ccc1ee4938bd81ae462e8a2b069669c25826 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/CodeWriter.h +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/CodeWriter.h @@ -76,10 +76,18 @@ namespace armarx::aron::codegenerator std::vector<MetaEnumPtr> typeEnums; std::string producerName; - std::vector<codegenerator::WriterInfo> dataWriters; - std::vector<codegenerator::ReaderInfo> dataReaders; - std::vector<codegenerator::StaticReaderInfo> staticDataReaders; - std::vector<codegenerator::WriterInfo> initialTypeWriters; + std::vector<codegenerator::WriterInfo> dictDataWriters; + std::vector<codegenerator::WriterInfo> intEnumDataWriters; + + std::vector<codegenerator::ReaderInfo> dictDataReaders; + std::vector<codegenerator::ReaderInfo> intEnumDataReaders; + + std::vector<codegenerator::StaticReaderInfo> staticDictDataReaders; + std::vector<codegenerator::StaticReaderInfo> staticIntEnumDataReaders; + + std::vector<codegenerator::WriterInfo> initialDictTypeWriters; + std::vector<codegenerator::WriterInfo> initialIntEnumTypeWriters; + std::vector<std::string> additionalIncludes; }; } diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/Writer.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/Writer.cpp index 01933af56e82265b8232cdb4bb9b211b4fa8ec10..64d17347e586e80613ef571f8d22d9489d0b522e 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/Writer.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/Writer.cpp @@ -80,90 +80,174 @@ namespace armarx::aron::codegenerator::cpp void Writer::addSpecificWriterMethods() { - // The toAron Serializer is visible by default + // DictData stuff { - codegenerator::WriterInfo toAron; - toAron.methodName = "toAron"; - toAron.returnType = "armarx::aron::data::DictPtr"; - toAron.writerClassType = "armarx::aron::data::writer::VariantWriter"; - toAron.include = "<RobotAPI/libraries/aron/core/data/rw/writer/variant/VariantWriter.h>"; - toAron.enforceConversion = "armarx::aron::data::Dict::DynamicCastAndCheck"; - dataWriters.push_back(toAron); - } - - { - codegenerator::WriterInfo toAronDTO; - toAronDTO.methodName = "toAronDTO"; - toAronDTO.returnType = "armarx::aron::data::dto::DictPtr"; - toAronDTO.writerClassType = "armarx::aron::data::writer::VariantWriter"; - toAronDTO.include = "<RobotAPI/libraries/aron/core/data/rw/writer/variant/VariantWriter.h>"; - toAronDTO.enforceConversion = "armarx::aron::data::Dict::DynamicCastAndCheck"; - toAronDTO.enforceMemberAccess = "->toAronDictDTO()"; - dataWriters.push_back(toAronDTO); - } - - { - // 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 toAron; + toAron.methodName = "toAron"; + toAron.returnType = "armarx::aron::data::DictPtr"; + toAron.writerClassType = "armarx::aron::data::writer::VariantWriter"; + toAron.include = + "<RobotAPI/libraries/aron/core/data/rw/writer/variant/VariantWriter.h>"; + toAron.enforceConversion = "armarx::aron::data::Dict::DynamicCastAndCheck"; + dictDataWriters.push_back(toAron); + } + { + codegenerator::WriterInfo toAronDTO; + toAronDTO.methodName = "toAronDTO"; + toAronDTO.returnType = "armarx::aron::data::dto::DictPtr"; + toAronDTO.writerClassType = "armarx::aron::data::writer::VariantWriter"; + toAronDTO.include = + "<RobotAPI/libraries/aron/core/data/rw/writer/variant/VariantWriter.h>"; + toAronDTO.enforceConversion = "armarx::aron::data::Dict::DynamicCastAndCheck"; + toAronDTO.enforceMemberAccess = "->toAronDictDTO()"; + dictDataWriters.push_back(toAronDTO); + } + { + // 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"; + initialDictTypeWriters.push_back(ToAronType); + } + { + // The toAron Serializer is visible by default + codegenerator::WriterInfo ToAronTypeDTO; + ToAronTypeDTO.methodName = "ToAronTypeDTO"; + ToAronTypeDTO.returnType = "armarx::aron::type::dto::AronObjectPtr"; + ToAronTypeDTO.writerClassType = "armarx::aron::type::writer::VariantWriter"; + ToAronTypeDTO.include = + "<RobotAPI/libraries/aron/core/type/rw/writer/variant/VariantWriter.h>"; + ToAronTypeDTO.enforceConversion = "armarx::aron::type::Object::DynamicCastAndCheck"; + ToAronTypeDTO.enforceMemberAccess = "->toAronObjectDTO()"; + initialDictTypeWriters.push_back(ToAronTypeDTO); + } } + // IntEnum stuff { - // The toAron Serializer is visible by default - codegenerator::WriterInfo ToAronTypeDTO; - ToAronTypeDTO.methodName = "ToAronTypeDTO"; - ToAronTypeDTO.returnType = "armarx::aron::type::dto::AronObjectPtr"; - ToAronTypeDTO.writerClassType = "armarx::aron::type::writer::VariantWriter"; - ToAronTypeDTO.include = "<RobotAPI/libraries/aron/core/type/rw/writer/variant/VariantWriter.h>"; - ToAronTypeDTO.enforceConversion = "armarx::aron::type::Object::DynamicCastAndCheck"; - ToAronTypeDTO.enforceMemberAccess = "->toAronObjectDTO()"; - initialTypeWriters.push_back(ToAronTypeDTO); + { + codegenerator::WriterInfo toAron; + toAron.methodName = "toAron"; + toAron.returnType = "armarx::aron::data::IntPtr"; + toAron.writerClassType = "armarx::aron::data::writer::VariantWriter"; + toAron.include = + "<RobotAPI/libraries/aron/core/data/rw/writer/variant/VariantWriter.h>"; + toAron.enforceConversion = "armarx::aron::data::Int::DynamicCastAndCheck"; + intEnumDataWriters.push_back(toAron); + } + { + codegenerator::WriterInfo toAronDTO; + toAronDTO.methodName = "toAronDTO"; + toAronDTO.returnType = "armarx::aron::data::dto::AronIntPtr"; + toAronDTO.writerClassType = "armarx::aron::data::writer::VariantWriter"; + toAronDTO.include = + "<RobotAPI/libraries/aron/core/data/rw/writer/variant/VariantWriter.h>"; + toAronDTO.enforceConversion = "armarx::aron::data::Int::DynamicCastAndCheck"; + toAronDTO.enforceMemberAccess = "->toAronIntDTO()"; + intEnumDataWriters.push_back(toAronDTO); + } + { + // The toAron Serializer is visible by default + codegenerator::WriterInfo ToAronType; + ToAronType.methodName = "ToAronType"; + ToAronType.returnType = "armarx::aron::type::IntEnumPtr"; + ToAronType.writerClassType = "armarx::aron::type::writer::VariantWriter"; + ToAronType.include = + "<RobotAPI/libraries/aron/core/type/rw/writer/variant/VariantWriter.h>"; + ToAronType.enforceConversion = "armarx::aron::type::IntEnum::DynamicCastAndCheck"; + initialIntEnumTypeWriters.push_back(ToAronType); + } + { + // The toAron Serializer is visible by default + codegenerator::WriterInfo ToAronTypeDTO; + ToAronTypeDTO.methodName = "ToAronTypeDTO"; + ToAronTypeDTO.returnType = "armarx::aron::type::dto::IntEnumPtr"; + ToAronTypeDTO.writerClassType = "armarx::aron::type::writer::VariantWriter"; + ToAronTypeDTO.include = + "<RobotAPI/libraries/aron/core/type/rw/writer/variant/VariantWriter.h>"; + ToAronTypeDTO.enforceConversion = "armarx::aron::type::IntEnum::DynamicCastAndCheck"; + ToAronTypeDTO.enforceMemberAccess = "->toIntEnumDTO()"; + initialIntEnumTypeWriters.push_back(ToAronTypeDTO); + } } } void Writer::addSpecificReaderMethods() { - // The static FromAron Deserializer - { - codegenerator::StaticReaderInfo fromAron; - fromAron.methodName = "FromAron"; - fromAron.argumentType = "armarx::aron::data::DictPtr"; - fromAron.returnType = OWN_TYPE_NAME; - staticDataReaders.push_back(fromAron); - } - - { - codegenerator::StaticReaderInfo fromAronDTO; - fromAronDTO.methodName = "FromAron"; - fromAronDTO.argumentType = "armarx::aron::data::dto::DictPtr"; - fromAronDTO.returnType = OWN_TYPE_NAME; - staticDataReaders.push_back(fromAronDTO); - } - - - // The fromAron Deserializer is visible by default + // Dict stuff { - codegenerator::ReaderInfo fromAron; - fromAron.methodName = "fromAron"; - fromAron.argumentType = "armarx::aron::data::DictPtr"; - fromAron.readerClassType = "armarx::aron::data::reader::VariantReader"; - fromAron.include = "<RobotAPI/libraries/aron/core/data/rw/reader/variant/VariantReader.h>"; - dataReaders.push_back(fromAron); + { + codegenerator::StaticReaderInfo fromAron; + fromAron.methodName = "FromAron"; + fromAron.argumentType = "armarx::aron::data::DictPtr"; + fromAron.returnType = OWN_TYPE_NAME; + staticDictDataReaders.push_back(fromAron); + } + { + codegenerator::StaticReaderInfo fromAronDTO; + fromAronDTO.methodName = "FromAron"; + fromAronDTO.argumentType = "armarx::aron::data::dto::DictPtr"; + fromAronDTO.returnType = OWN_TYPE_NAME; + staticDictDataReaders.push_back(fromAronDTO); + } + { + codegenerator::ReaderInfo fromAron; + fromAron.methodName = "fromAron"; + fromAron.argumentType = "armarx::aron::data::DictPtr"; + fromAron.readerClassType = "armarx::aron::data::reader::VariantReader"; + fromAron.include = "<RobotAPI/libraries/aron/core/data/rw/reader/variant/VariantReader.h>"; + dictDataReaders.push_back(fromAron); + } + { + codegenerator::ReaderInfo fromAronDTO; + fromAronDTO.methodName = "fromAron"; + fromAronDTO.argumentType = "armarx::aron::data::dto::DictPtr"; + fromAronDTO.readerClassType = "armarx::aron::data::reader::VariantReader"; + fromAronDTO.include = "<RobotAPI/libraries/aron/core/data/rw/reader/variant/VariantReader.h>"; + fromAronDTO.enforceConversion = "std::make_shared<armarx::aron::data::Dict>"; + dictDataReaders.push_back(fromAronDTO); + } } + // IntEnum stuff { - codegenerator::ReaderInfo fromAronDTO; - fromAronDTO.methodName = "fromAron"; - fromAronDTO.argumentType = "armarx::aron::data::dto::DictPtr"; - fromAronDTO.readerClassType = "armarx::aron::data::reader::VariantReader"; - fromAronDTO.include = "<RobotAPI/libraries/aron/core/data/rw/reader/variant/VariantReader.h>"; - fromAronDTO.enforceConversion = "std::make_shared<armarx::aron::data::Dict>"; - dataReaders.push_back(fromAronDTO); + { + codegenerator::StaticReaderInfo fromAron; + fromAron.methodName = "FromAron"; + fromAron.argumentType = "armarx::aron::data::IntPtr"; + fromAron.returnType = OWN_TYPE_NAME; + staticIntEnumDataReaders.push_back(fromAron); + } + { + codegenerator::StaticReaderInfo fromAronDTO; + fromAronDTO.methodName = "FromAron"; + fromAronDTO.argumentType = "armarx::aron::data::dto::AronIntPtr"; + fromAronDTO.returnType = OWN_TYPE_NAME; + staticIntEnumDataReaders.push_back(fromAronDTO); + } + { + codegenerator::ReaderInfo fromAron; + fromAron.methodName = "fromAron"; + fromAron.argumentType = "armarx::aron::data::IntPtr"; + fromAron.readerClassType = "armarx::aron::data::reader::VariantReader"; + fromAron.include = "<RobotAPI/libraries/aron/core/data/rw/reader/variant/VariantReader.h>"; + intEnumDataReaders.push_back(fromAron); + } + { + codegenerator::ReaderInfo fromAronDTO; + fromAronDTO.methodName = "fromAron"; + fromAronDTO.argumentType = "armarx::aron::data::dto::AronIntPtr"; + fromAronDTO.readerClassType = "armarx::aron::data::reader::VariantReader"; + fromAronDTO.include = + "<RobotAPI/libraries/aron/core/data/rw/reader/variant/VariantReader.h>"; + fromAronDTO.enforceConversion = "std::make_shared<armarx::aron::data::Int>"; + intEnumDataReaders.push_back(fromAronDTO); + } } } @@ -210,7 +294,7 @@ namespace armarx::aron::codegenerator::cpp } // Writermethods - for (codegenerator::WriterInfo info : dataWriters) + for (codegenerator::WriterInfo info : dictDataWriters) { if (info.returnType == OWN_TYPE_NAME) { @@ -227,7 +311,7 @@ namespace armarx::aron::codegenerator::cpp // Add methods to set the member variables // also resolve the original class name if the return type is set to special - for (codegenerator::StaticReaderInfo info : staticDataReaders) + for (codegenerator::StaticReaderInfo info : staticDictDataReaders) { if (info.returnType == OWN_TYPE_NAME) { @@ -243,7 +327,7 @@ namespace armarx::aron::codegenerator::cpp } // Add methods to set the member variables - for (codegenerator::ReaderInfo info : dataReaders) + for (codegenerator::ReaderInfo info : dictDataReaders) { if (info.argumentType == OWN_TYPE_NAME) { @@ -259,7 +343,7 @@ namespace armarx::aron::codegenerator::cpp } // Typewritermethods - for (codegenerator::WriterInfo info : initialTypeWriters) + for (codegenerator::WriterInfo info : initialDictTypeWriters) { if (info.returnType == OWN_TYPE_NAME) { @@ -293,6 +377,8 @@ namespace armarx::aron::codegenerator::cpp // Generate aron wrapper class and add to classes CppClassPtr c = setupBasicCppClass(publicGenerateIntEnumType, generator); + c->addInclude("<RobotAPI/libraries/aron/core/data/variant/primitive/Int.h>"); + setupMemberFields(c, publicGenerateIntEnumType.doc_values, generator); c->addInherit("public armarx::aron::cpp::AronGeneratedClass"); @@ -319,7 +405,7 @@ namespace armarx::aron::codegenerator::cpp c->addMethod(enumAssignment3); // Writermethods - for (codegenerator::WriterInfo info : dataWriters) + for (codegenerator::WriterInfo info : intEnumDataWriters) { if (info.returnType == OWN_TYPE_NAME) { @@ -336,7 +422,7 @@ namespace armarx::aron::codegenerator::cpp // Add methods to set the member variables // also resolve the original class name if the return type is set to special - for (codegenerator::StaticReaderInfo info : staticDataReaders) + for (codegenerator::StaticReaderInfo info : staticIntEnumDataReaders) { if (info.returnType == OWN_TYPE_NAME) { @@ -352,7 +438,7 @@ namespace armarx::aron::codegenerator::cpp } // Add methods to set the member variables - for (codegenerator::ReaderInfo info : dataReaders) + for (codegenerator::ReaderInfo info : intEnumDataReaders) { if (info.argumentType == OWN_TYPE_NAME) { @@ -368,7 +454,7 @@ namespace armarx::aron::codegenerator::cpp } // Typewritermethods - for (codegenerator::WriterInfo info : initialTypeWriters) + for (codegenerator::WriterInfo info : initialIntEnumTypeWriters) { if (info.returnType == OWN_TYPE_NAME) {