Skip to content
Snippets Groups Projects
Commit b68d7bab authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

Merge branch 'aron/dev' into fabianpk

# Conflicts:
#	source/RobotAPI/libraries/aron/converter/common/VectorConverter.h
parents 9573c5e5 c47f2540
No related branches found
No related tags found
1 merge request!337Merge fabianpk dev branch
......@@ -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"}, ""}}
};
}
......
......@@ -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();
}
......
......@@ -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;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment