diff --git a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h index a2b724af0ceb6a029c76db86341e8445c725eebc..0d0b108f4fea35354169e76956571ffb60daab09 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h +++ b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h @@ -97,10 +97,10 @@ namespace armarx::aron::typereader::xml const std::string QUATERNION_TAG = "quaternion"; const std::string IMAGE_TAG = "image"; const std::string POINT_CLOUD_TAG = "pointcloud"; - const std::string INT_TAG = "int"; - const std::string LONG_TAG = "long"; - const std::string FLOAT_TAG = "float"; - const std::string DOUBLE_TAG = "double"; + const std::string INT_TAG = "int32"; + const std::string LONG_TAG = "int64"; + const std::string FLOAT_TAG = "float32"; + const std::string DOUBLE_TAG = "float64"; const std::string STRING_TAG = "string"; const std::string BOOL_TAG = "bool"; const std::string ANY_OBJECT_TAG = "anyobject"; @@ -108,21 +108,32 @@ namespace armarx::aron::typereader::xml // others const std::vector<std::string> WHATEVER_VALUES = {"?"}; - // Replacements ({tagName, {replacementsTag, additionalAronDTOXMLIncludePackagePath}}) - const std::map<std::string, std::pair<std::string, std::pair<std::string, std::string>>> REPLACEMENTS = + struct Replacement { - {"position", {"<matrix rows='3' cols='1' type='float32' />", {}}}, - {"pose", {"<matrix rows='4' cols='4' type='float32' />", {}}}, - {"orientation", {"<quaternion type='float32' />", {}}}, + std::string replacementTag; + std::pair<std::string, std::string> additionalAronDTOXMLIncludePackagePath; + std::string deprecatedWarning; + }; + + // Replacements ({tagName, {replacementsTag, additionalAronDTOXMLIncludePackagePath}, deprecationwarning}) + const std::map<std::string, Replacement> REPLACEMENTS = + { + {"int", {"<int32 />", {}, "The <int />-tag is deprecated. Please use <int32 /> instead."}}, + {"long", {"<int64 />", {}, "The <long />-tag is deprecated. Please use <int64 /> instead."}}, + {"float", {"<float32 />", {}, "The <float />-tag is deprecated. Please use <float32 /> instead."}}, + {"double", {"<float64 />", {}, "The <double />-tag is deprecated. Please use <float64 /> instead."}}, + {"position", {"<matrix rows='3' cols='1' type='float32' />", {}, ""}}, + {"pose", {"<matrix rows='4' cols='4' type='float32' />", {}, ""}}, + {"orientation", {"<quaternion type='float32' />", {}, ""}}, // You can also add replacements for arondtos here! - // structure: {xml-identifier, {replacement, auto-include}} - {"datetime", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}}}, - {"time", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}}}, - {"duration", {"<armarx::arondto::Duration />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}}}, - {"framedposition", {"<armarx::arondto::FramedPosition />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}}}, - {"framedorientation", {"<armarx::arondto::FramedOrientation />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}}}, - {"framedpose", {"<armarx::arondto::FramedPose />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}}} + // structure: {xml-identifier, {replacement, auto-include}, deprecationwarning} + {"datetime", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}}, + {"time", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}}, + {"duration", {"<armarx::arondto::Duration />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}}, + {"framedposition", {"<armarx::arondto::FramedPosition />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}}, + {"framedorientation", {"<armarx::arondto::FramedOrientation />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}}, + {"framedpose", {"<armarx::arondto::FramedPose />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}} }; } diff --git a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Factory.cpp b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Factory.cpp index 9b17f8aa6ec6cfb67dbb14ccaae3e97eb9b5c111..8409c87ba128e86bab38cf78f0994d34f35844fe 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Factory.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Factory.cpp @@ -30,11 +30,16 @@ #include "Factory.h" // ArmarX +#include <ArmarXCore/core/time/DateTime.h> #include <RobotAPI/libraries/aron/core/type/variant/All.h> #include "Data.h" namespace armarx::aron::typereader::xml { + void printDeprecationWarning(const std::string& warning) + { + std::cout << "\033[1;33mAron deprecation warning: " << warning << "\033[0m" << std::endl; + } type::VariantPtr ReaderFactory::create(const RapidXmlReaderNode& node, const Path& path) { @@ -65,8 +70,14 @@ namespace armarx::aron::typereader::xml // check for replacement if (auto it = constantes::REPLACEMENTS.find(simox::alg::to_lower(nodeToUse.name())); it != constantes::REPLACEMENTS.end()) { + auto replacement = it->second; + if (!replacement.deprecatedWarning.empty()) + { + printDeprecationWarning(replacement.deprecatedWarning); + } + // We make the system believe there is another string in the xml - RapidXmlReaderPtr reader = RapidXmlReader::FromXmlString(it->second.first); + RapidXmlReaderPtr reader = RapidXmlReader::FromXmlString(replacement.replacementTag); nodeToUse = reader->getRoot(); } diff --git a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Reader.cpp b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Reader.cpp index 0ca73e5b6e72da48d81babbd19efb49cc0c929e3..7e9c71cbecf3c5dd9d8952135b61625a84ce1a27 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Reader.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Reader.cpp @@ -350,10 +350,12 @@ namespace armarx::aron::typereader::xml std::vector<std::pair<std::string, std::string>> ret; for (const auto& repl : constantes::REPLACEMENTS) { - if (not repl.second.second.first.empty() && not repl.second.second.second.empty() && util::HasTagName(node, repl.first)) + auto replacement = repl.second; + + if (not replacement.additionalAronDTOXMLIncludePackagePath.first.empty() && not replacement.additionalAronDTOXMLIncludePackagePath.second.empty() && util::HasTagName(node, repl.first)) { // we found a string that will be replaced so we might need to add a default include - ret.push_back(repl.second.second); + ret.push_back(replacement.additionalAronDTOXMLIncludePackagePath); break; } }