diff --git a/source/RobotAPI/applications/AronCodeGenerator/main.cpp b/source/RobotAPI/applications/AronCodeGenerator/main.cpp index 046053dfb6d34a4979807b7eaf4dd43b7db01367..04511deab1bc537552220e5896a4a849812baf32 100644 --- a/source/RobotAPI/applications/AronCodeGenerator/main.cpp +++ b/source/RobotAPI/applications/AronCodeGenerator/main.cpp @@ -39,8 +39,8 @@ #include <ArmarXCore/libraries/cppgen/CppMethod.h> #include <ArmarXCore/libraries/cppgen/CppClass.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReader.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/AronCppWriter.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/AronTypeXMLReader.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/AronCppWriter.h> using namespace armarx; using namespace aron; diff --git a/source/RobotAPI/components/armem/ArMemDebugMemory/ArMemDebugMemory.cpp b/source/RobotAPI/components/armem/ArMemDebugMemory/ArMemDebugMemory.cpp deleted file mode 100644 index 859bbd4a23a6dd324ae884bd1aa0cf4cb6dcb804..0000000000000000000000000000000000000000 --- a/source/RobotAPI/components/armem/ArMemDebugMemory/ArMemDebugMemory.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of ArmarX. - * - * 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/>. - * - * @package RobotAPI::ArmarXObjects::ArMemDebugMemory - * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) - * @date 2020 - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#include "ArMemDebugMemory.h" - -#include <ArmarXCore/core/exceptions/local/ExpressionException.h> - -#include <SimoxUtility/algorithm/string.h> - -#include <RobotAPI/libraries/armem/core/error.h> -#include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> - -namespace armarx -{ - ArMemDebugMemoryPropertyDefinitions::ArMemDebugMemoryPropertyDefinitions(std::string prefix) : - armarx::ComponentPropertyDefinitions(prefix) - { - } - - ArMemDebugMemory::ArMemDebugMemory() - { - } - - armarx::PropertyDefinitionsPtr ArMemDebugMemory::createPropertyDefinitions() - { - armarx::PropertyDefinitionsPtr defs = new ArMemDebugMemoryPropertyDefinitions(getConfigIdentifier()); - - defs->topic(debugObserver); - return defs; - } - - - std::string ArMemDebugMemory::getDefaultName() const - { - return "ArMemDebugMemory"; - } - - - void ArMemDebugMemory::onInitComponent() - { - memory.name() = memoryName; - } - - - void ArMemDebugMemory::onConnectComponent() - { - RemoteGui__createTab(); - RemoteGui_startRunningTask(); - } - - - void ArMemDebugMemory::onDisconnectComponent() - { - } - - - void ArMemDebugMemory::onExitComponent() - { - } - - - - // WRITING - armem::data::AddSegmentsResult ArMemDebugMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) - { - armem::data::AddSegmentsResult result = ComponentPluginUser::addSegments(input, addCoreSegmentOnUsage); - tab.rebuild = true; - return result; - } - - - armem::data::CommitResult ArMemDebugMemory::commit(const armem::data::Commit& commit, const Ice::Current&) - { - armem::data::CommitResult result = ComponentPluginUser::commit(commit); - tab.rebuild = true; - return result; - } - - - // READING - - // Inherited from Plugin - - - - // REMOTE GUI - - void ArMemDebugMemory::RemoteGui__createTab() - { - using namespace armarx::RemoteGui::Client; - - armem::server::MemoryRemoteGui mrg; - { - std::scoped_lock lock(memoryMutex); - tab.memoryGroup = mrg.makeGroupBox(memory); - } - - VBoxLayout root = {tab.memoryGroup, VSpacer()}; - RemoteGui_createTab(getName(), root, &tab); - } - - - void ArMemDebugMemory::RemoteGui_update() - { - if (tab.rebuild.exchange(false)) - { - RemoteGui__createTab(); - } - } - -} diff --git a/source/RobotAPI/components/armem/ArMemDebugMemory/xmls/ExampleData.xml b/source/RobotAPI/components/armem/ArMemDebugMemory/xmls/ExampleData.xml deleted file mode 100644 index 0cd92acebcb91a793a58a7ce09896ac8c2f91214..0000000000000000000000000000000000000000 --- a/source/RobotAPI/components/armem/ArMemDebugMemory/xmls/ExampleData.xml +++ /dev/null @@ -1,86 +0,0 @@ -<!--Some fancy comment --> -<?xml version="1.0" encoding="UTF-8" ?> -<AronTypeDefinition> - <CodeIncludes> - <Include include="<Eigen/Core>" /> - <Include include="<Image/ByteImage.h>" /> - </CodeIncludes> - <GenerateTypes> - <GenerateType name='armarx::armem::aron::example::ExampleData'> - <ObjectChild key='the_int'> - <Int /> - </ObjectChild> - <ObjectChild key='the_long'> - <Long /> - </ObjectChild> - <ObjectChild key='the_float'> - <Float /> - </ObjectChild> - <ObjectChild key='the_double'> - <Double /> - </ObjectChild> - <ObjectChild key='the_string'> - <String /> - </ObjectChild> - <ObjectChild key='the_bool'> - <Bool /> - </ObjectChild> - - - <ObjectChild key='the_eigen_position'> - <EigenMatrix rows="3" cols="1" type="float" /> - </ObjectChild> - <ObjectChild key='the_eigen_pose'> - <EigenMatrix rows="4" cols="4" type="float" /> - </ObjectChild> - <ObjectChild key='the_ivt_image'> - <IVTCByteImage type="GrayScale" /> - </ObjectChild> - - - <ObjectChild key='the_float_list'> - <List> - <Float /> - </List> - </ObjectChild> - <ObjectChild key='the_int_list'> - <List> - <Int /> - </List> - </ObjectChild> - <ObjectChild key='the_string_list'> - <List> - <String /> - </List> - </ObjectChild> - - <ObjectChild key='the_object_list'> - <List> - <Object name='ListClass'> - <ObjectChild key='element_int'> - <Int /> - </ObjectChild> - <ObjectChild key='element_float'> - <Float /> - </ObjectChild> - <ObjectChild key='element_string'> - <String /> - </ObjectChild> - </Object> - </List> - </ObjectChild> - - <ObjectChild key='the_float_dict'> - <Dict> - <Float /> - </Dict> - </ObjectChild> - <ObjectChild key='the_int_dict'> - <Dict> - <Int /> - </Dict> - </ObjectChild> - - </GenerateType> - </GenerateTypes> -</AronTypeDefinition> diff --git a/source/RobotAPI/components/armem/ArMemExampleMemory/test/CMakeLists.txt b/source/RobotAPI/components/armem/ArMemExampleMemory/test/CMakeLists.txt deleted file mode 100644 index 8c8e23c047ea826570eaaa45c497838112124af8..0000000000000000000000000000000000000000 --- a/source/RobotAPI/components/armem/ArMemExampleMemory/test/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -# Libs required for the tests -SET(LIBS ${LIBS} ArmarXCore ArMemExampleMemory) - -armarx_add_test(ArMemExampleMemoryTest ArMemExampleMemoryTest.cpp "${LIBS}") diff --git a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/test/CMakeLists.txt b/source/RobotAPI/components/armem/ArMemMemoryNameSystem/test/CMakeLists.txt deleted file mode 100644 index aeab2d50f304cf5fe4081deb1c7b7cab6be175f4..0000000000000000000000000000000000000000 --- a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/test/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -# Libs required for the tests -SET(LIBS ${LIBS} ArmarXCore ArMemMemoryNameSystem) - -armarx_add_test(ArMemMemoryNameSystemTest ArMemMemoryNameSystemTest.cpp "${LIBS}") diff --git a/source/RobotAPI/components/armem/CMakeLists.txt b/source/RobotAPI/components/armem/CMakeLists.txt index 6d4b4b0bf0e91cff4278a646479140f9afd27b59..6d75a1af055cfcb0bf49a8785be427cf7b955cf8 100644 --- a/source/RobotAPI/components/armem/CMakeLists.txt +++ b/source/RobotAPI/components/armem/CMakeLists.txt @@ -1,4 +1,14 @@ -add_subdirectory(ArMemExampleMemory) -add_subdirectory(ArMemDebugMemory) -add_subdirectory(ArMemExampleClient) -add_subdirectory(ArMemMemoryNameSystem) +# memory servers +add_subdirectory(server/ExampleMemory) +add_subdirectory(server/GeneralPurposeMemory) +add_subdirectory(server/RobotSensorMemory) +add_subdirectory(server/SkillsMemory) + +# memory server addons + + +# clients +add_subdirectory(client/ExampleClient) + +# The memory name system +add_subdirectory(MemoryNameSystem) diff --git a/source/RobotAPI/components/armem/MemoryNameSystem/CMakeLists.txt b/source/RobotAPI/components/armem/MemoryNameSystem/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..75a50c54304d11e5452f1e4d1f8287a65fd0e9f6 --- /dev/null +++ b/source/RobotAPI/components/armem/MemoryNameSystem/CMakeLists.txt @@ -0,0 +1,22 @@ +armarx_component_set_name("MemoryNameSystem") + + +set(COMPONENT_LIBS + ArmarXCore ArmarXCoreInterfaces # for DebugObserverInterface + ArmarXGuiComponentPlugins + RobotAPICore RobotAPIInterfaces armem + # RobotAPIComponentPlugins # for ArViz and other plugins +) + +set(SOURCES + MemoryNameSystem.cpp +) +set(HEADERS + MemoryNameSystem.h +) + + +armarx_add_component("${SOURCES}" "${HEADERS}") + +#generate the application +armarx_generate_and_add_component_executable() diff --git a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/ArMemMemoryNameSystem.cpp b/source/RobotAPI/components/armem/MemoryNameSystem/MemoryNameSystem.cpp similarity index 67% rename from source/RobotAPI/components/armem/ArMemMemoryNameSystem/ArMemMemoryNameSystem.cpp rename to source/RobotAPI/components/armem/MemoryNameSystem/MemoryNameSystem.cpp index 22c9235a354a2f3eabc89d99d9e26212cd6ed5b4..47131a79a44f25dabc1e3364fcc7d3d044b3e506 100644 --- a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/ArMemMemoryNameSystem.cpp +++ b/source/RobotAPI/components/armem/MemoryNameSystem/MemoryNameSystem.cpp @@ -13,14 +13,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemMemoryNameSystem + * @package RobotAPI::ArmarXObjects::MemoryNameSystem * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ -#include "ArMemMemoryNameSystem.h" +#include "MemoryNameSystem.h" #include <ArmarXCore/core/exceptions/local/ExpressionException.h> @@ -31,49 +31,49 @@ namespace armarx { - ArMemMemoryNameSystemPropertyDefinitions::ArMemMemoryNameSystemPropertyDefinitions(std::string prefix) : + MemoryNameSystemPropertyDefinitions::MemoryNameSystemPropertyDefinitions(std::string prefix) : armarx::ComponentPropertyDefinitions(prefix) { } - armarx::PropertyDefinitionsPtr ArMemMemoryNameSystem::createPropertyDefinitions() + armarx::PropertyDefinitionsPtr MemoryNameSystem::createPropertyDefinitions() { - armarx::PropertyDefinitionsPtr defs = new ArMemMemoryNameSystemPropertyDefinitions(getConfigIdentifier()); + armarx::PropertyDefinitionsPtr defs = new MemoryNameSystemPropertyDefinitions(getConfigIdentifier()); return defs; } - std::string ArMemMemoryNameSystem::getDefaultName() const + std::string MemoryNameSystem::getDefaultName() const { - return "ArMemMemoryNameSystem"; + return "MemoryNameSystem"; } - void ArMemMemoryNameSystem::onInitComponent() + void MemoryNameSystem::onInitComponent() { } - void ArMemMemoryNameSystem::onConnectComponent() + void MemoryNameSystem::onConnectComponent() { RemoteGui__createTab(); RemoteGui_startRunningTask(); } - void ArMemMemoryNameSystem::onDisconnectComponent() + void MemoryNameSystem::onDisconnectComponent() { } - void ArMemMemoryNameSystem::onExitComponent() + void MemoryNameSystem::onExitComponent() { } - armem::data::RegisterMemoryResult ArMemMemoryNameSystem::registerMemory( + armem::data::RegisterMemoryResult MemoryNameSystem::registerMemory( const armem::data::RegisterMemoryInput& input, const Ice::Current& c) { armem::data::RegisterMemoryResult result = Plugin::registerMemory(input, c); @@ -82,7 +82,7 @@ namespace armarx } - armem::data::RemoveMemoryResult ArMemMemoryNameSystem::removeMemory( + armem::data::RemoveMemoryResult MemoryNameSystem::removeMemory( const armem::data::RemoveMemoryInput& input, const Ice::Current& c) { armem::data::RemoveMemoryResult result = Plugin::removeMemory(input, c); @@ -94,7 +94,7 @@ namespace armarx // REMOTE GUI - void ArMemMemoryNameSystem::RemoteGui__createTab() + void MemoryNameSystem::RemoteGui__createTab() { using namespace armarx::RemoteGui::Client; @@ -106,7 +106,7 @@ namespace armarx } - void ArMemMemoryNameSystem::RemoteGui_update() + void MemoryNameSystem::RemoteGui_update() { if (tab.rebuild.exchange(false)) { diff --git a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/ArMemMemoryNameSystem.h b/source/RobotAPI/components/armem/MemoryNameSystem/MemoryNameSystem.h similarity index 82% rename from source/RobotAPI/components/armem/ArMemMemoryNameSystem/ArMemMemoryNameSystem.h rename to source/RobotAPI/components/armem/MemoryNameSystem/MemoryNameSystem.h index 5147135bce50689bfeccde89464039cf0db10440..795aecc66f96423aa29b28660694e09ea50a1426 100644 --- a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/ArMemMemoryNameSystem.h +++ b/source/RobotAPI/components/armem/MemoryNameSystem/MemoryNameSystem.h @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemMemoryNameSystem + * @package RobotAPI::ArmarXObjects::MemoryNameSystem * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt @@ -37,30 +37,30 @@ namespace armarx { /** - * @class ArMemMemoryNameSystemPropertyDefinitions - * @brief Property definitions of `ArMemMemoryNameSystem`. + * @class MemoryNameSystemPropertyDefinitions + * @brief Property definitions of `MemoryNameSystem`. */ - class ArMemMemoryNameSystemPropertyDefinitions : + class MemoryNameSystemPropertyDefinitions : public armarx::ComponentPropertyDefinitions { public: - ArMemMemoryNameSystemPropertyDefinitions(std::string prefix); + MemoryNameSystemPropertyDefinitions(std::string prefix); }; /** - * @defgroup Component-ArMemMemoryNameSystem ArMemMemoryNameSystem + * @defgroup Component-MemoryNameSystem MemoryNameSystem * @ingroup RobotAPI-Components - * A description of the component ArMemMemoryNameSystem. + * A description of the component MemoryNameSystem. * - * @class ArMemMemoryNameSystem - * @ingroup Component-ArMemMemoryNameSystem - * @brief Brief description of class ArMemMemoryNameSystem. + * @class MemoryNameSystem + * @ingroup Component-MemoryNameSystem + * @brief Brief description of class MemoryNameSystem. * - * Detailed description of class ArMemMemoryNameSystem. + * Detailed description of class MemoryNameSystem. */ - class ArMemMemoryNameSystem : + class MemoryNameSystem : virtual public armarx::Component , virtual public armem::mns::ComponentPluginUser , virtual public LightweightRemoteGuiComponentPluginUser diff --git a/source/RobotAPI/components/armem/MemoryNameSystem/test/CMakeLists.txt b/source/RobotAPI/components/armem/MemoryNameSystem/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b495ddff0ba086967c34c28e0d2da770ae4f8998 --- /dev/null +++ b/source/RobotAPI/components/armem/MemoryNameSystem/test/CMakeLists.txt @@ -0,0 +1,5 @@ + +# Libs required for the tests +SET(LIBS ${LIBS} ArmarXCore MemoryNameSystem) + +armarx_add_test(MemoryNameSystemTest MemoryNameSystemTest.cpp "${LIBS}") diff --git a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/test/ArMemMemoryNameSystemTest.cpp b/source/RobotAPI/components/armem/MemoryNameSystem/test/MemoryNameSystemTest.cpp similarity index 81% rename from source/RobotAPI/components/armem/ArMemMemoryNameSystem/test/ArMemMemoryNameSystemTest.cpp rename to source/RobotAPI/components/armem/MemoryNameSystem/test/MemoryNameSystemTest.cpp index 7c2f6aea7d307d2ced486c746f57aeb21824fc89..3eecee385f44a1a05596c617a938f00048fcc1fd 100644 --- a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/test/ArMemMemoryNameSystemTest.cpp +++ b/source/RobotAPI/components/armem/MemoryNameSystem/test/MemoryNameSystemTest.cpp @@ -13,25 +13,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemMemoryNameSystem + * @package RobotAPI::ArmarXObjects::MemoryNameSystem * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ -#define BOOST_TEST_MODULE RobotAPI::ArmarXObjects::ArMemMemoryNameSystem +#define BOOST_TEST_MODULE RobotAPI::ArmarXObjects::MemoryNameSystem #define ARMARX_BOOST_TEST #include <RobotAPI/Test.h> -#include "../ArMemMemoryNameSystem.h" +#include "../MemoryNameSystem.h" #include <iostream> BOOST_AUTO_TEST_CASE(testExample) { - armarx::ArMemMemoryNameSystem instance; + armarx::MemoryNameSystem instance; BOOST_CHECK_EQUAL(true, true); } diff --git a/source/RobotAPI/components/armem/ArMemExampleClient/CMakeLists.txt b/source/RobotAPI/components/armem/client/ExampleClient/CMakeLists.txt similarity index 84% rename from source/RobotAPI/components/armem/ArMemExampleClient/CMakeLists.txt rename to source/RobotAPI/components/armem/client/ExampleClient/CMakeLists.txt index 01eb7b07b3fc2a9c2d48345b84a1784663958ca7..a6c8b9c637db73dc5cae91c430346542b834dec4 100644 --- a/source/RobotAPI/components/armem/ArMemExampleClient/CMakeLists.txt +++ b/source/RobotAPI/components/armem/client/ExampleClient/CMakeLists.txt @@ -1,4 +1,4 @@ -armarx_component_set_name("ArMemExampleClient") +armarx_component_set_name("ExampleClient") find_package(IVT QUIET) armarx_build_if(IVT_FOUND "IVT not available") @@ -11,11 +11,11 @@ set(COMPONENT_LIBS ) set(SOURCES - ArMemExampleClient.cpp + ExampleClient.cpp ) set(HEADERS - ArMemExampleClient.h + ExampleClient.h ) armarx_add_component("${SOURCES}" "${HEADERS}") diff --git a/source/RobotAPI/components/armem/ArMemExampleClient/ArMemExampleClient.cpp b/source/RobotAPI/components/armem/client/ExampleClient/ExampleClient.cpp similarity index 87% rename from source/RobotAPI/components/armem/ArMemExampleClient/ArMemExampleClient.cpp rename to source/RobotAPI/components/armem/client/ExampleClient/ExampleClient.cpp index d2f6c51d85292b249c83649fd11b10446bc8312f..d483d1336024d059987b1f3e631ae0d5b917fb1f 100644 --- a/source/RobotAPI/components/armem/ArMemExampleClient/ArMemExampleClient.cpp +++ b/source/RobotAPI/components/armem/client/ExampleClient/ExampleClient.cpp @@ -13,14 +13,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemExampleClient + * @package RobotAPI::ArmarXObjects::ExampleClient * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ -#include "ArMemExampleClient.h" +#include "ExampleClient.h" #include <SimoxUtility/color/cmaps.h> @@ -32,19 +32,19 @@ #include <RobotAPI/libraries/armem/client/query/query_fns.h> #include <RobotAPI/libraries/armem/core/ice_conversions.h> -#include <RobotAPI/components/armem/ArMemExampleMemory/aron/ExampleData.aron.generated.h> +#include <RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.aron.generated.h> namespace armarx { - ArMemExampleClientPropertyDefinitions::ArMemExampleClientPropertyDefinitions(std::string prefix) : + ExampleClientPropertyDefinitions::ExampleClientPropertyDefinitions(std::string prefix) : armarx::ComponentPropertyDefinitions(prefix) { } - armarx::PropertyDefinitionsPtr ArMemExampleClient::createPropertyDefinitions() + armarx::PropertyDefinitionsPtr ExampleClient::createPropertyDefinitions() { - armarx::PropertyDefinitionsPtr defs = new ArMemExampleClientPropertyDefinitions(getConfigIdentifier()); + armarx::PropertyDefinitionsPtr defs = new ExampleClientPropertyDefinitions(getConfigIdentifier()); defs->topic(debugObserver); @@ -53,18 +53,18 @@ namespace armarx return defs; } - std::string ArMemExampleClient::getDefaultName() const + std::string ExampleClient::getDefaultName() const { - return "ArMemExampleClient"; + return "ExampleClient"; } - void ArMemExampleClient::onInitComponent() + void ExampleClient::onInitComponent() { } - void ArMemExampleClient::onConnectComponent() + void ExampleClient::onConnectComponent() { createRemoteGuiTab(); RemoteGui_startRunningTask(); @@ -90,26 +90,26 @@ namespace armarx ARMARX_INFO << "Entity " << entityID << " was updated by " << snapshotIDs.size() << " snapshots."; }); // Using a member function: - memoryReader.subscribe(entityID, this, &ArMemExampleClient::example_entityUpdated); + memoryReader.subscribe(entityID, this, &ExampleClient::example_entityUpdated); - task = new RunningTask<ArMemExampleClient>(this, &ArMemExampleClient::run); + task = new RunningTask<ExampleClient>(this, &ExampleClient::run); task->start(); } - void ArMemExampleClient::onDisconnectComponent() + void ExampleClient::onDisconnectComponent() { task->stop(); } - void ArMemExampleClient::onExitComponent() + void ExampleClient::onExitComponent() { } - void ArMemExampleClient::run() + void ExampleClient::run() { ARMARX_IMPORTANT << "Running example."; @@ -142,7 +142,7 @@ namespace armarx } - armem::MemoryID ArMemExampleClient::addProviderSegment() + armem::MemoryID ExampleClient::addProviderSegment() { armem::data::AddSegmentInput input; input.coreSegmentName = "ExampleModality"; @@ -155,7 +155,7 @@ namespace armarx return armem::MemoryID(result.segmentID); } - armem::MemoryID ArMemExampleClient::commitSingleSnapshot(const armem::MemoryID& entityID) + armem::MemoryID ExampleClient::commitSingleSnapshot(const armem::MemoryID& entityID) { // Prepare the update with some empty instances. armem::EntityUpdate update; @@ -178,7 +178,7 @@ namespace armarx return updateResult.snapshotID; } - void ArMemExampleClient::commitMultipleSnapshots(const armem::MemoryID& entityID, int num) + void ExampleClient::commitMultipleSnapshots(const armem::MemoryID& entityID, int num) { // Commit a number of updates with different timestamps and number of instances. armem::Commit commit; @@ -202,7 +202,7 @@ namespace armarx } - void ArMemExampleClient::queryLatestSnapshot(const armem::MemoryID& entityID) + void ExampleClient::queryLatestSnapshot(const armem::MemoryID& entityID) { ARMARX_IMPORTANT << "Querying latest snapshot: " @@ -262,7 +262,7 @@ namespace armarx } } - void ArMemExampleClient::queryExactSnapshot(const armem::MemoryID& snapshotID) + void ExampleClient::queryExactSnapshot(const armem::MemoryID& snapshotID) { ARMARX_IMPORTANT << "Querying exact smapshot: " @@ -297,7 +297,7 @@ namespace armarx } - void ArMemExampleClient::commitExampleData() + void ExampleClient::commitExampleData() { ARMARX_IMPORTANT << "Adding segment " << "ExampleData" << "/" << getName(); @@ -376,7 +376,7 @@ namespace armarx } } - void ArMemExampleClient::queryExampleData() + void ExampleClient::queryExampleData() { // Query all entities from provider. armem::client::query::Builder qb; @@ -400,7 +400,7 @@ namespace armarx - void ArMemExampleClient::example_entityUpdated(const armem::MemoryID& subscriptionID, const std::vector<armem::MemoryID>& snapshotIDs) + void ExampleClient::example_entityUpdated(const armem::MemoryID& subscriptionID, const std::vector<armem::MemoryID>& snapshotIDs) { std::stringstream ss; ss << "example_entity got updated: " << subscriptionID << "\n"; @@ -414,7 +414,7 @@ namespace armarx } - void ArMemExampleClient::createRemoteGuiTab() + void ExampleClient::createRemoteGuiTab() { using namespace armarx::RemoteGui::Client; @@ -427,7 +427,7 @@ namespace armarx RemoteGui_createTab(getName(), root, &tab); } - void ArMemExampleClient::RemoteGui_update() + void ExampleClient::RemoteGui_update() { if (tab.rebuild.exchange(false)) { diff --git a/source/RobotAPI/components/armem/ArMemExampleClient/ArMemExampleClient.h b/source/RobotAPI/components/armem/client/ExampleClient/ExampleClient.h similarity index 82% rename from source/RobotAPI/components/armem/ArMemExampleClient/ArMemExampleClient.h rename to source/RobotAPI/components/armem/client/ExampleClient/ExampleClient.h index 263e5f5d51c9c9fca6fdd10312c7435a285ada3e..3ee6d82e44f6efa8feb62b504d3d966ac23387fb 100644 --- a/source/RobotAPI/components/armem/ArMemExampleClient/ArMemExampleClient.h +++ b/source/RobotAPI/components/armem/client/ExampleClient/ExampleClient.h @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemExampleClient + * @package RobotAPI::ArmarXObjects::ExampleClient * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt @@ -40,29 +40,29 @@ namespace armarx { /** - * @class ArMemExampleClientPropertyDefinitions - * @brief Property definitions of `ArMemExampleClient`. + * @class ExampleClientPropertyDefinitions + * @brief Property definitions of `ExampleClient`. */ - class ArMemExampleClientPropertyDefinitions : + class ExampleClientPropertyDefinitions : public armarx::ComponentPropertyDefinitions { public: - ArMemExampleClientPropertyDefinitions(std::string prefix); + ExampleClientPropertyDefinitions(std::string prefix); }; /** - * @defgroup Component-ArMemExampleClient ArMemExampleClient + * @defgroup Component-ExampleClient ExampleClient * @ingroup RobotAPI-Components - * A description of the component ArMemExampleClient. + * A description of the component ExampleClient. * - * @class ArMemExampleClient - * @ingroup Component-ArMemExampleClient - * @brief Brief description of class ArMemExampleClient. + * @class ExampleClient + * @ingroup Component-ExampleClient + * @brief Brief description of class ExampleClient. * - * Detailed description of class ArMemExampleClient. + * Detailed description of class ExampleClient. */ - class ArMemExampleClient : + class ExampleClient : virtual public armarx::Component, virtual public armarx::armem::client::ComponentPluginUser, virtual public LightweightRemoteGuiComponentPluginUser @@ -114,7 +114,7 @@ namespace armarx private: - armarx::RunningTask<ArMemExampleClient>::pointer_type task; + armarx::RunningTask<ExampleClient>::pointer_type task; armarx::DebugObserverInterfacePrx debugObserver; diff --git a/source/RobotAPI/components/armem/ArMemExampleClient/test/ArMemExampleClientTest.cpp b/source/RobotAPI/components/armem/client/ExampleClient/test/ArMemExampleClientTest.cpp similarity index 100% rename from source/RobotAPI/components/armem/ArMemExampleClient/test/ArMemExampleClientTest.cpp rename to source/RobotAPI/components/armem/client/ExampleClient/test/ArMemExampleClientTest.cpp diff --git a/source/RobotAPI/components/armem/ArMemExampleClient/test/CMakeLists.txt b/source/RobotAPI/components/armem/client/ExampleClient/test/CMakeLists.txt similarity index 100% rename from source/RobotAPI/components/armem/ArMemExampleClient/test/CMakeLists.txt rename to source/RobotAPI/components/armem/client/ExampleClient/test/CMakeLists.txt diff --git a/source/RobotAPI/components/armem/ArMemExampleMemory/CMakeLists.txt b/source/RobotAPI/components/armem/server/ExampleMemory/CMakeLists.txt similarity index 88% rename from source/RobotAPI/components/armem/ArMemExampleMemory/CMakeLists.txt rename to source/RobotAPI/components/armem/server/ExampleMemory/CMakeLists.txt index c02d06dd2fc8aae51f745685e8fcb29a2b3fc696..99070a2c52f970a6ac9f64992a5a9a113de7f227 100644 --- a/source/RobotAPI/components/armem/ArMemExampleMemory/CMakeLists.txt +++ b/source/RobotAPI/components/armem/server/ExampleMemory/CMakeLists.txt @@ -1,4 +1,4 @@ -armarx_component_set_name("ArMemExampleMemory") +armarx_component_set_name("ExampleMemory") find_package(IVT QUIET) armarx_build_if(IVT_FOUND "IVT not available") @@ -14,10 +14,10 @@ set(COMPONENT_LIBS ) set(SOURCES - ArMemExampleMemory.cpp + ExampleMemory.cpp ) set(HEADERS - ArMemExampleMemory.h + ExampleMemory.h ) diff --git a/source/RobotAPI/components/armem/ArMemExampleMemory/ArMemExampleMemory.cpp b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp similarity index 73% rename from source/RobotAPI/components/armem/ArMemExampleMemory/ArMemExampleMemory.cpp rename to source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp index 8ef1905c1773892912986b24c13c4dc1a9647357..19b547583a3678d9b244e8fa4b13b48730229033 100644 --- a/source/RobotAPI/components/armem/ArMemExampleMemory/ArMemExampleMemory.cpp +++ b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp @@ -13,14 +13,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemExampleMemory + * @package RobotAPI::ArmarXObjects::ExampleMemory * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ -#include "ArMemExampleMemory.h" +#include "ExampleMemory.h" #include <ArmarXCore/core/exceptions/local/ExpressionException.h> @@ -29,19 +29,14 @@ #include <RobotAPI/libraries/armem/core/error.h> #include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> -#include <RobotAPI/components/armem/ArMemExampleMemory/aron/ExampleData.aron.generated.h> +#include <RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.aron.generated.h> namespace armarx { - ArMemExampleMemoryPropertyDefinitions::ArMemExampleMemoryPropertyDefinitions(std::string prefix) : - armarx::ComponentPropertyDefinitions(prefix) + armarx::PropertyDefinitionsPtr ExampleMemory::createPropertyDefinitions() { - } - - armarx::PropertyDefinitionsPtr ArMemExampleMemory::createPropertyDefinitions() - { - armarx::PropertyDefinitionsPtr defs = new ArMemExampleMemoryPropertyDefinitions(getConfigIdentifier()); + armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier()); defs->topic(debugObserver); @@ -58,12 +53,12 @@ namespace armarx } - std::string ArMemExampleMemory::getDefaultName() const + std::string ExampleMemory::getDefaultName() const { - return "ArMemExampleMemory"; + return "ExampleMemory"; } - void ArMemExampleMemory::onInitComponent() + void ExampleMemory::onInitComponent() { memory.name() = p.memoryName; @@ -77,17 +72,17 @@ namespace armarx memory.addCoreSegments(p.core.defaultCoreSegments); } - void ArMemExampleMemory::onConnectComponent() + void ExampleMemory::onConnectComponent() { RemoteGui__createTab(); RemoteGui_startRunningTask(); } - void ArMemExampleMemory::onDisconnectComponent() + void ExampleMemory::onDisconnectComponent() { } - void ArMemExampleMemory::onExitComponent() + void ExampleMemory::onExitComponent() { } @@ -95,7 +90,7 @@ namespace armarx // WRITING - armem::data::AddSegmentsResult ArMemExampleMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) + armem::data::AddSegmentsResult ExampleMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) { // This function is overloaded to trigger the remote gui rebuild. armem::data::AddSegmentsResult result = ComponentPluginUser::addSegments(input, p.core.addOnUsage); @@ -104,7 +99,7 @@ namespace armarx } - armem::data::CommitResult ArMemExampleMemory::commit(const armem::data::Commit& commit, const Ice::Current&) + armem::data::CommitResult ExampleMemory::commit(const armem::data::Commit& commit, const Ice::Current&) { // This function is overloaded to trigger the remote gui rebuild. armem::data::CommitResult result = ComponentPluginUser::commit(commit); @@ -121,7 +116,7 @@ namespace armarx // REMOTE GUI - void ArMemExampleMemory::RemoteGui__createTab() + void ExampleMemory::RemoteGui__createTab() { using namespace armarx::RemoteGui::Client; @@ -135,7 +130,7 @@ namespace armarx } - void ArMemExampleMemory::RemoteGui_update() + void ExampleMemory::RemoteGui_update() { if (tab.rebuild.exchange(false)) { diff --git a/source/RobotAPI/components/armem/ArMemExampleMemory/ArMemExampleMemory.h b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.h similarity index 80% rename from source/RobotAPI/components/armem/ArMemExampleMemory/ArMemExampleMemory.h rename to source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.h index aedb1732f88bbb926393877ea6fb12600a252f83..37d20608bea3c0c14cda73332693768899d6ce90 100644 --- a/source/RobotAPI/components/armem/ArMemExampleMemory/ArMemExampleMemory.h +++ b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.h @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemExampleMemory + * @package RobotAPI::ArmarXObjects::ExampleMemory * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt @@ -35,30 +35,17 @@ namespace armarx { /** - * @class ArMemExampleMemoryPropertyDefinitions - * @brief Property definitions of `ArMemExampleMemory`. - */ - class ArMemExampleMemoryPropertyDefinitions : - public armarx::ComponentPropertyDefinitions - { - public: - ArMemExampleMemoryPropertyDefinitions(std::string prefix); - }; - - - - /** - * @defgroup Component-ArMemExampleMemory ArMemExampleMemory + * @defgroup Component-ExampleMemory ExampleMemory * @ingroup RobotAPI-Components - * A description of the component ArMemExampleMemory. + * A description of the component ExampleMemory. * - * @class ArMemExampleMemory - * @ingroup Component-ArMemExampleMemory - * @brief Brief description of class ArMemExampleMemory. + * @class ExampleMemory + * @ingroup Component-ExampleMemory + * @brief Brief description of class ExampleMemory. * - * Detailed description of class ArMemExampleMemory. + * Detailed description of class ExampleMemory. */ - class ArMemExampleMemory : + class ExampleMemory : virtual public armarx::Component , virtual public armem::server::ComponentPluginUser , virtual public LightweightRemoteGuiComponentPluginUser diff --git a/source/RobotAPI/components/armem/ArMemExampleMemory/aron/ExampleData.xml b/source/RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.xml similarity index 100% rename from source/RobotAPI/components/armem/ArMemExampleMemory/aron/ExampleData.xml rename to source/RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.xml diff --git a/source/RobotAPI/components/armem/server/ExampleMemory/test/CMakeLists.txt b/source/RobotAPI/components/armem/server/ExampleMemory/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b2d0b8524117c1c46d2cdc5097ce017c753b2653 --- /dev/null +++ b/source/RobotAPI/components/armem/server/ExampleMemory/test/CMakeLists.txt @@ -0,0 +1,5 @@ + +# Libs required for the tests +SET(LIBS ${LIBS} ArmarXCore ExampleMemory) + +armarx_add_test(ExampleMemoryTest ExampleMemoryTest.cpp "${LIBS}") diff --git a/source/RobotAPI/components/armem/ArMemExampleMemory/test/ArMemExampleMemoryTest.cpp b/source/RobotAPI/components/armem/server/ExampleMemory/test/ExampleMemoryTest.cpp similarity index 80% rename from source/RobotAPI/components/armem/ArMemExampleMemory/test/ArMemExampleMemoryTest.cpp rename to source/RobotAPI/components/armem/server/ExampleMemory/test/ExampleMemoryTest.cpp index 9f391d139acba82d1b4da11101f2599191e5a3e2..78e26f1222a5c79fab78a34bc4780fae90829907 100644 --- a/source/RobotAPI/components/armem/ArMemExampleMemory/test/ArMemExampleMemoryTest.cpp +++ b/source/RobotAPI/components/armem/server/ExampleMemory/test/ExampleMemoryTest.cpp @@ -13,21 +13,21 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemExampleMemory + * @package RobotAPI::ArmarXObjects::ExampleMemory * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ -#define BOOST_TEST_MODULE RobotAPI::ArmarXObjects::ArMemExampleMemory +#define BOOST_TEST_MODULE RobotAPI::ArmarXObjects::ExampleMemory #define ARMARX_BOOST_TEST #include <RobotAPI/Test.h> -#include "../ArMemExampleMemory.h" +#include "../ExampleMemory.h" -#include <RobotAPI/components/armem/ArMemExampleMemory/aron/ExampleData.aron.generated.h> +#include <RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.aron.generated.h> #include <RobotAPI/libraries/armem/core.h> #include <iostream> @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_ExampleData) BOOST_AUTO_TEST_CASE(test_ExampleData_type) { - armarx::aron::typenavigator::AronObjectTypeNavigatorPtr type = ExampleData::toInitialAronType(); + armarx::aron::typenavigator::ObjectNavigatorPtr type = ExampleData::toInitialAronType(); BOOST_CHECK_EQUAL(type->getAcceptedTypes().size(), 15); diff --git a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/CMakeLists.txt b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/CMakeLists.txt similarity index 71% rename from source/RobotAPI/components/armem/ArMemMemoryNameSystem/CMakeLists.txt rename to source/RobotAPI/components/armem/server/GeneralPurposeMemory/CMakeLists.txt index 5551a07dcf06737d017f6b7e104bdee9cbef4b1f..f0521043e0891a4b42b3fd75e612b607b3e421aa 100644 --- a/source/RobotAPI/components/armem/ArMemMemoryNameSystem/CMakeLists.txt +++ b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/CMakeLists.txt @@ -1,4 +1,4 @@ -armarx_component_set_name("ArMemMemoryNameSystem") +armarx_component_set_name("GeneralPurposeMemory") set(COMPONENT_LIBS @@ -6,21 +6,22 @@ set(COMPONENT_LIBS ArmarXGuiComponentPlugins RobotAPICore RobotAPIInterfaces armem # RobotAPIComponentPlugins # for ArViz and other plugins + + ${IVT_LIBRARIES} ) set(SOURCES - ArMemMemoryNameSystem.cpp + GeneralPurposeMemory.cpp ) set(HEADERS - ArMemMemoryNameSystem.h + GeneralPurposeMemory.h ) armarx_add_component("${SOURCES}" "${HEADERS}") - -# add unit tests -# add_subdirectory(test) - #generate the application armarx_generate_and_add_component_executable() + + + diff --git a/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.cpp b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7cc9356831b2da36ee8facfb55c777722fa47350 --- /dev/null +++ b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.cpp @@ -0,0 +1,86 @@ +/* + * This file is part of ArmarX. + * + * 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/>. + * + * @package RobotAPI::ArmarXObjects::GeneralPurposeMemory + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2020 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "GeneralPurposeMemory.h" + +#include <ArmarXCore/core/exceptions/local/ExpressionException.h> + +#include <SimoxUtility/algorithm/string.h> + +#include <RobotAPI/libraries/armem/core/error.h> +#include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> + +namespace armarx +{ + GeneralPurposeMemory::GeneralPurposeMemory() + { + } + + armarx::PropertyDefinitionsPtr GeneralPurposeMemory::createPropertyDefinitions() + { + armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier()); + return defs; + } + + + std::string GeneralPurposeMemory::getDefaultName() const + { + return "GeneralPurposeMemory"; + } + + + void GeneralPurposeMemory::onInitComponent() + { + memory.name() = memoryName; + } + + + void GeneralPurposeMemory::onConnectComponent() + { + } + + + void GeneralPurposeMemory::onDisconnectComponent() + { + } + + + void GeneralPurposeMemory::onExitComponent() + { + } + + + + // WRITING + armem::data::AddSegmentsResult GeneralPurposeMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) + { + armem::data::AddSegmentsResult result = ComponentPluginUser::addSegments(input, addCoreSegmentOnUsage); + return result; + } + + + armem::data::CommitResult GeneralPurposeMemory::commit(const armem::data::Commit& commit, const Ice::Current&) + { + armem::data::CommitResult result = ComponentPluginUser::commit(commit); + return result; + } +} diff --git a/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.h b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.h new file mode 100644 index 0000000000000000000000000000000000000000..c91e38d07df966ec61c06653bc7d828358275797 --- /dev/null +++ b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.h @@ -0,0 +1,84 @@ +/* + * This file is part of ArmarX. + * + * 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/>. + * + * @package RobotAPI::ArmarXObjects::GeneralPurposeMemory + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2020 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + + +#include <ArmarXCore/core/Component.h> + +#include <ArmarXCore/interface/observers/ObserverInterface.h> +#include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h> +#include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h> + +#include <RobotAPI/libraries/armem/server/ComponentPlugin.h> + + +namespace armarx +{ + /** + * @defgroup Component-GeneralPurposeMemory GeneralPurposeMemory + * @ingroup RobotAPI-Components + * A description of the component GeneralPurposeMemory. + * + * @class GeneralPurposeMemory + * @ingroup Component-GeneralPurposeMemory + * @brief Brief description of class GeneralPurposeMemory. + * + * Detailed description of class GeneralPurposeMemory. + */ + class GeneralPurposeMemory : + virtual public armarx::Component, + virtual public armem::server::ComponentPluginUser + { + public: + GeneralPurposeMemory(); + + /// @see armarx::ManagedIceObject::getDefaultName() + std::string getDefaultName() const override; + + public: + armem::data::AddSegmentsResult addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) override; + armem::data::CommitResult commit(const armem::data::Commit& commit, const Ice::Current&) override; + + protected: + /// @see armarx::ManagedIceObject::onInitComponent() + void onInitComponent() override; + + /// @see armarx::ManagedIceObject::onConnectComponent() + void onConnectComponent() override; + + /// @see armarx::ManagedIceObject::onDisconnectComponent() + void onDisconnectComponent() override; + + /// @see armarx::ManagedIceObject::onExitComponent() + void onExitComponent() override; + + /// @see PropertyUser::createPropertyDefinitions() + armarx::PropertyDefinitionsPtr createPropertyDefinitions() override; + + + private: + std::string memoryName = "GeneralPurposeMemory"; + bool addCoreSegmentOnUsage = true; + + }; +} diff --git a/source/RobotAPI/components/armem/ArMemDebugMemory/CMakeLists.txt b/source/RobotAPI/components/armem/server/ObjectMemory/CMakeLists.txt similarity index 55% rename from source/RobotAPI/components/armem/ArMemDebugMemory/CMakeLists.txt rename to source/RobotAPI/components/armem/server/ObjectMemory/CMakeLists.txt index 017e1709df01b4becba5b6aef90fa3dc031399a0..28ade93141eef153f7ed6dd8972cc0adda2b9f3b 100644 --- a/source/RobotAPI/components/armem/ArMemDebugMemory/CMakeLists.txt +++ b/source/RobotAPI/components/armem/server/ObjectMemory/CMakeLists.txt @@ -1,7 +1,4 @@ -armarx_component_set_name("ArMemDebugMemory") - -find_package(IVT QUIET) -armarx_build_if(IVT_FOUND "IVT not available") +armarx_component_set_name("ObjectMemory") set(COMPONENT_LIBS @@ -14,21 +11,13 @@ set(COMPONENT_LIBS ) set(SOURCES - ArMemDebugMemory.cpp + ObjectMemory.cpp ) set(HEADERS - ArMemDebugMemory.h + ObjectMemory.h ) - armarx_add_component("${SOURCES}" "${HEADERS}") -if (IVT_FOUND) - target_include_directories(${ARMARX_COMPONENT_NAME} PUBLIC ${IVT_INCLUDE_DIRS}) -endif() - - -# add unit tests -# add_subdirectory(test) #generate the application armarx_generate_and_add_component_executable() diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..93977f9d9a04181f9b22c24d0c6639571d591412 --- /dev/null +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp @@ -0,0 +1,92 @@ +/* + * This file is part of ArmarX. + * + * 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/>. + * + * @package RobotAPI::ArmarXObjects::ObjectMemory + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2020 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "ObjectMemory.h" + +#include <ArmarXCore/core/exceptions/local/ExpressionException.h> + +#include <SimoxUtility/algorithm/string.h> + +#include <RobotAPI/libraries/armem/core/error.h> +#include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> + +namespace armarx +{ + ObjectMemory::ObjectMemory() + { + } + + armarx::PropertyDefinitionsPtr ObjectMemory::createPropertyDefinitions() + { + armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier()); + return defs; + } + + + std::string ObjectMemory::getDefaultName() const + { + return "ObjectMemory"; + } + + + void ObjectMemory::onInitComponent() + { + memory.name() = memoryName; + } + + + void ObjectMemory::onConnectComponent() + { + } + + + void ObjectMemory::onDisconnectComponent() + { + } + + + void ObjectMemory::onExitComponent() + { + } + + + + // WRITING + armem::data::AddSegmentsResult ObjectMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) + { + armem::data::AddSegmentsResult result = ComponentPluginUser::addSegments(input, addCoreSegmentOnUsage); + return result; + } + + + armem::data::CommitResult ObjectMemory::commit(const armem::data::Commit& commit, const Ice::Current&) + { + armem::data::CommitResult result = ComponentPluginUser::commit(commit); + return result; + } + + + // READING + // Inherited from Plugin + + +} diff --git a/source/RobotAPI/components/armem/ArMemDebugMemory/ArMemDebugMemory.h b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h similarity index 65% rename from source/RobotAPI/components/armem/ArMemDebugMemory/ArMemDebugMemory.h rename to source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h index 568f22c1674e319cdfc0d4eca37618ee314a9835..ca194dfbf6c2f0c3b527a2170aa1308f883780ae 100644 --- a/source/RobotAPI/components/armem/ArMemDebugMemory/ArMemDebugMemory.h +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package RobotAPI::ArmarXObjects::ArMemDebugMemory + * @package RobotAPI::ArmarXObjects::ObjectMemory * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) * @date 2020 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt @@ -35,36 +35,23 @@ namespace armarx { /** - * @class ArMemDebugMemoryPropertyDefinitions - * @brief Property definitions of `ArMemDebugMemory`. - */ - class ArMemDebugMemoryPropertyDefinitions : - public armarx::ComponentPropertyDefinitions - { - public: - ArMemDebugMemoryPropertyDefinitions(std::string prefix); - }; - - - /** - * @defgroup Component-ArMemDebugMemory ArMemDebugMemory + * @defgroup Component-ObjectMemory ObjectMemory * @ingroup RobotAPI-Components - * A description of the component ArMemDebugMemory. + * A description of the component ObjectMemory. * - * @class ArMemDebugMemory - * @ingroup Component-ArMemDebugMemory - * @brief Brief description of class ArMemDebugMemory. + * @class ObjectMemory + * @ingroup Component-ObjectMemory + * @brief Brief description of class ObjectMemory. * - * Detailed description of class ArMemDebugMemory. + * Detailed description of class ObjectMemory. */ - class ArMemDebugMemory : + class ObjectMemory : virtual public armarx::Component , virtual public armem::server::ComponentPluginUser - , virtual public LightweightRemoteGuiComponentPluginUser // , virtual public armarx::ArVizComponentPluginUser { public: - ArMemDebugMemory(); + ObjectMemory(); /// @see armarx::ManagedIceObject::getDefaultName() std::string getDefaultName() const override; @@ -74,11 +61,6 @@ namespace armarx armem::data::AddSegmentsResult addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) override; armem::data::CommitResult commit(const armem::data::Commit& commit, const Ice::Current&) override; - // LightweightRemoteGuiComponentPluginUser interface - public: - void RemoteGui__createTab(); - void RemoteGui_update() override; - protected: /// @see armarx::ManagedIceObject::onInitComponent() @@ -98,18 +80,7 @@ namespace armarx private: - /// Debug observer. Used to visualize e.g. time series. - armarx::DebugObserverInterfacePrx debugObserver; - - std::string memoryName = "DebugMemory"; + std::string memoryName = "ObjectMemory"; bool addCoreSegmentOnUsage = true; - - struct RemoteGuiTab : RemoteGui::Client::Tab - { - std::atomic_bool rebuild = false; - RemoteGui::Client::GroupBox memoryGroup; - }; - RemoteGuiTab tab; - }; } diff --git a/source/RobotAPI/components/armem/server/RobotSensorMemory/CMakeLists.txt b/source/RobotAPI/components/armem/server/RobotSensorMemory/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6b41a6548813d6299456af1bb22703efbc6c5a18 --- /dev/null +++ b/source/RobotAPI/components/armem/server/RobotSensorMemory/CMakeLists.txt @@ -0,0 +1,26 @@ +armarx_component_set_name("RobotSensorMemory") + + +set(COMPONENT_LIBS + ArmarXCore ArmarXCoreInterfaces # for DebugObserverInterface + ArmarXGuiComponentPlugins + RobotAPICore RobotAPIInterfaces armem + # RobotAPIComponentPlugins # for ArViz and other plugins + + ${IVT_LIBRARIES} +) + +set(SOURCES + RobotSensorMemory.cpp +) +set(HEADERS + RobotSensorMemory.h +) + +armarx_add_component("${SOURCES}" "${HEADERS}") + +#generate the application +armarx_generate_and_add_component_executable() + + + diff --git a/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.cpp b/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..938241717dbafb7aa5896ad74c2881589a3066ad --- /dev/null +++ b/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.cpp @@ -0,0 +1,92 @@ +/* + * This file is part of ArmarX. + * + * 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/>. + * + * @package RobotAPI::ArmarXObjects::RobotSensorMemory + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2020 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "RobotSensorMemory.h" + +#include <ArmarXCore/core/exceptions/local/ExpressionException.h> + +#include <SimoxUtility/algorithm/string.h> + +#include <RobotAPI/libraries/armem/core/error.h> +#include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> + +namespace armarx +{ + RobotSensorMemory::RobotSensorMemory() + { + } + + armarx::PropertyDefinitionsPtr RobotSensorMemory::createPropertyDefinitions() + { + armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier()); + + return defs; + } + + + std::string RobotSensorMemory::getDefaultName() const + { + return "RobotSensorMemory"; + } + + + void RobotSensorMemory::onInitComponent() + { + memory.name() = memoryName; + } + + + void RobotSensorMemory::onConnectComponent() + { + } + + + void RobotSensorMemory::onDisconnectComponent() + { + } + + + void RobotSensorMemory::onExitComponent() + { + } + + + + // WRITING + armem::data::AddSegmentsResult RobotSensorMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) + { + armem::data::AddSegmentsResult result = ComponentPluginUser::addSegments(input, addCoreSegmentOnUsage); + return result; + } + + + armem::data::CommitResult RobotSensorMemory::commit(const armem::data::Commit& commit, const Ice::Current&) + { + armem::data::CommitResult result = ComponentPluginUser::commit(commit); + return result; + } + + + // READING + // Inherited from Plugin + +} diff --git a/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.h b/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.h new file mode 100644 index 0000000000000000000000000000000000000000..0534c719d9b0a35294cbec755731bee8c0e9b300 --- /dev/null +++ b/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.h @@ -0,0 +1,85 @@ +/* + * This file is part of ArmarX. + * + * 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/>. + * + * @package RobotAPI::ArmarXObjects::RobotSensorMemory + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2020 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + + +#include <ArmarXCore/core/Component.h> + +#include <ArmarXCore/interface/observers/ObserverInterface.h> +#include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h> +#include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h> + +#include <RobotAPI/libraries/armem/server/ComponentPlugin.h> + + +namespace armarx +{ + /** + * @defgroup Component-RobotSensorMemory RobotSensorMemory + * @ingroup RobotAPI-Components + * A description of the component RobotSensorMemory. + * + * @class RobotSensorMemory + * @ingroup Component-RobotSensorMemory + * @brief Brief description of class RobotSensorMemory. + * + * Detailed description of class RobotSensorMemory. + */ + class RobotSensorMemory : + virtual public armarx::Component + , virtual public armem::server::ComponentPluginUser + // , virtual public armarx::ArVizComponentPluginUser + { + public: + RobotSensorMemory(); + + /// @see armarx::ManagedIceObject::getDefaultName() + std::string getDefaultName() const override; + + // WritingInterface interface + public: + armem::data::AddSegmentsResult addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) override; + armem::data::CommitResult commit(const armem::data::Commit& commit, const Ice::Current&) override; + + protected: + /// @see armarx::ManagedIceObject::onInitComponent() + void onInitComponent() override; + + /// @see armarx::ManagedIceObject::onConnectComponent() + void onConnectComponent() override; + + /// @see armarx::ManagedIceObject::onDisconnectComponent() + void onDisconnectComponent() override; + + /// @see armarx::ManagedIceObject::onExitComponent() + void onExitComponent() override; + + /// @see PropertyUser::createPropertyDefinitions() + armarx::PropertyDefinitionsPtr createPropertyDefinitions() override; + + + private: + std::string memoryName = "RobotSensorMemory"; + bool addCoreSegmentOnUsage = true; + }; +} diff --git a/source/RobotAPI/components/armem/server/SkillsMemory/CMakeLists.txt b/source/RobotAPI/components/armem/server/SkillsMemory/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c00bd89e9c47178acbe3ea49ac4b3d3bc3cc5436 --- /dev/null +++ b/source/RobotAPI/components/armem/server/SkillsMemory/CMakeLists.txt @@ -0,0 +1,26 @@ +armarx_component_set_name("SkillsMemory") + + +set(COMPONENT_LIBS + ArmarXCore ArmarXCoreInterfaces # for DebugObserverInterface + ArmarXGuiComponentPlugins + RobotAPICore RobotAPIInterfaces armem + # RobotAPIComponentPlugins # for ArViz and other plugins + + ${IVT_LIBRARIES} +) + +set(SOURCES + SkillsMemory.cpp +) +set(HEADERS + SkillsMemory.h +) + +armarx_add_component("${SOURCES}" "${HEADERS}") + +#generate the application +armarx_generate_and_add_component_executable() + + + diff --git a/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..14dd8887985350929b4a729a4387a5ba448c68f9 --- /dev/null +++ b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp @@ -0,0 +1,91 @@ +/* + * This file is part of ArmarX. + * + * 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/>. + * + * @package RobotAPI::ArmarXObjects::SkillsMemory + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2020 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "SkillsMemory.h" + +#include <ArmarXCore/core/exceptions/local/ExpressionException.h> + +#include <SimoxUtility/algorithm/string.h> + +#include <RobotAPI/libraries/armem/core/error.h> +#include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> + +namespace armarx +{ + SkillsMemory::SkillsMemory() + { + } + + armarx::PropertyDefinitionsPtr SkillsMemory::createPropertyDefinitions() + { + armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier()); + return defs; + } + + + std::string SkillsMemory::getDefaultName() const + { + return "SkillsMemory"; + } + + + void SkillsMemory::onInitComponent() + { + memory.name() = memoryName; + } + + + void SkillsMemory::onConnectComponent() + { + } + + + void SkillsMemory::onDisconnectComponent() + { + } + + + void SkillsMemory::onExitComponent() + { + } + + + + // WRITING + armem::data::AddSegmentsResult SkillsMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) + { + armem::data::AddSegmentsResult result = ComponentPluginUser::addSegments(input, addCoreSegmentOnUsage); + return result; + } + + + armem::data::CommitResult SkillsMemory::commit(const armem::data::Commit& commit, const Ice::Current&) + { + armem::data::CommitResult result = ComponentPluginUser::commit(commit); + return result; + } + + + // READING + // Inherited from Plugin + +} diff --git a/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.h b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.h new file mode 100644 index 0000000000000000000000000000000000000000..6201ffb07640bf4c75473d0a0e29876f4fdbf265 --- /dev/null +++ b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.h @@ -0,0 +1,86 @@ +/* + * This file is part of ArmarX. + * + * 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/>. + * + * @package RobotAPI::ArmarXObjects::SkillsMemory + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2020 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + + +#include <ArmarXCore/core/Component.h> + +#include <ArmarXCore/interface/observers/ObserverInterface.h> +#include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h> +#include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h> + +#include <RobotAPI/libraries/armem/server/ComponentPlugin.h> + + +namespace armarx +{ + /** + * @defgroup Component-SkillsMemory SkillsMemory + * @ingroup RobotAPI-Components + * A description of the component SkillsMemory. + * + * @class SkillsMemory + * @ingroup Component-SkillsMemory + * @brief Brief description of class SkillsMemory. + * + * Detailed description of class SkillsMemory. + */ + class SkillsMemory : + virtual public armarx::Component, + virtual public armem::server::ComponentPluginUser + // , virtual public armarx::ArVizComponentPluginUser + { + public: + SkillsMemory(); + + /// @see armarx::ManagedIceObject::getDefaultName() + std::string getDefaultName() const override; + + // WritingInterface interface + public: + armem::data::AddSegmentsResult addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) override; + armem::data::CommitResult commit(const armem::data::Commit& commit, const Ice::Current&) override; + + + protected: + /// @see armarx::ManagedIceObject::onInitComponent() + void onInitComponent() override; + + /// @see armarx::ManagedIceObject::onConnectComponent() + void onConnectComponent() override; + + /// @see armarx::ManagedIceObject::onDisconnectComponent() + void onDisconnectComponent() override; + + /// @see armarx::ManagedIceObject::onExitComponent() + void onExitComponent() override; + + /// @see PropertyUser::createPropertyDefinitions() + armarx::PropertyDefinitionsPtr createPropertyDefinitions() override; + + + private: + std::string memoryName = "SkillsMemory"; + bool addCoreSegmentOnUsage = true; + }; +} diff --git a/source/RobotAPI/interface/CMakeLists.txt b/source/RobotAPI/interface/CMakeLists.txt index 06b9d9b21090a3149c26862033f87d2192775045..7ee210481fec8c2714f3cdb29f0eb3c02f46dd7a 100644 --- a/source/RobotAPI/interface/CMakeLists.txt +++ b/source/RobotAPI/interface/CMakeLists.txt @@ -113,6 +113,7 @@ set(SLICE_FILES armem/server.ice armem/server/MemoryInterface.ice + armem/server/MemoryPredictorInterface.ice armem/server/ReadingMemoryInterface.ice armem/server/WritingMemoryInterface.ice diff --git a/source/RobotAPI/interface/armem/server/MemoryPredictorInterface.ice b/source/RobotAPI/interface/armem/server/MemoryPredictorInterface.ice new file mode 100644 index 0000000000000000000000000000000000000000..42920804f6d80d9e79151600864dc50e3b0c7aa3 --- /dev/null +++ b/source/RobotAPI/interface/armem/server/MemoryPredictorInterface.ice @@ -0,0 +1,16 @@ +#pragma once + +#include <RobotAPI/interface/armem/server/ReadingMemoryInterface.ice> +#include <RobotAPI/interface/armem/server/WritingMemoryInterface.ice> + +module armarx { + module armem { + module server { + interface MemoryPredictorInterface + { + // TODO + void predict(); + } + }; + }; +}; diff --git a/source/RobotAPI/interface/aron/Aron.ice b/source/RobotAPI/interface/aron/Aron.ice index cddbcc1558554cdb3ad19e81e981d0480e48b668..027ab4c47140b51facba1c5e30d03cb95ef02e5e 100644 --- a/source/RobotAPI/interface/aron/Aron.ice +++ b/source/RobotAPI/interface/aron/Aron.ice @@ -9,13 +9,21 @@ RUN_ARON_MACRO(Object, object, OBJECT) \ RUN_ARON_MACRO(List, list, LIST) \ RUN_ARON_MACRO(Dict, dict, DICT) \ + RUN_ARON_MACRO(Pair, pair, PAIR) \ RUN_ARON_MACRO(Tuple, tuple, TUPLE) \ -#define HANDLE_COMPLEX_TYPES \ +#define HANDLE_NDARRAY_TYPES \ RUN_ARON_MACRO(EigenMatrix, eigenmatrix, EIGEN_MATRIX) \ + RUN_ARON_MACRO(EigenQuaternion, eigenquaternion, EIGEN_QUATERNION) \ RUN_ARON_MACRO(IVTCByteImage, ivtcbyteimage, IVT_CBYTE_IMAGE) \ RUN_ARON_MACRO(OpenCVMat, opencvmat, OPENCV_MAT) \ - RUN_ARON_MACRO(PCLPointCloud, pclpointcloud, PCL_POINTCLOUD) + RUN_ARON_MACRO(PCLPointCloud, pclpointcloud, PCL_POINTCLOUD) \ + RUN_ARON_MACRO(Position, position, POSITION) \ + RUN_ARON_MACRO(Orientation, orientation, ORIENTATION) \ + RUN_ARON_MACRO(Pose, pose, POSE) + +#define HANDLE_ENUM_TYPES \ + RUN_ARON_MACRO(IntEnum, intenum, INT_ENUM) #define HANDLE_PRIMITIVE_TYPES \ RUN_ARON_MACRO(Int, int, INT) \ @@ -23,11 +31,14 @@ RUN_ARON_MACRO(Float, float, FLOAT) \ RUN_ARON_MACRO(Double, double, DOUBLE) \ RUN_ARON_MACRO(String, string, STRING) \ - RUN_ARON_MACRO(Bool, bool, BOOL) + RUN_ARON_MACRO(Bool, bool, BOOL) \ + RUN_ARON_MACRO(Time, time, TIME) + #define HANDLE_ALL_ARON_TYPES \ HANDLE_CONTAINER_TYPES \ HANDLE_COMPLEX_TYPES \ + HANDLE_ENUM_TYPES \ HANDLE_PRIMITIVE_TYPES /************************************ @@ -41,10 +52,18 @@ #define HANDLE_COMPLEX_DATA \ RUN_ARON_MACRO(NDArray, ndarray, NDARRAY) +#define HANDLE_PRIMITIVE_DATA \ + RUN_ARON_MACRO(Int, int, INT) \ + RUN_ARON_MACRO(Long, long, LONG) \ + RUN_ARON_MACRO(Float, float, FLOAT) \ + RUN_ARON_MACRO(Double, double, DOUBLE) \ + RUN_ARON_MACRO(String, string, STRING) \ + RUN_ARON_MACRO(Bool, bool, BOOL) + #define HANDLE_ALL_ARON_DATA \ HANDLE_CONTAINER_DATA \ HANDLE_COMPLEX_DATA \ - HANDLE_PRIMITIVE_TYPES + HANDLE_PRIMITIVE_DATA module armarx @@ -56,11 +75,9 @@ module armarx * General Definitions *** ************************/ sequence<byte> AronByteSequence; -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - sequence<lowerType> Aron##upperType##Sequence; - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO + sequence<int> AronIntSequence; + sequence<string> AronStringSequence; + dictionary<string, int> AronIntDict; /************************* @@ -72,32 +89,30 @@ module armarx sequence<AronType> AronTypeList; dictionary<string, AronType> AronTypeDict; - // Container Types (serialize to object/list) - class AronContainerType extends AronType {}; - - // Please note that either elementTypes xor acceptedType is set!!! - class AronDictSerializerType extends AronContainerType { AronTypeDict elementTypes; AronType acceptedType;}; - class AronListSerializerType extends AronContainerType { AronTypeList elementTypes; AronType acceptedType;}; + // Container types + class AronList extends AronType { AronType acceptedType; }; + class AronTuple extends AronType { AronTypeList elementTypes; }; + class AronPair extends AronType { AronType acceptedType1; AronType acceptedType2; }; + class AronObject extends AronType { AronObject parent; string objectName; AronTypeDict elementTypes;}; + class AronDict extends AronType { AronType acceptedType; }; - class AronListType extends AronListSerializerType { }; - class AronTupleType extends AronListSerializerType { }; + // Complex Types (serialize to ndarray) + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + class Aron##upperType extends AronType { AronIntSequence dimensions; string typename; }; - class AronObjectType extends AronDictSerializerType { AronObjectType parent; string objectName; }; - class AronDictType extends AronDictSerializerType { }; + HANDLE_NDARRAY_TYPES + #undef RUN_ARON_MACRO - // Complex Types (serialize to ndarray) - class AronComplexType extends AronType {}; - class AronNDArraySerializerType extends AronComplexType { AronIntSequence dimensions; string typeName; }; + // Enum types #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##Type extends AronNDArraySerializerType { }; + class Aron##upperType extends AronType { AronIntDict acceptedValues; }; - HANDLE_COMPLEX_TYPES + HANDLE_ENUM_TYPES #undef RUN_ARON_MACRO // Primitive Types - class AronPrimitiveType extends AronType {}; #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##Type extends AronPrimitiveType { }; + class Aron##upperType extends AronType { }; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO @@ -114,23 +129,22 @@ module armarx dictionary<string, AronData> AronDataDict; // Container Data - class AronContainer extends AronData {}; - class AronList extends AronContainer { AronDataList elements; }; - class AronDict extends AronContainer { AronDataDict elements; }; + class AronList extends AronData { AronDataList elements; }; + class AronDict extends AronData { AronDataDict elements; }; - // Complex Data. The NDArray contains the same information as an AronType, but there is no other way to do it - class AronComplex extends AronData {}; - class AronNDArray extends AronComplex { AronIntSequence dimensions; string type; AronByteSequence data; }; + // Complex Data. The NDArray contains more or less the same information as an AronType, but there is no other way to do it + // Especially, note the difference between the type's typeName (e.g. "GRAY_SCALE_IMAGE") and the data's type ("0") + // Further, note the difference between the type's dimensions (e.g. 128x128) and the data's dimensions (128x128x3 for RGB) + class AronNDArray extends AronData { AronIntSequence dimensions; string type; AronByteSequence data; }; - // Basic Data - class AronPrimitive extends AronData {}; + // Primitive Data #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType extends AronPrimitive { lowerType value; }; + class Aron##upperType extends AronData { lowerType value; }; - HANDLE_PRIMITIVE_TYPES + HANDLE_PRIMITIVE_DATA #undef RUN_ARON_MACRO - + // useful for memory ice_conversions sequence<AronDict> AronDictSeq; }; @@ -139,9 +153,11 @@ module armarx #undef HANDLE_ALL_ARON_TYPES #undef HANDLE_PRIMITIVE_TYPES +#undef HANDLE_ENUM_TYPES #undef HANDLE_COMPLEX_TYPES #undef HANDLE_CONTAINER_TYPES #undef HANDLE_ALL_ARON_DATA #undef HANDLE_COMPLEX_DATA #undef HANDLE_CONTAINER_DATA +#undef HANDLE_CONTAINER_TYPES diff --git a/source/RobotAPI/libraries/armem/client/ReaderComponentPlugin.h b/source/RobotAPI/libraries/armem/client/ReaderComponentPlugin.h index c4b6eae7a875baf2ae0814ffc89c233aacf4fee6..b98c5282aa3ef990c20c62a870860bde9f9e47af 100644 --- a/source/RobotAPI/libraries/armem/client/ReaderComponentPlugin.h +++ b/source/RobotAPI/libraries/armem/client/ReaderComponentPlugin.h @@ -8,7 +8,7 @@ #include <ArmarXCore/core/Component.h> // RobotAPI -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> #include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h> #include <RobotAPI/interface/armem/server/ReadingMemoryInterface.h> #include <RobotAPI/interface/armem/client/MemoryListenerInterface.h> diff --git a/source/RobotAPI/libraries/armem/client/WriterComponentPlugin.h b/source/RobotAPI/libraries/armem/client/WriterComponentPlugin.h index 9e1608c10cfb0173d9dc80aa1c87b3dbe1b38a18..e95149f85c269f3b3e09eb3036f5a2c5ae7b85f1 100644 --- a/source/RobotAPI/libraries/armem/client/WriterComponentPlugin.h +++ b/source/RobotAPI/libraries/armem/client/WriterComponentPlugin.h @@ -5,7 +5,7 @@ #include <ArmarXCore/core/Component.h> // RobotAPI -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> #include <RobotAPI/interface/armem/server/WritingMemoryInterface.h> #include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h> diff --git a/source/RobotAPI/libraries/armem/core/Commit.h b/source/RobotAPI/libraries/armem/core/Commit.h index 7d246f8ae0e3a05aff05c6d842a9947b12fec937..d921de2bc2939207f988983752ffc54d1d54fe46 100644 --- a/source/RobotAPI/libraries/armem/core/Commit.h +++ b/source/RobotAPI/libraries/armem/core/Commit.h @@ -2,7 +2,7 @@ #include <vector> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AronDictDataNavigator.h> #include "../core/MemoryID.h" #include "../core/Time.h" diff --git a/source/RobotAPI/libraries/armem/core/CoreSegment.cpp b/source/RobotAPI/libraries/armem/core/CoreSegment.cpp index 34f73cbdf4f7845a8fc2ad0ab14bc7d9ffcb8775..61098ee9a268d6bd06748c02878cc70e013e72af 100644 --- a/source/RobotAPI/libraries/armem/core/CoreSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/CoreSegment.cpp @@ -12,17 +12,17 @@ namespace armarx::armem { } - CoreSegment::CoreSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) : + CoreSegment::CoreSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr aronType) : CoreSegment(name, MemoryID(), aronType) { } - CoreSegment::CoreSegment(const std::string& name, const MemoryID& parentID, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) : + CoreSegment::CoreSegment(const std::string& name, const MemoryID& parentID, aron::typenavigator::ObjectNavigatorPtr aronType) : CoreSegment(parentID.getMemoryID().withCoreSegmentName(name), aronType) { } - CoreSegment::CoreSegment(const MemoryID& id, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) : + CoreSegment::CoreSegment(const MemoryID& id, aron::typenavigator::ObjectNavigatorPtr aronType) : Base(id, aronType) { } @@ -108,9 +108,9 @@ namespace armarx::armem } - ProviderSegment& CoreSegment::addProviderSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr providerSegmentType) + ProviderSegment& CoreSegment::addProviderSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr providerSegmentType) { - aron::typenavigator::AronObjectTypeNavigatorPtr type = providerSegmentType ? providerSegmentType : this->aronType(); + aron::typenavigator::ObjectNavigatorPtr type = providerSegmentType ? providerSegmentType : this->aronType(); return addProviderSegment(ProviderSegment(name, type)); } diff --git a/source/RobotAPI/libraries/armem/core/CoreSegment.h b/source/RobotAPI/libraries/armem/core/CoreSegment.h index aed697fb00d5aaf4c3d1f8446be5b289fae97cb8..f492c0f1a735bd8c7343bfb503bc66f3add11908 100644 --- a/source/RobotAPI/libraries/armem/core/CoreSegment.h +++ b/source/RobotAPI/libraries/armem/core/CoreSegment.h @@ -23,9 +23,9 @@ namespace armarx::armem public: CoreSegment(); - CoreSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); - CoreSegment(const std::string& name, const MemoryID& parentID, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); - CoreSegment(const MemoryID& id, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); + CoreSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); + CoreSegment(const std::string& name, const MemoryID& parentID, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); + CoreSegment(const MemoryID& id, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); CoreSegment(const CoreSegment& other); CoreSegment& operator=(const CoreSegment& other); @@ -55,7 +55,7 @@ namespace armarx::armem * @param providerSegmentType The provider type. If nullptr, the core segment type is used. * @return The added provider segment. */ - ProviderSegment& addProviderSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr providerSegmentType = nullptr); + ProviderSegment& addProviderSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr providerSegmentType = nullptr); /// Copy and insert a provider segment. ProviderSegment& addProviderSegment(const ProviderSegment& providerSegment); /// Move and insert a provider segment. diff --git a/source/RobotAPI/libraries/armem/core/EntityInstance.h b/source/RobotAPI/libraries/armem/core/EntityInstance.h index 7b3235bec867296d72784e446f0d2f0ef41bf00a..be020ccd414a8d42633effff7162cf4bfc78ab77 100644 --- a/source/RobotAPI/libraries/armem/core/EntityInstance.h +++ b/source/RobotAPI/libraries/armem/core/EntityInstance.h @@ -1,7 +1,7 @@ #pragma once #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AronDictDataNavigator.h> #include "../core/Time.h" diff --git a/source/RobotAPI/libraries/armem/core/Memory.cpp b/source/RobotAPI/libraries/armem/core/Memory.cpp index c78e22733a9dc05f2748061b4fd8680b9b1f7172..3d218f0b098670cbc6e704e9e500ffecd752c2ac 100644 --- a/source/RobotAPI/libraries/armem/core/Memory.cpp +++ b/source/RobotAPI/libraries/armem/core/Memory.cpp @@ -83,7 +83,7 @@ namespace armarx::armem } - CoreSegment& Memory::addCoreSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr coreSegmentType) + CoreSegment& Memory::addCoreSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr coreSegmentType) { return addCoreSegment(CoreSegment(name, coreSegmentType)); } diff --git a/source/RobotAPI/libraries/armem/core/Memory.h b/source/RobotAPI/libraries/armem/core/Memory.h index 1f38f7eab44be7f08020c1e78c41a3460b9ebe76..2059d0c0dcdc13e683e20fd9c4646bb499b6d1ce 100644 --- a/source/RobotAPI/libraries/armem/core/Memory.h +++ b/source/RobotAPI/libraries/armem/core/Memory.h @@ -47,7 +47,7 @@ namespace armarx::armem * @param coreSegmentType The core segment type (optional). * @return The added core segment. */ - CoreSegment& addCoreSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr coreSegmentType = nullptr); + CoreSegment& addCoreSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr coreSegmentType = nullptr); /// Copy and insert a core segment. CoreSegment& addCoreSegment(const CoreSegment& coreSegment); /// Move and insert a core segment. diff --git a/source/RobotAPI/libraries/armem/core/ProviderSegment.cpp b/source/RobotAPI/libraries/armem/core/ProviderSegment.cpp index fb0ca8cc82a3cfcbf3f89251c87b2d79a7f4e357..879932739ff86a8a9b091d561053f0f76ca08be0 100644 --- a/source/RobotAPI/libraries/armem/core/ProviderSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/ProviderSegment.cpp @@ -12,17 +12,17 @@ namespace armarx::armem { } - ProviderSegment::ProviderSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) : + ProviderSegment::ProviderSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr aronType) : ProviderSegment(name, MemoryID(), aronType) { } - ProviderSegment::ProviderSegment(const std::string& name, const MemoryID parentID, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) : + ProviderSegment::ProviderSegment(const std::string& name, const MemoryID parentID, aron::typenavigator::ObjectNavigatorPtr aronType) : ProviderSegment(parentID.withProviderSegmentName(name), aronType) { } - ProviderSegment::ProviderSegment(const MemoryID id, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) : + ProviderSegment::ProviderSegment(const MemoryID id, aron::typenavigator::ObjectNavigatorPtr aronType) : Base(id, aronType) { } diff --git a/source/RobotAPI/libraries/armem/core/ProviderSegment.h b/source/RobotAPI/libraries/armem/core/ProviderSegment.h index 384ee1b416c2dac48ae1dcccdc9fa3e984ff6700..cbb2080de0af157cb45f9d938edcde62315f7483 100644 --- a/source/RobotAPI/libraries/armem/core/ProviderSegment.h +++ b/source/RobotAPI/libraries/armem/core/ProviderSegment.h @@ -25,9 +25,9 @@ namespace armarx::armem public: ProviderSegment(); - ProviderSegment(const std::string& name, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); - ProviderSegment(const std::string& name, const MemoryID parentID, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); - ProviderSegment(const MemoryID id, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); + ProviderSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); + ProviderSegment(const std::string& name, const MemoryID parentID, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); + ProviderSegment(const MemoryID id, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); ProviderSegment(const ProviderSegment& other); ProviderSegment& operator=(const ProviderSegment& other); diff --git a/source/RobotAPI/libraries/armem/core/detail/TypedEntityContainer.h b/source/RobotAPI/libraries/armem/core/detail/TypedEntityContainer.h index 5a74fd0e742bc33ae3f1d75ea92ea3489d4806f3..822d1fe172ca063e365c465077362f5e011603c2 100644 --- a/source/RobotAPI/libraries/armem/core/detail/TypedEntityContainer.h +++ b/source/RobotAPI/libraries/armem/core/detail/TypedEntityContainer.h @@ -2,7 +2,7 @@ #include "EntityContainer.h" -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> namespace armarx::armem::detail { @@ -18,9 +18,9 @@ namespace armarx::armem::detail public: - TypedEntityContainer(aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr) : _aronType(aronType) + TypedEntityContainer(aron::typenavigator::ObjectNavigatorPtr aronType = nullptr) : _aronType(aronType) {} - TypedEntityContainer(const MemoryID& id, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr) : + TypedEntityContainer(const MemoryID& id, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr) : EntityContainer<ValueT, Derived>(id), _aronType(aronType) {} @@ -32,11 +32,11 @@ namespace armarx::armem::detail { return _aronType != nullptr; } - aron::typenavigator::AronObjectTypeNavigatorPtr& aronType() + aron::typenavigator::ObjectNavigatorPtr& aronType() { return _aronType; } - aron::typenavigator::AronObjectTypeNavigatorPtr aronType() const + aron::typenavigator::ObjectNavigatorPtr aronType() const { return _aronType; } @@ -55,7 +55,7 @@ namespace armarx::armem::detail private: /// The expected Aron type. May be nullptr, in which case no type information is available. - aron::typenavigator::AronObjectTypeNavigatorPtr _aronType; + aron::typenavigator::ObjectNavigatorPtr _aronType; }; diff --git a/source/RobotAPI/libraries/armem/core/ice_conversions.cpp b/source/RobotAPI/libraries/armem/core/ice_conversions.cpp index 74d2262cf01c4b43aacf740444f4912c50e03972..ad7da435ab222ffd0416ef29c092fb4904dff51f 100644 --- a/source/RobotAPI/libraries/armem/core/ice_conversions.cpp +++ b/source/RobotAPI/libraries/armem/core/ice_conversions.cpp @@ -236,8 +236,8 @@ namespace armarx if (ice.aronType) { - providerSegment.aronType() = aron::typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck( - aron::typenavigator::AronTypeNavigator::FromAronType(ice.aronType) + providerSegment.aronType() = aron::typenavigator::ObjectNavigator::DynamicCastAndCheck( + aron::typenavigator::Navigator::FromAronType(ice.aronType) ); } fromIce(ice.entities, providerSegment.entities); @@ -259,8 +259,8 @@ namespace armarx if (ice.aronType) { - coreSegment.aronType() = aron::typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck( - aron::typenavigator::AronTypeNavigator::FromAronType(ice.aronType) + coreSegment.aronType() = aron::typenavigator::ObjectNavigator::DynamicCastAndCheck( + aron::typenavigator::Navigator::FromAronType(ice.aronType) ); } fromIce(ice.providerSegments, coreSegment.providerSegments); diff --git a/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.cpp b/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.cpp index 8aee152ffcea5231faf09da36fc75ab057982cd9..57cea432606c3b938c90ddc7d2b0bb856cf626b3 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.cpp +++ b/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.cpp @@ -26,14 +26,14 @@ // ArmarX #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/AronDataConverter/AronDataConverter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/AronTypeConverter/AronTypeConverter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.h> #include <RobotAPI/libraries/armem/core/error.h> @@ -121,13 +121,13 @@ namespace armarx::armem::io return ret; } - EntityInstance DiskReader::readSingleInstanceFromDisk(const MemoryID& id, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure) const + EntityInstance DiskReader::readSingleInstanceFromDisk(const MemoryID& id, const aron::typenavigator::NavigatorPtr& expectedStructure) const { std::filesystem::path p = rootPath / (id.str() + getEntityInstanceSuffix()); return readSingleInstanceFromDisk(p, expectedStructure); } - EntityInstance DiskReader::readSingleInstanceFromDisk(const std::filesystem::path& p, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure) const + EntityInstance DiskReader::readSingleInstanceFromDisk(const std::filesystem::path& p, const aron::typenavigator::NavigatorPtr& expectedStructure) const { if (!std::filesystem::is_regular_file(p)) { @@ -141,13 +141,13 @@ namespace armarx::armem::io return unwrapData(dictdata); } - aron::typenavigator::AronObjectTypeNavigatorPtr DiskReader::readSingleTypeInformationFromDisk(const MemoryID& id) const + aron::typenavigator::ObjectNavigatorPtr DiskReader::readSingleTypeInformationFromDisk(const MemoryID& id) const { std::filesystem::path p = rootPath / id.str() / (id.getLeafItem() + getTypeSuffix()); return readSingleTypeInformationFromDisk(p); } - aron::typenavigator::AronObjectTypeNavigatorPtr DiskReader::readSingleTypeInformationFromDisk(const std::filesystem::path& p) const + aron::typenavigator::ObjectNavigatorPtr DiskReader::readSingleTypeInformationFromDisk(const std::filesystem::path& p) const { if (!std::filesystem::is_regular_file(p)) { @@ -157,7 +157,7 @@ namespace armarx::armem::io std::ifstream ifs(p); std::string file_content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>())); - aron::typenavigator::AronObjectTypeNavigatorPtr objecttype = getStringAsTypeNavigator(file_content); + aron::typenavigator::ObjectNavigatorPtr objecttype = getStringAsTypeNavigator(file_content); return objecttype; } @@ -187,8 +187,8 @@ namespace armarx::armem::io return e; } - aron::typenavigator::AronObjectTypeNavigatorPtr DiskReader::unwrapType(const aron::typenavigator::AronObjectTypeNavigatorPtr& t) const + aron::typenavigator::ObjectNavigatorPtr DiskReader::unwrapType(const aron::typenavigator::ObjectNavigatorPtr& t) const { - return aron::typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck(t->getAcceptedType(DISK_READER_WRITER_DATA_FIELD)); + return aron::typenavigator::ObjectNavigator::DynamicCastAndCheck(t->getAcceptedType(DISK_READER_WRITER_DATA_FIELD)); } } diff --git a/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.h b/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.h index 415dde225b7c686d27987d2e83ef1d1282de191a..1d71e7b62867d2454c285eed0a720f3f31eca706 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.h +++ b/source/RobotAPI/libraries/armem/core/io/DiskReader/DiskReader.h @@ -25,9 +25,9 @@ #include <memory> #include <string> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AronDictDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> #include <RobotAPI/libraries/armem/core/EntityInstance.h> @@ -49,17 +49,17 @@ namespace armarx::armem::io FileSystemLookupMemory readMemoryStructureFromDisk(); FileSystemLookupMemory readMemoryStructureFromDisk(const std::string&); - EntityInstance readSingleInstanceFromDisk(const std::filesystem::path&, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure = nullptr) const; - EntityInstance readSingleInstanceFromDisk(const MemoryID&, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure = nullptr) const; + EntityInstance readSingleInstanceFromDisk(const std::filesystem::path&, const aron::typenavigator::NavigatorPtr& expectedStructure = nullptr) const; + EntityInstance readSingleInstanceFromDisk(const MemoryID&, const aron::typenavigator::NavigatorPtr& expectedStructure = nullptr) const; - aron::typenavigator::AronObjectTypeNavigatorPtr readSingleTypeInformationFromDisk(const std::filesystem::path&) const; - aron::typenavigator::AronObjectTypeNavigatorPtr readSingleTypeInformationFromDisk(const MemoryID&) const; + aron::typenavigator::ObjectNavigatorPtr readSingleTypeInformationFromDisk(const std::filesystem::path&) const; + aron::typenavigator::ObjectNavigatorPtr readSingleTypeInformationFromDisk(const MemoryID&) const; protected: EntityInstance unwrapData(const aron::datanavigator::AronDictDataNavigatorPtr&) const; - aron::typenavigator::AronObjectTypeNavigatorPtr unwrapType(const aron::typenavigator::AronObjectTypeNavigatorPtr&) const; + aron::typenavigator::ObjectNavigatorPtr unwrapType(const aron::typenavigator::ObjectNavigatorPtr&) const; - virtual aron::datanavigator::AronDictDataNavigatorPtr getStringAsDataNavigator(const std::string&, const aron::typenavigator::AronTypeNavigatorPtr&) const = 0; - virtual aron::typenavigator::AronObjectTypeNavigatorPtr getStringAsTypeNavigator(const std::string& s) const = 0; + virtual aron::datanavigator::AronDictDataNavigatorPtr getStringAsDataNavigator(const std::string&, const aron::typenavigator::NavigatorPtr&) const = 0; + virtual aron::typenavigator::ObjectNavigatorPtr getStringAsTypeNavigator(const std::string& s) const = 0; }; } diff --git a/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.cpp b/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.cpp index 41e230cd614abbf8647697904dd1b4b736a6dc03..b5383b0d9aa280e3316e78b61134e90a46e55485 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.cpp +++ b/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.cpp @@ -1,10 +1,10 @@ #include "NlohmannJSONDiskReader.h" -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/AronDataConverter/AronDataConverter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/AronDataNlohmannJSONReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/AronTypeConverter/AronTypeConverter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/AronTypeNlohmannJSONReader.h> namespace armarx::armem::io @@ -22,7 +22,7 @@ namespace armarx::armem::io { } - aron::datanavigator::AronDictDataNavigatorPtr NlohmannJSONDiskReader::getStringAsDataNavigator(const std::string& s, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure) const + aron::datanavigator::AronDictDataNavigatorPtr NlohmannJSONDiskReader::getStringAsDataNavigator(const std::string& s, const aron::typenavigator::NavigatorPtr& expectedStructure) const { aron::io::AronDataNlohmannJSONReader dataReader(s); aron::io::AronDataNavigatorWriter navWriter; @@ -30,11 +30,11 @@ namespace armarx::armem::io return aron::datanavigator::AronDictDataNavigator::DynamicCastAndCheck(navWriter.getResult()); } - aron::typenavigator::AronObjectTypeNavigatorPtr NlohmannJSONDiskReader::getStringAsTypeNavigator(const std::string& s) const + aron::typenavigator::ObjectNavigatorPtr NlohmannJSONDiskReader::getStringAsTypeNavigator(const std::string& s) const { aron::io::AronTypeNlohmannJSONReader typeReader(s); aron::io::AronTypeNavigatorWriter navWriter; aron::io::AronTypeConverter::ConvertFromReader(typeReader, navWriter); - return aron::typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck(navWriter.getResult()); + return aron::typenavigator::ObjectNavigator::DynamicCastAndCheck(navWriter.getResult()); } } diff --git a/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.h b/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.h index 16e9ff7a1463a227644493d7c1b6e898ccc3db42..f4908b5e45a919d423f96d3de23044b6e8b08e35 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.h +++ b/source/RobotAPI/libraries/armem/core/io/DiskReader/NlohmannJSONDiskReader/NlohmannJSONDiskReader.h @@ -42,8 +42,8 @@ namespace armarx::armem::io protected: aron::datanavigator::AronDictDataNavigatorPtr getStringAsDataNavigator( - const std::string&, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure = nullptr) const override; - aron::typenavigator::AronObjectTypeNavigatorPtr getStringAsTypeNavigator(const std::string& s) const override; + const std::string&, const aron::typenavigator::NavigatorPtr& expectedStructure = nullptr) const override; + aron::typenavigator::ObjectNavigatorPtr getStringAsTypeNavigator(const std::string& s) const override; std::string getEntityInstanceSuffix() const override { diff --git a/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.cpp b/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.cpp index 27c3ab13b303552f29e4de9d11266c9ac9accfab..a36149131470c48cd59648792998abbccdd36dc6 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.cpp +++ b/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.cpp @@ -26,13 +26,13 @@ // ArmarX #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/DataWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/Writer.h> // BaseClass @@ -244,9 +244,9 @@ namespace armarx::armem::io return dataWrapped; } - aron::typenavigator::AronObjectTypeNavigatorPtr DiskWriter::wrapType(const aron::typenavigator::AronObjectTypeNavigatorPtr& t) const + aron::typenavigator::ObjectNavigatorPtr DiskWriter::wrapType(const aron::typenavigator::ObjectNavigatorPtr& t) const { - aron::typenavigator::AronObjectTypeNavigatorPtr typeWrapped(new aron::typenavigator::AronObjectTypeNavigator()); + aron::typenavigator::ObjectNavigatorPtr typeWrapped(new aron::typenavigator::ObjectNavigator()); typeWrapped->setObjectName(t->getObjectName() + "__ltm_export"); typeWrapped->addAcceptedType(DISK_READER_WRITER_DATA_FIELD, t); diff --git a/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.h b/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.h index 6e7a2567c6f69b2c5f64ecbd4e28664c18648699..9d999bbe91fac94574cc045557297ef765946aaf 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.h +++ b/source/RobotAPI/libraries/armem/core/io/DiskWriter/DiskWriter.h @@ -26,9 +26,9 @@ #include <filesystem> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AronDictDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> // BaseClass @@ -60,10 +60,10 @@ namespace armarx::armem::io protected: aron::datanavigator::AronDictDataNavigatorPtr wrapData(const EntityInstance& e) const; - aron::typenavigator::AronObjectTypeNavigatorPtr wrapType(const aron::typenavigator::AronObjectTypeNavigatorPtr&) const; + aron::typenavigator::ObjectNavigatorPtr wrapType(const aron::typenavigator::ObjectNavigatorPtr&) const; virtual std::string getDataAsString(const aron::datanavigator::AronDictDataNavigatorPtr&) const = 0; - virtual std::string getTypeAsString(const aron::typenavigator::AronObjectTypeNavigatorPtr&) const = 0; + virtual std::string getTypeAsString(const aron::typenavigator::ObjectNavigatorPtr&) const = 0; bool directoryPathExists(const std::filesystem::path& p) const; bool ensureDirectoryPathExists(const std::filesystem::path& p) const; diff --git a/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.cpp b/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.cpp index 29268e81831eb2f460aaddad0e4d45bb77fb37d5..6f460795c1dc2c170e307dfe618ff8a98054645a 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.cpp +++ b/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.cpp @@ -1,9 +1,9 @@ #include "NlohmannJSONDiskWriter.h" -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.h> namespace armarx::armem::io @@ -23,14 +23,14 @@ namespace armarx::armem::io std::string NlohmannJSONDiskWriter::getDataAsString(const aron::datanavigator::AronDictDataNavigatorPtr& aronDataNav) const { aron::io::AronDataNlohmannJSONWriter dataWriter; - aron::io::AronDataWriterVisitor::SetupWriterFromAronDataPtr(dataWriter, aronDataNav->getResult()); + aron::io::Visitor::SetupWriterFromAronDataPtr(dataWriter, aronDataNav->getResult()); return dataWriter.getResult().dump(2); } - std::string NlohmannJSONDiskWriter::getTypeAsString(const aron::typenavigator::AronObjectTypeNavigatorPtr& aronTypeNav) const + std::string NlohmannJSONDiskWriter::getTypeAsString(const aron::typenavigator::ObjectNavigatorPtr& aronTypeNav) const { - aron::io::AronTypeNlohmannJSONWriter typeWriter; - aron::io::AronTypeWriterVisitor::SetupWriterFromAronTypePtr(typeWriter, aronTypeNav->getResult()); + aron::io::NlohmannJSONWriter typeWriter; + aron::io::Visitor::SetupWriterFromAronTypePtr(typeWriter, aronTypeNav->getResult()); return typeWriter.getResult().dump(2); } } diff --git a/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.h b/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.h index 5d4c798cc46fefcbf065120c9af679f45371a03d..760221687a9875a5f178bd8292c80b42b296ceb1 100644 --- a/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.h +++ b/source/RobotAPI/libraries/armem/core/io/DiskWriter/NlohmannJSONDiskWriter/NlohmannJSONDiskWriter.h @@ -42,7 +42,7 @@ namespace armarx::armem::io protected: std::string getDataAsString(const aron::datanavigator::AronDictDataNavigatorPtr&) const override; - std::string getTypeAsString(const aron::typenavigator::AronObjectTypeNavigatorPtr&) const override; + std::string getTypeAsString(const aron::typenavigator::ObjectNavigatorPtr&) const override; std::string getEntityInstanceSuffix() const override { diff --git a/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.cpp b/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.cpp index c63702f0e6b01deb45ed82debd55050787866202..24cdd90a23eae3a14b86314227e46f647098127a 100644 --- a/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.cpp +++ b/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.cpp @@ -1,6 +1,6 @@ #include "MemoryFileSystemStorage.h" -#include <RobotAPI/libraries/aron/aroncore/AronDebug.h> +#include <RobotAPI/libraries/aron/aroncore/Debug.h> #include <RobotAPI/libraries/armem/core/error.h> @@ -169,18 +169,18 @@ namespace armarx::armem::io EntityInstance ret(_id.instanceIndex); if (internalMemory.hasEntityInstance(_id)) { - aron::typenavigator::AronObjectTypeNavigatorPtr typeInformation = readClosestTypeInformation(_id); + aron::typenavigator::ObjectNavigatorPtr typeInformation = readClosestTypeInformation(_id); const DiskEntityInstance& path = internalMemory.getDiskEntityInstance(_id); return reader->readSingleInstanceFromDisk(path, typeInformation); } return ret; } - aron::typenavigator::AronObjectTypeNavigatorPtr FileSystemMemoryManager::readClosestTypeInformation(const MemoryID& _id) const + aron::typenavigator::ObjectNavigatorPtr FileSystemMemoryManager::readClosestTypeInformation(const MemoryID& _id) const { if (_id.hasInstanceIndex()) { - aron::typenavigator::AronObjectTypeNavigatorPtr t = reader->readSingleTypeInformationFromDisk(_id); + aron::typenavigator::ObjectNavigatorPtr t = reader->readSingleTypeInformationFromDisk(_id); if (t != nullptr) { return t; @@ -189,7 +189,7 @@ namespace armarx::armem::io if (_id.hasTimestamp()) { MemoryID id = _id.getEntitySnapshotID(); - aron::typenavigator::AronObjectTypeNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); + aron::typenavigator::ObjectNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); if (t != nullptr) { return t; @@ -198,7 +198,7 @@ namespace armarx::armem::io if (_id.hasEntityName()) { MemoryID id = _id.getEntityID(); - aron::typenavigator::AronObjectTypeNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); + aron::typenavigator::ObjectNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); if (t != nullptr) { return t; @@ -207,7 +207,7 @@ namespace armarx::armem::io if (_id.hasProviderSegmentName()) { MemoryID id = _id.getProviderSegmentID(); - aron::typenavigator::AronObjectTypeNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); + aron::typenavigator::ObjectNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); if (t != nullptr) { return t; @@ -216,7 +216,7 @@ namespace armarx::armem::io if (_id.hasCoreSegmentName()) { MemoryID id = _id.getCoreSegmentID(); - aron::typenavigator::AronObjectTypeNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); + aron::typenavigator::ObjectNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); if (t != nullptr) { return t; @@ -225,7 +225,7 @@ namespace armarx::armem::io if (_id.hasMemoryName()) { MemoryID id = _id.getMemoryID(); - aron::typenavigator::AronObjectTypeNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); + aron::typenavigator::ObjectNavigatorPtr t = reader->readSingleTypeInformationFromDisk(id); if (t != nullptr) { return t; diff --git a/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.h b/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.h index 80c9c2c703f22690a61deacfe9658b0b24d33ee1..3420fc9033bc7a0b009131158628e0f6fdd10b2d 100644 --- a/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.h +++ b/source/RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.h @@ -61,7 +61,7 @@ namespace armarx::armem::io EntitySnapshot readEntitySnapshotFromDisk(const MemoryID& entitySnapshotID) const; EntityInstance readEntityInstanceFromDisk(const MemoryID& entityInstanceID) const; - aron::typenavigator::AronObjectTypeNavigatorPtr readClosestTypeInformation(const MemoryID&) const; + aron::typenavigator::ObjectNavigatorPtr readClosestTypeInformation(const MemoryID&) const; //std::pair<Entity, aron::typenavigator::AronObjectTypeNavigatorPtr> readTypedEntityFromDisk(); //std::pair<EntitySnapshot, aron::typenavigator::AronObjectTypeNavigatorPtr> readTypedEntitySnapshotFromDisk(); diff --git a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp index 3c5e7b6ecb4172b075d6cca7b4a59b0d543c3283..03d497725adec16d41f10f1e8fd23f51c06b1bac 100644 --- a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp +++ b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp @@ -2,8 +2,8 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.h> #include <SimoxUtility/meta/type_name.h> diff --git a/source/RobotAPI/libraries/armem/server/RemoteGuiAronDataVisitor.h b/source/RobotAPI/libraries/armem/server/RemoteGuiAronDataVisitor.h index ee2c40570db1cca8a4e371e3d4bfd5f7347cf18f..876f6c8f0d9be4ca3daf80758f4f562cfec49a99 100644 --- a/source/RobotAPI/libraries/armem/server/RemoteGuiAronDataVisitor.h +++ b/source/RobotAPI/libraries/armem/server/RemoteGuiAronDataVisitor.h @@ -5,7 +5,7 @@ #include <ArmarXGui/libraries/RemoteGui/Client/Widgets.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.h> namespace armarx::armem::server diff --git a/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp index 951ced4998066620a89ec06a9090d35cf87b99cb..20440006641d61dd90fe81a21772a52b9e0d4de7 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp @@ -28,12 +28,12 @@ #include "../core/Memory.h" #include "../core/error.h" -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> #include <RobotAPI/libraries/armem/core/io/MemoryFileSystemStorage.h> #include <RobotAPI/libraries/aron/aroncore/AronRandomizer.h> -#include <RobotAPI/libraries/aron/aroncore/AronDebug.h> +#include <RobotAPI/libraries/aron/aroncore/Debug.h> #include <filesystem> #include <iostream> @@ -71,8 +71,8 @@ namespace ArMemLTMTest static armem::Memory setupMemoryWithType( const std::string& memoryName, - const aron::typenavigator::AronObjectTypeNavigatorPtr& t1, - const aron::typenavigator::AronObjectTypeNavigatorPtr& t2, + const aron::typenavigator::ObjectNavigatorPtr& t1, + const aron::typenavigator::ObjectNavigatorPtr& t2, unsigned int numSnapshots, unsigned int numInstances) { @@ -92,7 +92,7 @@ namespace ArMemLTMTest coreSegment.aronType() = t1; providerSegment.aronType() = t2; - aron::typenavigator::AronObjectTypeNavigatorPtr t = t2 != nullptr ? t2 : t1; + aron::typenavigator::ObjectNavigatorPtr t = t2 != nullptr ? t2 : t1; for (unsigned int i = 0; i < numSnapshots; ++i) { @@ -117,9 +117,9 @@ namespace ArMemLTMTest } template <class TypeNavigatorT> - aron::typenavigator::AronObjectTypeNavigatorPtr makeType(const std::string& memberPrefix, int numMembers = 4) + aron::typenavigator::ObjectNavigatorPtr makeType(const std::string& memberPrefix, int numMembers = 4) { - aron::typenavigator::AronObjectTypeNavigatorPtr t = std::make_shared<aron::typenavigator::AronObjectTypeNavigator>(aron::AronPath()); + aron::typenavigator::ObjectNavigatorPtr t = std::make_shared<aron::typenavigator::ObjectNavigator>(aron::Path()); t->setObjectName("TestObjectType1"); for (int i = 0; i < numMembers; ++i) @@ -313,17 +313,17 @@ BOOST_AUTO_TEST_CASE(test_memory_export__easy_rainer_setup) { std::string memoryName = "TestMemory_RainerSetup"; - aron::typenavigator::AronObjectTypeNavigatorPtr t(new aron::typenavigator::AronObjectTypeNavigator(aron::AronPath())); + aron::typenavigator::AronObjectTypeNavigatorPtr t(new aron::typenavigator::AronObjectTypeNavigator(aron::Path())); t->setObjectName("TestRainerType1"); - aron::typenavigator::AronDictTypeNavigatorPtr tm1(new aron::typenavigator::AronDictTypeNavigator(aron::AronPath())); - aron::typenavigator::AronFloatTypeNavigatorPtr tm1m1(new aron::typenavigator::AronFloatTypeNavigator(aron::AronPath())); + aron::typenavigator::AronDictTypeNavigatorPtr tm1(new aron::typenavigator::AronDictTypeNavigator(aron::Path())); + aron::typenavigator::AronFloatTypeNavigatorPtr tm1m1(new aron::typenavigator::AronFloatTypeNavigator(aron::Path())); tm1->setAcceptedType(tm1m1); - aron::typenavigator::AronStringTypeNavigatorPtr tm2(new aron::typenavigator::AronStringTypeNavigator(aron::AronPath())); - aron::typenavigator::AronDictTypeNavigatorPtr tm3(new aron::typenavigator::AronDictTypeNavigator(aron::AronPath())); - aron::typenavigator::AronStringTypeNavigatorPtr tm3m1(new aron::typenavigator::AronStringTypeNavigator(aron::AronPath())); + aron::typenavigator::AronStringTypeNavigatorPtr tm2(new aron::typenavigator::AronStringTypeNavigator(aron::Path())); + aron::typenavigator::AronDictTypeNavigatorPtr tm3(new aron::typenavigator::AronDictTypeNavigator(aron::Path())); + aron::typenavigator::AronStringTypeNavigatorPtr tm3m1(new aron::typenavigator::AronStringTypeNavigator(aron::Path())); tm3->setAcceptedType(tm3m1); - aron::typenavigator::AronStringTypeNavigatorPtr tm4(new aron::typenavigator::AronStringTypeNavigator(aron::AronPath())); + aron::typenavigator::AronStringTypeNavigatorPtr tm4(new aron::typenavigator::AronStringTypeNavigator(aron::Path())); t->addAcceptedType("float_params", tm1); t->addAcceptedType("name", tm2); //t->addAcceptedType("string_params", tm3); diff --git a/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp index 6983c42dceef954ad5857c8a26626332666bf86b..48c63d27674206cd29de9363034232d45a6f8821 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp @@ -31,7 +31,7 @@ #include <iostream> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AronDictDataNavigator.h> namespace armem = armarx::armem; diff --git a/source/RobotAPI/libraries/armem_gui/MemoryTreeWidget.cpp b/source/RobotAPI/libraries/armem_gui/MemoryTreeWidget.cpp index d494cd315ade75ccc758ebebd5943a8144dafdce..89b08fc1cdab157f46a38371fef1d60661bba8c1 100644 --- a/source/RobotAPI/libraries/armem_gui/MemoryTreeWidget.cpp +++ b/source/RobotAPI/libraries/armem_gui/MemoryTreeWidget.cpp @@ -6,7 +6,7 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> namespace armarx::armem::gui diff --git a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitor.h b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitor.h index 2ceb790caf10591bb0260a52f83445f4458fa84f..2244fb4d3977b253bb05e913a0905a8378387fbf 100644 --- a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitor.h +++ b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitor.h @@ -6,7 +6,7 @@ #include <QTreeWidget> #include <QLabel> -#include <RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.h> #include "InstanceTreeDataVisitorBase.h" diff --git a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitorBase.h b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitorBase.h index a0b9a913b9e47ea07ee5cb393cbfef64eeb803bc..79691c5c78bf2d74c2e8922fee27be5dcfb11780 100644 --- a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitorBase.h +++ b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitorBase.h @@ -6,7 +6,7 @@ #include <QTreeWidget> #include <QLabel> -#include <RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.h> namespace armarx::armem::gui diff --git a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.cpp b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.cpp index 6e9c63c47be8be806befc7a31b75376afe23df4c..de5ed25266167ddefd56f1e63807059fc03810a6 100644 --- a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.cpp +++ b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.cpp @@ -16,7 +16,7 @@ namespace armarx::armem::gui return n; } - QStringList InstanceTreeTypedDataVisitor::serializeAronPath(const aron::AronPath& path) + QStringList InstanceTreeTypedDataVisitor::serializePath(const aron::Path& path) { QStringList qpath; qpath.append(QString::fromStdString(path.getRootIdentifier())); @@ -28,7 +28,7 @@ namespace armarx::armem::gui return qpath; } - aron::AronPath InstanceTreeTypedDataVisitor::deserializeAronPath(const QStringList& qpath) + aron::Path InstanceTreeTypedDataVisitor::deserializePath(const QStringList& qpath) { ARMARX_CHECK_GREATER_EQUAL(qpath.size(), 2); std::vector<std::string> pathItems; @@ -36,7 +36,7 @@ namespace armarx::armem::gui { pathItems.push_back(qpath.at(i).toStdString()); } - aron::AronPath path(qpath.at(0).toStdString(), qpath.at(1).toStdString(), pathItems); + aron::Path path(qpath.at(0).toStdString(), qpath.at(1).toStdString(), pathItems); return path; } diff --git a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.h b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.h index b38664fc4a814ac5df66e9522dc318189c220d26..3d0c3a1290c3fc4b04652dddca4d457125f8f1e8 100644 --- a/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.h +++ b/source/RobotAPI/libraries/armem_gui/instance/InstanceTreeTypedDataVisitor.h @@ -6,7 +6,7 @@ #include <QTreeWidget> #include <QLabel> -#include <RobotAPI/libraries/aron/aroncore/navigators/visitors/TypedDataVisitor.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/visitors/TypedDataVisitor.h> #include "InstanceTreeDataVisitorBase.h" @@ -116,7 +116,7 @@ namespace armarx::armem::gui QTreeWidgetItem* item = new QTreeWidgetItem(this->makeValueRowStrings(key, dataNavigator, sanitizeTypeName(type.getName()))); items.top()->addChild(item); - item->setData(columnKey, Qt::UserRole, serializeAronPath(dataNavigator.getPath())); + item->setData(columnKey, Qt::UserRole, serializePath(dataNavigator.getPath())); item->setData(columnType, Qt::UserRole, int(type.getDescriptor())); } return true; @@ -124,8 +124,8 @@ namespace armarx::armem::gui public: - static QStringList serializeAronPath(const aron::AronPath& path); - static aron::AronPath deserializeAronPath(const QStringList& qpath); + static QStringList serializePath(const aron::Path& path); + static aron::Path deserializePath(const QStringList& qpath); }; diff --git a/source/RobotAPI/libraries/armem_gui/instance/InstanceView.cpp b/source/RobotAPI/libraries/armem_gui/instance/InstanceView.cpp index 9f9b735acd747704bad699c833d6ac64ce6898b9..09bfbc3a837ba94d5003867247b865b4e364b39f 100644 --- a/source/RobotAPI/libraries/armem_gui/instance/InstanceView.cpp +++ b/source/RobotAPI/libraries/armem_gui/instance/InstanceView.cpp @@ -15,8 +15,8 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AronNDArrayDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> #include <RobotAPI/libraries/armem_gui/gui_utils.h> #include <RobotAPI/libraries/armem_gui/instance/InstanceTreeDataVisitor.h> @@ -91,7 +91,7 @@ namespace armarx::armem::gui::instance void InstanceView::update(const MemoryID& id, const Memory& memory) { - aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr; + aron::typenavigator::ObjectNavigatorPtr aronType = nullptr; const armem::EntityInstance* instance = nullptr; try { @@ -113,7 +113,7 @@ namespace armarx::armem::gui::instance } - void InstanceView::update(const EntityInstance& instance, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) + void InstanceView::update(const EntityInstance& instance, aron::typenavigator::ObjectNavigatorPtr aronType) { currentInstance = instance; currentAronType = aronType; @@ -145,7 +145,7 @@ namespace armarx::armem::gui::instance } } - void InstanceView::updateData(const aron::datanavigator::AronDictDataNavigatorPtr& data, aron::typenavigator::AronObjectTypeNavigatorPtr aronType) + void InstanceView::updateData(const aron::datanavigator::AronDictDataNavigatorPtr& data, aron::typenavigator::ObjectNavigatorPtr aronType) { armarx::gui::clearItem(treeItemData); if (!data) @@ -205,13 +205,13 @@ namespace armarx::armem::gui::instance QMenu menu(this); - aron::AronTypeDescriptor type = static_cast<aron::AronTypeDescriptor>(item->data(int(Columns::TYPE), Qt::UserRole).toInt()); + aron::type::Descriptor type = static_cast<aron::type::Descriptor>(item->data(int(Columns::TYPE), Qt::UserRole).toInt()); switch (type) { - case aron::AronTypeDescriptor::eAronIVTCByteImageType: + case aron::type::Descriptor::eAronIVTCByteImageType: { QStringList qpath = item->data(int(Columns::KEY), Qt::UserRole).toStringList(); - aron::AronPath path = InstanceTreeTypedDataVisitor::deserializeAronPath(qpath); + aron::Path path = InstanceTreeTypedDataVisitor::deserializePath(qpath); QAction* viewAction = new QAction("Show image"); menu.addAction(viewAction); @@ -228,7 +228,7 @@ namespace armarx::armem::gui::instance menu.exec(tree->mapToGlobal(pos)); } - void InstanceView::showImageView(const aron::AronPath& elementPath) + void InstanceView::showImageView(const aron::Path& elementPath) { if (!currentInstance) { diff --git a/source/RobotAPI/libraries/armem_gui/instance/InstanceView.h b/source/RobotAPI/libraries/armem_gui/instance/InstanceView.h index 4717e5adebf3f0bb9a403abb783f87ea7597e661..bb6891eb680a6d03d7c1e3cde0ea69a6d2730d15 100644 --- a/source/RobotAPI/libraries/armem_gui/instance/InstanceView.h +++ b/source/RobotAPI/libraries/armem_gui/instance/InstanceView.h @@ -4,7 +4,7 @@ #include <QWidget> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> #include <RobotAPI/libraries/armem/core/Memory.h> @@ -35,7 +35,7 @@ namespace armarx::armem::gui::instance void setUseTypeInfo(bool enable); void update(const MemoryID& id, const Memory& memory); - void update(const EntityInstance& instance, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); + void update(const EntityInstance& instance, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); void update(); @@ -48,14 +48,14 @@ namespace armarx::armem::gui::instance private slots: void prepareTreeContextMenu(const QPoint& pos); - void showImageView(const aron::AronPath& elementPath); + void showImageView(const aron::Path& elementPath); void removeImageView(); private: void updateInstanceID(const MemoryID& id); - void updateData(const aron::datanavigator::AronDictDataNavigatorPtr& data, aron::typenavigator::AronObjectTypeNavigatorPtr aronType = nullptr); + void updateData(const aron::datanavigator::AronDictDataNavigatorPtr& data, aron::typenavigator::ObjectNavigatorPtr aronType = nullptr); void updateMetaData(const EntityInstanceMetadata& metadata); void updateImageView(const aron::datanavigator::AronDictDataNavigatorPtr& data); @@ -72,7 +72,7 @@ namespace armarx::armem::gui::instance }; std::optional<EntityInstance> currentInstance; - aron::typenavigator::AronObjectTypeNavigatorPtr currentAronType = nullptr; + aron::typenavigator::ObjectNavigatorPtr currentAronType = nullptr; bool useTypeInfo = true; QSplitter* splitter; @@ -90,7 +90,7 @@ namespace armarx::armem::gui::instance QGroupBox* group; instance::ImageView* view; - aron::AronPath elementPath; + aron::Path elementPath; }; std::optional<ImageView> imageView; diff --git a/source/RobotAPI/libraries/aron/aroncore/AronConcepts.h b/source/RobotAPI/libraries/aron/aroncore/AronConcepts.h deleted file mode 100644 index 086d630375eda8fdccc5d73bc07428a7bb30ebf9..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronConcepts.h +++ /dev/null @@ -1,161 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <string> - -// ArmarX -#include <RobotAPI/interface/aron.h> - - - -// TODO: REMOVE!!! -namespace armarx -{ - namespace aron - { - - - /* // General Concepts - template <typename CppType> - concept IsAronPrimitiveCppType = false - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<CppType, lowerType>::value) - - HANDLE_PRIMITIVE_TYPES - #undef RUN_ARON_MACRO - ; - - template <typename AronData, typename CppType> - concept AreAronPrimitiveDependent = false - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronData, Aron##upperType>::value && std::is_same<CppType, lowerType>::value) - - HANDLE_PRIMITIVE_TYPES - #undef RUN_ARON_MACRO - ; - - template <typename AronData> - concept IsAronData = false - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronData, Aron##upperType>::value) - - HANDLE_ALL_ARON_DATA - #undef RUN_ARON_MACRO - ; - - template <typename AronAbstractTypeType> - concept IsAronAbstractType = false - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronAbstractTypeType, Aron##upperType##Type>::value) - - HANDLE_ALL_ARON_TYPES - #undef RUN_ARON_MACRO - ; - - template <typename AronAbstractTypeType, typename AronData, typename CppType> - concept AreAronAbstractTypeAndPrimitiveDependent = false - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronAbstractTypeType, Aron##upperType##Type>::value && std::is_same<AronData, Aron##upperType>::value && std::is_same<CppType, lowerType>::value) - - HANDLE_PRIMITIVE_TYPES - #undef RUN_ARON_MACRO - ; - - - - // Compound - template <typename Aron> - concept isAron = IsAronData<Aron> || IsAronAbstractType<Aron>; - - - - - - // AronDataNavigator Concepts - namespace data - { - class AronDataNavigator; - - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##DataNavigator; - - HANDLE_CONTAINER_DATA - #undef RUN_ARON_MACRO - - template<typename AronDataType, typename CppType> requires AreAronPrimitiveDependent<AronDataType, CppType> - class AronPrimitiveDataNavigator; - - template <typename AronDataNavigator> - concept IsAronDataNavigator = false - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronDataNavigator, Aron##upperType##DataNavigator>::value) - - HANDLE_CONTAINER_DATA - #undef RUN_ARON_MACRO - - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronDataNavigator, AronPrimitiveDataNavigator<Aron##upperType, lowerType>>::value) - - HANDLE_PRIMITIVE_TYPES - #undef RUN_ARON_MACRO - ; - } - - - - - - // AronAbstractTypeNavigator Concepts - namespace types - { - class AronAbstractTypeNavigator; - - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##TypeNavigator; - - HANDLE_CONTAINER_TYPES - #undef RUN_ARON_MACRO - - template<typename AronAbstractTypeType, typename AronDataType, typename CppType> requires AreAronAbstractTypeAndPrimitiveDependent<AronAbstractTypeType, AronDataType, CppType> - class AronPrimitiveTypeNavigator; - - template <typename AronAbstractTypeNavigator> - concept IsAronAbstractTypeNavigator = false - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronAbstractTypeNavigator, Aron##upperType##TypeNavigator>::value) - - HANDLE_CONTAINER_TYPES - #undef RUN_ARON_MACRO - - #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - || (std::is_same<AronAbstractTypeNavigator, AronPrimitiveTypeNavigator<Aron##upperType##Type, Aron##upperType, lowerType>>::value) - - HANDLE_PRIMITIVE_TYPES - #undef RUN_ARON_MACRO - ; - }*/ - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronDebug.h b/source/RobotAPI/libraries/aron/aroncore/AronDebug.h deleted file mode 100644 index b879d8b82ac70ab688ef5f7b7b046af565ff5c7c..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronDebug.h +++ /dev/null @@ -1,88 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> - -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.h> - -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.h> - -namespace armarx -{ - namespace aron - { - class AronDebug - { - public: - AronDebug() = delete; - - static std::string AronDataPtrToString(const data::AronDataPtr& data) - { - io::AronDataNlohmannJSONWriter w; - io::AronDataWriterVisitor::SetupWriterFromAronDataPtr(w, data); - return w.getResult().dump(2); - } - - static std::string AronDataNavigatorPtrToString(const datanavigator::AronDataNavigatorPtr& data) - { - if (data == nullptr) - { - return ""; - } - io::AronDataNlohmannJSONWriter w; - io::AronDataWriterVisitor::SetupWriterFromAronDataPtr(w, data); - return w.getResult().dump(2); - } - - static std::string AronTypePtrToString(const type::AronTypePtr& data) - { - io::AronTypeNlohmannJSONWriter w; - io::AronTypeWriterVisitor::SetupWriterFromAronTypePtr(w, data); - return w.getResult().dump(2); - } - - static std::string AronTypeNavigatorPtrToString(const typenavigator::AronTypeNavigatorPtr& data) - { - if (data == nullptr) - { - return ""; - } - io::AronTypeNlohmannJSONWriter w; - io::AronTypeWriterVisitor::SetupWriterFromAronTypePtr(w, data); - return w.getResult().dump(2); - } - }; - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronException.h b/source/RobotAPI/libraries/aron/aroncore/AronException.h deleted file mode 100644 index 48b8c7ef8807e299195154ba4c923eb82a710415..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronException.h +++ /dev/null @@ -1,160 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL - -// ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> -#include <RobotAPI/libraries/aron/aroncore/AronPath.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> - -namespace armarx -{ - namespace aron - { - namespace exception - { - class AronException : - public armarx::LocalException - { - public: - AronException() = delete; - AronException(const std::string& caller, const std::string& method, const std::string& reason) : - LocalException(caller + "::" + method + ": " + reason) - { - - } - }; - - class AronNotImplementedYetException : - public AronException - { - public: - AronNotImplementedYetException() = delete; - AronNotImplementedYetException(const std::string& caller, const std::string& method) : - AronException(caller, method, "This method is not yet implemented!") - { - - } - }; - - class AronExceptionWithPathInfo : - public AronException - { - public: - AronExceptionWithPathInfo() = delete; - AronExceptionWithPathInfo(const std::string& caller, const std::string& method, const std::string& reason, const AronPath& path) : - AronException(caller, method, reason + ". The path was: " + path.toString()) - { - - } - }; - - class AronDataNotValidException : - public AronException - { - public: - AronDataNotValidException() = delete; - AronDataNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const data::AronDataPtr& data) : - AronException(caller, method, reason + ". The ice_id of the data was: " + data->ice_id()) - { - - } - }; - - class AronTypeNotValidException : - public AronException - { - public: - AronTypeNotValidException() = delete; - AronTypeNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const type::AronTypePtr& type) : - AronException(caller, method, reason + ". The ice_id of the type was: " + type->ice_id()) - { - - } - }; - - class AronTypeDescriptorNotValidException : - public AronException - { - public: - AronTypeDescriptorNotValidException() = delete; - AronTypeDescriptorNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const AronTypeDescriptor& type) : - AronException(caller, method, reason + ". The name of the type-enum was: " + AronTypeDescriptorToString.at(type)) - { - - } - }; - - class AronDataDescriptorNotValidException : - public AronException - { - public: - AronDataDescriptorNotValidException() = delete; - AronDataDescriptorNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const AronDataDescriptor& data) : - AronException(caller, method, reason + ". The name of the data-enum was: " + AronDataDescriptorToString.at(data)) - { - - } - }; - - class AronStringNotValidException : - public AronException - { - public: - AronStringNotValidException() = delete; - AronStringNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const std::string& input) : - AronException(caller, method, reason + ". Got: " + input) - { - - } - }; - - class AronIndexNotValidException : - public AronException - { - public: - AronIndexNotValidException() = delete; - AronIndexNotValidException(const std::string& caller, const std::string& method, const std::string& reason, int real, int expected) : - AronException(caller, method, reason + ". The requested index is: " + std::to_string(real) + ". The maximum index was: " + std::to_string(expected)) - { - - } - }; - - class AronSizeNotValidException : - public AronException - { - public: - AronSizeNotValidException() = delete; - AronSizeNotValidException(const std::string& caller, const std::string& method, const std::string& reason, int real, int expected) : - AronException(caller, method, reason + ". The measured size is: " + std::to_string(real) + ". The expected size was: " + std::to_string(expected)) - { - - } - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronFactory.h b/source/RobotAPI/libraries/aron/aroncore/AronFactory.h deleted file mode 100644 index 6ec2b1604afa7fd576895326a9828c6b466647c5..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronFactory.h +++ /dev/null @@ -1,103 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> -#include <string> -#include <unordered_map> - -// ArmarX -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/AronPath.h> -#include <RobotAPI/libraries/aron/aroncore/AronException.h> - -namespace armarx -{ - namespace aron - { - template <typename Input, typename Output> - class AronFactory - { - public: - AronFactory() = default; - - virtual Output create(const Input&, const AronPath&) const = 0; - virtual Output createSpecific(const Input&, const AronPath&) const = 0; - }; - - template <typename Input, typename Output> - class AronPtrInputFactory : - virtual public AronFactory<Input, Output> - { - public: - AronPtrInputFactory() = default; - - virtual Output create(const Input&, const AronPath&) const = 0; - virtual Output createSpecific(const Input&, const AronPath&) const = 0; - - protected: - static void CheckIfInputIsNull(const std::string& c, const std::string& m, const AronPath& p, const Input& i) - { - if (i.get() == nullptr) - { - throw exception::AronExceptionWithPathInfo(c, m, "The used input is NULL", p); - } - } - }; - - template <typename Input, typename Output> - class AronPtrOutputFactory : - virtual public AronFactory<Input, Output> - { - public: - AronPtrOutputFactory() = default; - - virtual Output create(const Input&, const AronPath&) const = 0; - virtual Output createSpecific(const Input&, const AronPath&) const = 0; - - protected: - static void CheckIfOutputIsNull(const std::string& c, const std::string& m, const AronPath& p, const Output& o) - { - if (o.get() == nullptr) - { - throw exception::AronExceptionWithPathInfo(c, m, "The used output is NULL", p); - } - } - }; - - template <typename Input, typename Output> - class AronPtrInputPtrOutputFactory : - virtual public AronPtrInputFactory<Input, Output>, - virtual public AronPtrOutputFactory<Input, Output> - { - public: - AronPtrInputPtrOutputFactory() = default; - - virtual Output create(const Input&, const AronPath&) const = 0; - virtual Output createSpecific(const Input&, const AronPath&) const = 0; - }; - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronPath.cpp b/source/RobotAPI/libraries/aron/aroncore/AronPath.cpp deleted file mode 100644 index 6c01b59e43a5c632541fe808ac113319dfe51874..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronPath.cpp +++ /dev/null @@ -1,194 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -// Header -#include "AronPath.h" - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> - -namespace armarx -{ - namespace aron - { - AronPath::AronPath() : - rootIdentifier("\\"), - delimeter("->") - { - - } - - AronPath::AronPath(const std::vector<std::string>& p) : - path(p) - { - - } - - AronPath::AronPath(const std::string& s, const std::string& d): - rootIdentifier(s), - delimeter(d) - { - - } - - AronPath::AronPath(const std::string& s, const std::string& d, const std::vector<std::string>& p) : - rootIdentifier(s), - delimeter(d), - path(p) - { - - } - - AronPath::AronPath(const AronPath& p) : - rootIdentifier(p.getRootIdentifier()), - delimeter(p.getDelimeter()), - path(p.getPath()) - { - - } - - AronPath::AronPath(const AronPath& p, const std::string& s) : - AronPath(p) - { - appendPath(s); - } - - AronPath::AronPath(const AronPath& p, const std::string& s, const std::string& s2) : - AronPath(p) - { - appendPath(s); - appendPath(s2); - } - - AronPath::AronPath(const AronPath& pa, const std::vector<std::string>& p) : - AronPath(pa) - { - for (const std::string& s : p) - { - appendPath(s); - } - } - - void AronPath::setRootIdentifier(const std::string& s) - { - rootIdentifier = s; - } - - std::string AronPath::getRootIdentifier() const - { - return rootIdentifier; - } - - void AronPath::setDelimeter(const std::string& d) - { - delimeter = d; - } - - std::string AronPath::getDelimeter() const - { - return delimeter; - } - - void AronPath::appendPath(const std::string& str) - { - path.push_back(str); - } - - std::vector<std::string> AronPath::getPath() const - { - return path; - } - - std::string AronPath::getLastElement() const - { - if (!hasElement()) - { - throw exception::AronException("AronNavigatorPath", "getLastElement", "Try to access last element of empty vector."); - } - return path.back(); - } - - std::string AronPath::getFirstElement() const - { - if (!hasElement()) - { - throw exception::AronException("AronNavigatorPath", "getFirstElement", "Try to access last element of empty vector."); - } - return path[0]; - } - - bool AronPath::hasElement() const - { - return path.size() > 0; - } - - size_t AronPath::size() const - { - return path.size(); - } - - std::string AronPath::toString() const - { - std::stringstream ss; - ss << rootIdentifier; - for (const std::string& s : path) - { - ss << delimeter << s; - } - return ss.str(); - } - - AronPath AronPath::withDetachedLastElement() const - { - std::vector<std::string> p = path; - p.pop_back(); - return AronPath(rootIdentifier, delimeter, p); - } - - AronPath AronPath::withDetachedFirstElement() const - { - std::vector<std::string> p = path; - p.erase(p.begin()); - return AronPath(rootIdentifier, delimeter, p); - } - - AronPath AronPath::getWithoutPrefix(const AronPath& pref) const - { - unsigned int firstWithoutMatch = 0; - for (const std::string& el : pref.getPath()) - { - if (path.size() <= firstWithoutMatch || el != path[firstWithoutMatch]) - { - break; - } - else - { - firstWithoutMatch++; - } - } - std::vector<std::string> elementsWithoutPrefix(path.begin() + firstWithoutMatch, path.end()); - return AronPath(rootIdentifier, delimeter, elementsWithoutPrefix); - - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronPath.h b/source/RobotAPI/libraries/aron/aroncore/AronPath.h deleted file mode 100644 index 31a5dcdf3eb8c975fe276e921ba000411a149b55..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronPath.h +++ /dev/null @@ -1,77 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include<vector> -#include<string> - -// ArmarX -#include <RobotAPI/interface/aron.h> - -namespace armarx -{ - namespace aron - { - class AronPath - { - public: - AronPath(); - AronPath(const std::vector<std::string>&); - AronPath(const std::string&, const std::string&); - AronPath(const std::string&, const std::string&, const std::vector<std::string>&); - AronPath(const AronPath&); - AronPath(const AronPath&, const std::string&); - AronPath(const AronPath&, const std::string&, const std::string&); - AronPath(const AronPath&, const std::vector<std::string>&); - AronPath& operator=(const armarx::aron::AronPath&) = default; - - std::vector<std::string> getPath() const; - std::string getFirstElement() const; - std::string getLastElement() const; - bool hasElement() const; - size_t size() const; - - void setRootIdentifier(const std::string&); - std::string getRootIdentifier() const; - - void setDelimeter(const std::string&); - std::string getDelimeter() const; - - std::string toString() const; - - AronPath withDetachedFirstElement() const; - AronPath withDetachedLastElement() const; - AronPath getWithoutPrefix(const AronPath&) const; - - private: - void appendPath(const std::string&); - - private: - std::string rootIdentifier; - std::string delimeter; - std::vector<std::string> path; - }; - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronRandomizer.h b/source/RobotAPI/libraries/aron/aroncore/AronRandomizer.h deleted file mode 100644 index 166eb496abb99e28f5bb8f229e1d95a085f86bc1..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronRandomizer.h +++ /dev/null @@ -1,349 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> -#include <numeric> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> - -namespace armarx -{ - namespace aron - { - class AronRandomizer - { - public: - AronRandomizer() - { - initialize_random(); - }; - - typenavigator::AronTypeNavigatorPtr generateRandomType(bool mustBeObject = false) const - { - AronTypeDescriptor nextType = eAronObjectType; - if (!mustBeObject) - { - std::vector<AronTypeDescriptor> descriptors = - { -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - eAron##upperType##Type, - - HANDLE_ALL_ARON_TYPES -#undef RUN_ARON_MACRO - }; - - int randomType = generateRandom(descriptors.size(), 0); - nextType = descriptors[randomType]; - } - - switch (nextType) - { - case eAronObjectType: - { - typenavigator::AronObjectTypeNavigatorPtr t = typenavigator::AronObjectTypeNavigatorPtr(new typenavigator::AronObjectTypeNavigator(AronPath())); - std::string objectName = generateRandomWord(); - t->setObjectName(objectName); - - std::vector<std::string> usedNames({objectName}); - int members = generateRandom(4, 2); - std::set<std::string> usedKeys; - for (int i = 0; i < members; ++i) - { - std::string key = generateRandomWord(usedKeys); - usedKeys.insert(key); - - typenavigator::AronTypeNavigatorPtr m = generateRandomType(false); - t->addAcceptedType(key, m); - } - return t; - } - case eAronDictType: - { - typenavigator::AronDictTypeNavigatorPtr t = typenavigator::AronDictTypeNavigatorPtr(new typenavigator::AronDictTypeNavigator(AronPath())); - typenavigator::AronTypeNavigatorPtr a = generateRandomType(false); - - t->setAcceptedType(a); - return t; - } - case eAronTupleType: - { - typenavigator::AronTupleTypeNavigatorPtr t = typenavigator::AronTupleTypeNavigatorPtr(new typenavigator::AronTupleTypeNavigator(AronPath())); - - int members = generateRandom(4, 2); - for (int i = 0; i < members; ++i) - { - typenavigator::AronTypeNavigatorPtr m = generateRandomType(false); - t->addAcceptedType(m); - } - return t; - } - case eAronListType: - { - typenavigator::AronListTypeNavigatorPtr t = typenavigator::AronListTypeNavigatorPtr(new typenavigator::AronListTypeNavigator(AronPath())); - typenavigator::AronTypeNavigatorPtr a = generateRandomType(false); - - t->setAcceptedType(a); - return t; - } -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ -case eAron##upperType##Type: - - HANDLE_COMPLEX_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ -case eAron##upperType##Type: \ -{ \ - typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigatorPtr(new typenavigator::Aron##upperType##TypeNavigator(AronPath())); \ - return t; \ -} - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - default: - { - throw armarx::aron::exception::AronTypeDescriptorNotValidException("AronTest", "generateRandomType", "No valid type found!", nextType); - } - } - } - - datanavigator::AronDataNavigatorPtr generateAronDataFromType(const typenavigator::AronTypeNavigatorPtr& type) const - { - const AronTypeDescriptor desc = type->getDescriptor(); - switch (desc) - { - // In an object, we do not want to edit the keys. - case eAronObjectType: - { - typenavigator::AronObjectTypeNavigatorPtr t = typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck(type); - datanavigator::AronDictDataNavigatorPtr d = datanavigator::AronDictDataNavigatorPtr(new datanavigator::AronDictDataNavigator()); - for (const auto& [k, tt] : t->getAcceptedTypes()) - { - d->addElement(k, generateAronDataFromType(tt)); - } - return d; - } - - // here all totally random - case eAronDictType: - { - typenavigator::AronDictTypeNavigatorPtr t = typenavigator::AronDictTypeNavigator::DynamicCastAndCheck(type); - return datanavigator::AronDataNavigatorPtr(new datanavigator::AronDictDataNavigator()); - } - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ -case eAron##upperType##Type: \ -{ \ - typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ - return datanavigator::AronDataNavigatorPtr(new datanavigator::AronListDataNavigator()); \ -} - - HANDLE_LIST_SERIALIZER_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ -case eAron##upperType##Type: \ -{ \ - typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ - return datanavigator::AronDataNavigatorPtr(new datanavigator::AronNDArrayDataNavigator()); \ -} - - HANDLE_COMPLEX_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ -case eAron##upperType##Type: \ -{ \ - typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ - return datanavigator::AronDataNavigatorPtr(new datanavigator::Aron##upperType##DataNavigator()); \ -} - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - default: - { - throw armarx::aron::exception::AronTypeDescriptorNotValidException("AronTest", "generateAronDataFromType", "No valid type found!", desc); - } - } - } - - - void initializeRandomly(datanavigator::AronDictDataNavigatorPtr& data, const typenavigator::AronObjectTypeNavigatorPtr& type) const - { - for (auto& [key, nextData] : data->getElements()) - { - initializeRandomly(nextData, type->getAcceptedTypes()[key]); - } - } - - void initializeRandomly(datanavigator::AronDictDataNavigatorPtr& data, const typenavigator::AronDictTypeNavigatorPtr& type) const - { - data->clear(); - int numElements = generateRandom(5, 1); - std::set<std::string> usedKeys; - for (int i = 0; i < numElements; ++i) - { - std::string key = generateRandomWord(usedKeys); - usedKeys.insert(key); - datanavigator::AronDataNavigatorPtr newData = generateAronDataFromType(type->getAcceptedType()); - initializeRandomly(newData, type->getAcceptedType()); - data->addElement(key, newData); - } - } - - void initializeRandomly(datanavigator::AronListDataNavigatorPtr& data, const typenavigator::AronTupleTypeNavigatorPtr& type) const - { - unsigned int i = 0; - for (auto& nextData : data->getElements()) - { - initializeRandomly(nextData, type->getAcceptedTypes()[i++]); - } - } - - void initializeRandomly(datanavigator::AronListDataNavigatorPtr& data, const typenavigator::AronListTypeNavigatorPtr& type) const - { - data->clear(); - int numElements = generateRandom(5, 1); - for (int i = 0; i < numElements; ++i) - { - datanavigator::AronDataNavigatorPtr newData = generateAronDataFromType(type->getAcceptedType()); - initializeRandomly(newData, type->getAcceptedType()); - data->addElement(newData); - } - } - - void initializeRandomly(datanavigator::AronNDArrayDataNavigatorPtr& data, const typenavigator::AronNDArraySerializerTypeNavigatorPtr& type) const - { - std::vector<int> dims = data->getDimensions(); - int bytes = std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()); - std::vector<unsigned char> blob = generateRandomBlob(bytes); - data->setData(bytes, blob.data()); - } - - void initializeRandomly(datanavigator::AronIntDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const - { - data->setValue(generateRandom(1000, -1000)); - } - - void initializeRandomly(datanavigator::AronLongDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const - { - data->setValue(generateRandom(1000, -1000)); - } - - void initializeRandomly(datanavigator::AronFloatDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const - { - data->setValue(generateRandom(1000, -1000)); - } - - void initializeRandomly(datanavigator::AronDoubleDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const - { - data->setValue(generateRandom(1000, -1000)); - } - - void initializeRandomly(datanavigator::AronBoolDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const - { - data->setValue(generateRandom(1, 0)); - } - - void initializeRandomly(datanavigator::AronStringDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const - { - data->setValue(generateRandomWord()); - } - - void initializeRandomly(datanavigator::AronDataNavigatorPtr& data, const typenavigator::AronTypeNavigatorPtr& type) const - { - // Containers - AronTypeDescriptor desc = type->getDescriptor(); - switch (desc) - { - -#define RUN_ARON_MACRO(upperType, lowerType, capsType, upperData, lowerData, capsData) \ -case eAron##upperType##Type: \ -{ \ - typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ - datanavigator::Aron##upperData##DataNavigatorPtr d = datanavigator::Aron##upperData##DataNavigator::DynamicCastAndCheck(data); \ - initializeRandomly(d, t); \ - break; \ -} - - HANDLE_ALL_CORRESPONDING -#undef RUN_ARON_MACRO - - default: - { - throw armarx::aron::exception::AronTypeDescriptorNotValidException("AronTest", "initializeRandomly", "No valid type found!", desc); - } - } - } - - int generateRandom(int max, int min) const - { - max += 1; - int random = (std::rand() % (max - min)) + min; - return random; - } - - std::string generateRandomWord(const std::set<std::string>& usedKeys = {}) const - { - std::vector<string> words = - { - "Lorem", "ipsum", "dolor", "sit", "amet", "consetetur", "sadipscing", "elitr" - "sed", "diam", "nonumy", "eirmod", "tempor", "invidunt", "ut", "labore", "et" - "dolore", "magna", "aliquyam", "eratsed" - }; - - int i = generateRandom(words.size() - 1, 0); - std::string key = words[i]; - - while (usedKeys.count(key) > 0) - { - key = generateRandomWord(usedKeys); - } - - return key; - } - - std::vector<unsigned char> generateRandomBlob(unsigned int size) const - { - 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; - } - - protected: - void initialize_random() const - { - std::srand(std::time(nullptr)); - } - }; - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronResolver.cpp b/source/RobotAPI/libraries/aron/aroncore/AronResolver.cpp deleted file mode 100644 index ad82cfb7bcbaff9b8c60a545626895ca74cdd0e0..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronResolver.cpp +++ /dev/null @@ -1,177 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -// Simox -#include <SimoxUtility/meta/type_name.h> - -// Header -#include "AronResolver.h" - -namespace armarx -{ - namespace aron - { - AronTypeDescriptor AronResolver::GetDescriptorForAronType(const type::AronTypePtr& a) - { -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - { \ - type::Aron##upperType##TypePtr aron = type::Aron##upperType##TypePtr::dynamicCast(a); \ - if(aron.get() != nullptr) \ - { \ - return eAron##upperType##Type; \ - } \ - } - HANDLE_ALL_ARON_TYPES -#undef RUN_ARON_MACRO - throw exception::AronTypeNotValidException("AronTypeResolver", "GetTypeForAronAbstractType", "Could not cast AronAbstractType to a valid type", a); - } - - AronTypeDescriptor AronResolver::GetDescriptorForAronTypeId(const std::type_index& a) - { -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - { \ - if(a == std::type_index(typeid(type::Aron##upperType##Type))) \ - { \ - return eAron##upperType##Type; \ - } \ - } - HANDLE_ALL_ARON_TYPES -#undef RUN_ARON_MACRO - throw exception::AronException("AronTypeResolver", "GetTypeForAronTypeId", "Could not cast AronAbstractTypeId to a valid type. The typeid was " + simox::meta::get_type_name(a)); - } - - AronDataDescriptor AronResolver::GetDescriptorForAronData(const data::AronDataPtr& a) - { -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - { \ - data::Aron##upperType##Ptr aron = data::Aron##upperType##Ptr::dynamicCast(a); \ - if(aron.get() != nullptr) \ - { \ - return eAron##upperType; \ - } \ - } - HANDLE_ALL_ARON_DATA -#undef RUN_ARON_MACRO - throw exception::AronDataNotValidException("AronTypeResolver", "GetTypeForAronData", "Could not cast AronData to a valid type", a); - } - - AronDataDescriptor AronResolver::GetDescriptorForAronDataId(const std::type_index& a) - { -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - { \ - if(a == std::type_index(typeid(data::Aron##upperType))) \ - { \ - return eAron##upperType; \ - } \ - } - HANDLE_ALL_ARON_DATA -#undef RUN_ARON_MACRO - throw exception::AronException("AronTypeResolver", "GetTypeForAronDataTypeId", "Could not cast AronDataTypeId to a valid type. The typeid was " + simox::meta::get_type_name(a)); - } - - bool AronResolver::TypesAreCorresponding(const AronTypeDescriptor& t, const AronDataDescriptor& d) - { -#define RUN_ARON_MACRO(typeUpperType, typeLowerType, typeCapsType, dataUpperType, dataLowerType, dataCapsType) \ - if(t == AronTypeDescriptor::eAron##typeUpperType##Type && d == AronDataDescriptor::eAron##dataUpperType) \ - { \ - return true; \ - } - - HANDLE_ALL_CORRESPONDING -#undef RUN_ARON_MACRO - return false; - } - - AronDataDescriptor AronResolver::GetCorrespondingDataDescriptor(const AronTypeDescriptor& d) - { -#define RUN_ARON_MACRO(typeUpperType, typeLowerType, typeCapsType, dataUpperType, dataLowerType, dataCapsType) \ - { \ - if(d == eAron##typeUpperType##Type) \ - { \ - return eAron##dataUpperType; \ - } \ - } - HANDLE_ALL_CORRESPONDING -#undef RUN_ARON_MACRO - return eAronUnknown; - } - - bool AronResolver::DescriptorsAreRelated(const AronDataDescriptor& d, const AronDataDescriptor& d2) - { - if (d == d2) - { - return true; - } -#define RUN_ARON_MACRO(data1UpperType, data1LowerType, data1CapsType, data2UpperType, data2LowerType, data2CapsType) \ - if( \ - (d == AronDataDescriptor::eAron##data1UpperType && d2 == AronDataDescriptor::eAron##data2UpperType) || \ - (d2 == AronDataDescriptor::eAron##data1UpperType && d == AronDataDescriptor::eAron##data2UpperType) \ - ) \ - { \ - return true; \ - } - - HANDLE_ARON_PRIMITIVE_DATA_RELATED -#undef RUN_ARON_MACRO - return false; - } - - bool AronResolver::DescriptorsAreRelated(const AronTypeDescriptor& t, const AronTypeDescriptor& t2) - { - if (t == t2) - { - return true; - } -#define RUN_ARON_MACRO(type1UpperType, type1LowerType, type1CapsType, type2UpperType, type2LowerType, type2CapsType) \ - if( \ - (t == AronTypeDescriptor::eAron##type1UpperType##Type && t2 == AronTypeDescriptor::eAron##type2UpperType##Type) || \ - (t2 == AronTypeDescriptor::eAron##type1UpperType##Type && t == AronTypeDescriptor::eAron##type2UpperType##Type) \ - ) \ - { \ - return true; \ - } - - HANDLE_ARON_PRIMITIVE_DATA_RELATED -#undef RUN_ARON_MACRO - return false; - } - - AronDataDescriptor AronResolver::GetFirstIfDescriptorsAreRelated(const AronDataDescriptor& d, const AronDataDescriptor& d2) - { - if (DescriptorsAreRelated(d, d2)) - { - return d; - } - return d2; - } - - AronTypeDescriptor AronResolver::GetFirstIfDescriptorsAreRelated(const AronTypeDescriptor& t, const AronTypeDescriptor& t2) - { - if (DescriptorsAreRelated(t, t2)) - { - return t; - } - return t2; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronResolver.h b/source/RobotAPI/libraries/aron/aroncore/AronResolver.h deleted file mode 100644 index 9bbdf6e15bcb98e5de63e5b93f49a8b0ba5ad481..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/AronResolver.h +++ /dev/null @@ -1,66 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> -#include <typeindex> -#include <typeinfo> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> - -namespace armarx -{ - namespace aron - { - class AronResolver - { - private: // disallow creating this object. static use only - AronResolver() = delete; - - public: - static AronTypeDescriptor GetDescriptorForAronType(const type::AronTypePtr&); - - static AronTypeDescriptor GetDescriptorForAronTypeId(const std::type_index&); - - static AronDataDescriptor GetDescriptorForAronData(const data::AronDataPtr&); - - static AronDataDescriptor GetDescriptorForAronDataId(const std::type_index&); - - static bool TypesAreCorresponding(const AronTypeDescriptor&, const AronDataDescriptor&); - - static AronDataDescriptor GetCorrespondingDataDescriptor(const AronTypeDescriptor&); - - static bool DescriptorsAreRelated(const AronDataDescriptor&, const AronDataDescriptor&); - static bool DescriptorsAreRelated(const AronTypeDescriptor&, const AronTypeDescriptor&); - - static AronDataDescriptor GetFirstIfDescriptorsAreRelated(const AronDataDescriptor&, const AronDataDescriptor&); - static AronTypeDescriptor GetFirstIfDescriptorsAreRelated(const AronTypeDescriptor&, const AronTypeDescriptor&); - }; - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/CMakeLists.txt b/source/RobotAPI/libraries/aron/aroncore/CMakeLists.txt index fb75e9b7c50bbdd4d6769d3a371a3c47b24a7e9a..4d3a6022170abf7bab85954341fce76cbb45df9e 100644 --- a/source/RobotAPI/libraries/aron/aroncore/CMakeLists.txt +++ b/source/RobotAPI/libraries/aron/aroncore/CMakeLists.txt @@ -25,182 +25,186 @@ set(LIBS ) set(LIB_FILES - AronResolver.cpp - AronPath.cpp - - navigators/datanavigator/AronDataNavigator.cpp - navigators/datanavigator/AronListDataNavigator.cpp - navigators/datanavigator/AronDictDataNavigator.cpp - navigators/datanavigator/AronNDArrayDataNavigator.cpp - navigators/datanavigator/AronPrimitiveDataNavigator.cpp - navigators/datanavigator/AronDataNavigatorFactory.cpp - - navigators/typenavigator/AronTypeNavigator.cpp - navigators/typenavigator/AronObjectTypeNavigator.cpp - navigators/typenavigator/AronListTypeNavigator.cpp - navigators/typenavigator/AronDictTypeNavigator.cpp - navigators/typenavigator/AronTupleTypeNavigator.cpp - navigators/typenavigator/AronEigenMatrixTypeNavigator.cpp - navigators/typenavigator/AronIVTCByteImageTypeNavigator.cpp - navigators/typenavigator/AronOpenCVMatTypeNavigator.cpp - navigators/typenavigator/AronPCLPointCloudTypeNavigator.cpp - navigators/typenavigator/AronPrimitiveTypeNavigator.cpp - navigators/typenavigator/AronTypeNavigatorFactory.cpp - - navigators/visitors/DataVisitor.cpp - navigators/visitors/TypedDataVisitor.cpp - - io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.cpp - io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.cpp - io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.cpp - - io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.cpp - io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.cpp - - io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.cpp - io/AronDataIO/AronDataConverter/AronDataConverter.cpp - - io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.cpp - io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.cpp - io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.cpp - - io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.cpp - io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.cpp - - io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.cpp - io/AronTypeIO/AronTypeConverter/AronTypeConverter.cpp - - codegenerator/codeWriters/cppWriter/AronCppWriter.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.cpp - codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.cpp - - codegenerator/typeReaders/xmlReader/AronTypeXMLData.cpp - codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.cpp - codegenerator/typeReaders/xmlReader/AronTypeXMLReader.cpp + Resolver.cpp + Path.cpp + + navigator/data/Navigator.cpp + navigator/data/container/List.cpp + navigator/data/container/Dict.cpp + navigator/data/complex/NDArray.cpp + navigator/data/primitive/Primitive.cpp + navigator/data/NavigatorFactory.cpp + + navigator/type/Navigator.cpp + navigator/type/container/Object.cpp + navigator/type/container/List.cpp + navigator/type/container/Dict.cpp + navigator/type/container/Tuple.cpp + navigator/type/container/Pair.cpp + navigator/type/ndarray/EigenMatrix.cpp + navigator/type/ndarray/EigenQuaternion.cpp + navigator/type/ndarray/IVTCByteImage.cpp + navigator/type/ndarray/OpenCVMat.cpp + navigator/type/ndarray/PCLPointCloud.cpp + navigator/type/ndarray/Position.cpp + navigator/type/ndarray/Pose.cpp + navigator/type/ndarray/Orientation.cpp + navigator/type/enum/IntEnum.cpp + navigator/type/primitive/Primitive.cpp + navigator/type/NavigatorFactory.cpp + + #navigator/visitors/DataVisitor.cpp + #navigator/visitors/TypedDataVisitor.cpp + + io/dataIO/writer/navigator/NavigatorWriter.cpp + io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp + + io/dataIO/reader/navigator/NavigatorReader.cpp + io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp + + io/dataIO/visitor/Visitor.cpp + io/dataIO/converter/Converter.cpp + + io/typeIO/writer/navigator/NavigatorWriter.cpp + io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp + + io/typeIO/reader/navigator/NavigatorReader.cpp + io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.cpp + + io/typeIO/visitor/Visitor.cpp + io/typeIO/converter/Converter.cpp + + codegenerator/codeWriter/cpp/Writer.cpp + codegenerator/codeWriter/cpp/serializer/Serializer.cpp + codegenerator/codeWriter/cpp/serializer/container/Dict.cpp + codegenerator/codeWriter/cpp/serializer/container/List.cpp + codegenerator/codeWriter/cpp/serializer/container/Object.cpp + codegenerator/codeWriter/cpp/serializer/container/Tuple.cpp + codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.cpp + codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.cpp + codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.cpp + codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.cpp + codegenerator/codeWriter/cpp/serializer/primitive/Primitive.cpp + codegenerator/codeWriter/cpp/serializer/SerializerFactory.cpp + + codegenerator/typeReader/xml/Data.cpp + codegenerator/typeReader/xml/ReaderFactory.cpp + codegenerator/typeReader/xml/Reader.cpp ) set(LIB_HEADERS - AronDebug.h - AronConfig.h - AronConcepts.h - AronDescriptor.h - AronResolver.h - AronRandomizer.h - AronException.h - AronFactory.h - AronPath.h - - navigators/AronNavigator.h - navigators/AronNavigatorFactory.h - - navigators/datanavigator/AronAllDataNavigators.h - navigators/datanavigator/AronDataNavigator.h - navigators/datanavigator/AronListDataNavigator.h - navigators/datanavigator/AronDictDataNavigator.h - navigators/datanavigator/AronNDArrayDataNavigator.h - navigators/datanavigator/AronPrimitiveDataNavigator.h - navigators/datanavigator/AronDataNavigatorFactory.h - - navigators/typenavigator/AronAllTypeNavigators.h - navigators/typenavigator/AronTypeNavigator.h - navigators/typenavigator/AronObjectTypeNavigator.h - navigators/typenavigator/AronListTypeNavigator.h - navigators/typenavigator/AronDictTypeNavigator.h - navigators/typenavigator/AronTupleTypeNavigator.h - navigators/typenavigator/AronEigenMatrixTypeNavigator.h - navigators/typenavigator/AronIVTCByteImageTypeNavigator.h - navigators/typenavigator/AronOpenCVMatTypeNavigator.h - navigators/typenavigator/AronPCLPointCloudTypeNavigator.h - navigators/typenavigator/AronPrimitiveTypeNavigator.h - navigators/typenavigator/AronTypeNavigatorFactory.h - - navigators/visitors/DataVisitor.h - navigators/visitors/TypedDataVisitor.h - - io/AronReaderWriter.h - io/AronReaderWriterToken.h - io/AronWriterToken.h - io/AronReaderToken.h - - io/AronDataIO/AronDataReaderWriter.h - io/AronDataIO/AronDataWriter.h - io/AronDataIO/classWriters/AronDataClassWriter.h - io/AronDataIO/classWriters/AronDataClassWriterToken.h - io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriterToken.h - io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h - io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.h - io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriterToken.h - io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.h - io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriterToken.h - - io/AronDataIO/AronDataReader.h - io/AronDataIO/classReaders/AronDataClassReader.h - io/AronDataIO/classReaders/AronDataClassReaderToken.h - io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReaderToken.h - io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h - io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReaderToken.h - io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.h - - io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.h - io/AronDataIO/AronDataConverter/AronDataConverter.h - - io/AronTypeIO/AronTypeReaderWriter.h - io/AronTypeIO/AronTypeWriter.h - io/AronTypeIO/classWriters/AronTypeClassWriter.h - io/AronTypeIO/classWriters/AronTypeClassWriterToken.h - io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriterToken.h - io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h - io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.h - io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriterToken.h - io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.h - io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriterToken.h - - io/AronTypeIO/AronTypeReader.h - io/AronTypeIO/classReaders/AronTypeClassReader.h - io/AronTypeIO/classReaders/AronTypeClassReaderToken.h - io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.h - io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReaderToken.h - io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.h - io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReaderToken.h - - io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.h - io/AronTypeIO/AronTypeConverter/AronTypeConverter.h - - codegenerator/AronCppClass.h - codegenerator/AronWriterInfo.h - codegenerator/AronReaderInfo.h - codegenerator/AronGenerateTypeInfo.h - - codegenerator/codeWriters/AronCodeWriter.h - codegenerator/codeWriters/AronSerializerFactory.h - - codegenerator/codeWriters/cppWriter/AronCppWriter.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronAllCppSerializers.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.h - codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.h - - codegenerator/typeReaders/AronTypeReader.h - codegenerator/typeReaders/xmlReader/AronTypeXMLData.h - codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.h - codegenerator/typeReaders/xmlReader/AronTypeXMLReader.h + Debug.h + Config.h + Concepts.h + Descriptor.h + Resolver.h + Randomizer.h + Exception.h + Factory.h + Path.h + + navigator/Navigator.h + navigator/NavigatorFactory.h + + navigator/data/Navigator.h + navigator/data/container/List.h + navigator/data/container/Dict.h + navigator/data/complex/NDArray.h + navigator/data/primitive/Primitive.h + navigator/data/AllNavigators.h + navigator/data/NavigatorFactory.h + + navigator/type/Navigator.h + navigator/type/container/Object.h + navigator/type/container/List.h + navigator/type/container/Dict.h + navigator/type/container/Tuple.h + navigator/type/container/Pair.h + navigator/type/ndarray/EigenMatrix.h + navigator/type/ndarray/EigenQuaternion.h + navigator/type/ndarray/IVTCByteImage.h + navigator/type/ndarray/OpenCVMat.h + navigator/type/ndarray/PCLPointCloud.h + navigator/type/ndarray/Position.h + navigator/type/ndarray/Pose.h + navigator/type/ndarray/Orientation.h + navigator/type/enum/IntEnum.h + navigator/type/primitive/Primitive.h + navigator/type/AllNavigators.h + navigator/type/NavigatorFactory.h + + #navigator/visitors/DataVisitor.h + #navigator/visitors/TypedDataVisitor.h + + io/Data.h + io/WriterToken.h + io/ReaderToken.h + + io/dataIO/ReaderWriter.h + io/dataIO/Writer.h + io/dataIO/writer/Writer.h + io/dataIO/writer/WriterToken.h + io/dataIO/writer/navigator/NavigatorWriterToken.h + io/dataIO/writer/navigator/NavigatorWriter.h + io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h + io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h + + io/dataIO/Reader.h + io/dataIO/reader/Reader.h + io/dataIO/reader/ReaderToken.h + io/dataIO/reader/navigator/NavigatorReaderToken.h + io/dataIO/reader/navigator/NavigatorReader.h + io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h + io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h + + io/dataIO/visitor/Visitor.h + io/dataIO/converter/Converter.h + + io/typeIO/Writer.h + io/typeIO/writer/Writer.h + io/typeIO/writer/WriterToken.h + io/typeIO/writer/navigator/NavigatorWriterToken.h + io/typeIO/writer/navigator/NavigatorWriter.h + io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.h + io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h + + io/typeIO/Reader.h + io/typeIO/reader/Reader.h + io/typeIO/reader/ReaderToken.h + io/typeIO/reader/navigator/NavigatorReader.h + io/typeIO/reader/navigator/NavigatorReaderToken.h + io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.h + io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h + + io/typeIO/visitor/Visitor.h + io/typeIO/converter/Converter.h + + codegenerator/WriterInfo.h + codegenerator/ReaderInfo.h + codegenerator/GenerateTypeInfo.h + + codegenerator/codeWriter/CodeWriter.h + codegenerator/codeWriter/SerializerFactory.h + + codegenerator/codeWriter/cpp/AronCppClass.h + codegenerator/codeWriter/cpp/Writer.h + codegenerator/codeWriter/cpp/serializer/Serializer.h + codegenerator/codeWriter/cpp/serializer/container/Dict.h + codegenerator/codeWriter/cpp/serializer/container/List.h + codegenerator/codeWriter/cpp/serializer/container/Object.h + codegenerator/codeWriter/cpp/serializer/container/Tuple.h + codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.h + codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.h + codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.h + codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.h + codegenerator/codeWriter/cpp/serializer/primitive/Primitive.h + codegenerator/codeWriter/cpp/serializer/AllSerializers.h + codegenerator/codeWriter/cpp/serializer/SerializerFactory.h + + codegenerator/typeReader/Reader.h + codegenerator/typeReader/xml/Data.h + codegenerator/typeReader/xml/ReaderFactory.h + codegenerator/typeReader/xml/Reader.h ) armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") diff --git a/source/RobotAPI/libraries/aron/aroncore/Concepts.h b/source/RobotAPI/libraries/aron/aroncore/Concepts.h new file mode 100644 index 0000000000000000000000000000000000000000..2111e240b445bcfc935c8882385e3433001cafbb --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Concepts.h @@ -0,0 +1,166 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> + +// ArmarX +#include <RobotAPI/interface/aron.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> + + +namespace armarx::aron +{ + template<class T> + static constexpr bool isPrimitive = + std::is_same_v<T, int > || + std::is_same_v<T, long > || + std::is_same_v<T, float > || + std::is_same_v<T, double > || + std::is_same_v<T, bool > || + std::is_same_v<T, std::string>; + + + // TODO: make nice + /* // General Concepts + template <typename CppType> + concept IsAronPrimitiveCppType = false + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<CppType, lowerType>::value) + + HANDLE_PRIMITIVE_TYPES + #undef RUN_ARON_MACRO + ; + + template <typename AronData, typename CppType> + concept AreAronPrimitiveDependent = false + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronData, Aron##upperType>::value && std::is_same<CppType, lowerType>::value) + + HANDLE_PRIMITIVE_TYPES + #undef RUN_ARON_MACRO + ; + + template <typename AronData> + concept IsAronData = false + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronData, Aron##upperType>::value) + + HANDLE_ALL_ARON_DATA + #undef RUN_ARON_MACRO + ; + + template <typename AronAbstractTypeType> + concept IsAronAbstractType = false + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronAbstractTypeType, Aron##upperType##Type>::value) + + HANDLE_ALL_ARON_TYPES + #undef RUN_ARON_MACRO + ; + + template <typename AronAbstractTypeType, typename AronData, typename CppType> + concept AreAronAbstractTypeAndPrimitiveDependent = false + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronAbstractTypeType, Aron##upperType##Type>::value && std::is_same<AronData, Aron##upperType>::value && std::is_same<CppType, lowerType>::value) + + HANDLE_PRIMITIVE_TYPES + #undef RUN_ARON_MACRO + ; + + + + // Compound + template <typename Aron> + concept isAron = IsAronData<Aron> || IsAronAbstractType<Aron>; + + + + + + // AronDataNavigator Concepts + namespace data + { + class AronDataNavigator; + + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + class Aron##upperType##DataNavigator; + + HANDLE_CONTAINER_DATA + #undef RUN_ARON_MACRO + + template<typename AronDataType, typename CppType> requires AreAronPrimitiveDependent<AronDataType, CppType> + class AronPrimitiveDataNavigator; + + template <typename AronDataNavigator> + concept IsAronDataNavigator = false + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronDataNavigator, Aron##upperType##DataNavigator>::value) + + HANDLE_CONTAINER_DATA + #undef RUN_ARON_MACRO + + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronDataNavigator, AronPrimitiveDataNavigator<Aron##upperType, lowerType>>::value) + + HANDLE_PRIMITIVE_TYPES + #undef RUN_ARON_MACRO + ; + } + + + + + + // AronAbstractTypeNavigator Concepts + namespace types + { + class AronAbstractTypeNavigator; + + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + class Aron##upperType##TypeNavigator; + + HANDLE_CONTAINER_TYPES + #undef RUN_ARON_MACRO + + template<typename AronAbstractTypeType, typename AronDataType, typename CppType> requires AreAronAbstractTypeAndPrimitiveDependent<AronAbstractTypeType, AronDataType, CppType> + class AronPrimitiveTypeNavigator; + + template <typename AronAbstractTypeNavigator> + concept IsAronAbstractTypeNavigator = false + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronAbstractTypeNavigator, Aron##upperType##TypeNavigator>::value) + + HANDLE_CONTAINER_TYPES + #undef RUN_ARON_MACRO + + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + || (std::is_same<AronAbstractTypeNavigator, AronPrimitiveTypeNavigator<Aron##upperType##Type, Aron##upperType, lowerType>>::value) + + HANDLE_PRIMITIVE_TYPES + #undef RUN_ARON_MACRO + ; + }*/ +} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronConfig.h b/source/RobotAPI/libraries/aron/aroncore/Config.h similarity index 77% rename from source/RobotAPI/libraries/aron/aroncore/AronConfig.h rename to source/RobotAPI/libraries/aron/aroncore/Config.h index aad8d12956613c317c9d1dcf2b8c382a33db96f1..fa258beccd9723ff64b84d473fa64706761fe713 100644 --- a/source/RobotAPI/libraries/aron/aroncore/AronConfig.h +++ b/source/RobotAPI/libraries/aron/aroncore/Config.h @@ -46,20 +46,10 @@ * | | * | |->AronList: * This container represents a std::vector<T> where T can be any datatype convertable to Aron. - * TODO: + * TODO: complete doc */ -/** - * Should I use macros in C++? - * As a rule, you should only use macros, when a better alternative does not exist. - * They should not be used to generate code; you should simply write the code instead - * (if the code is type-agnostic, write a template instead and use concepts). - * - * However I it is easier right now, so I will use it. - */ - - #include <string> namespace armarx @@ -82,67 +72,61 @@ namespace armarx RUN_ARON_MACRO(Object, object, OBJECT) \ RUN_ARON_MACRO(List, list, LIST) \ RUN_ARON_MACRO(Dict, dict, DICT) \ - RUN_ARON_MACRO(Tuple, tuple, TUPLE) \ + RUN_ARON_MACRO(Pair, pair, PAIR) \ + RUN_ARON_MACRO(Tuple, tuple, TUPLE) -#define HANDLE_DICT_SERIALIZER_TYPES \ +// TODO: Remove +/*#define HANDLE_DICT_SERIALIZER_TYPES \ RUN_ARON_MACRO(Object, object, OBJECT) \ - RUN_ARON_MACRO(Dict, dict, DICT) \ + RUN_ARON_MACRO(Dict, dict, DICT) #define HANDLE_LIST_SERIALIZER_TYPES \ RUN_ARON_MACRO(List, list, LIST) \ - RUN_ARON_MACRO(Tuple, tuple, TUPLE) \ + RUN_ARON_MACRO(Tuple, tuple, TUPLE)*/ -#define HANDLE_CONTAINER_TYPES_EXCEPT_OBJECT \ +/*#define HANDLE_CONTAINER_TYPES_EXCEPT_OBJECT \ RUN_ARON_MACRO(List, list, LIST) \ RUN_ARON_MACRO(Dict, dict, DICT) \ - RUN_ARON_MACRO(Tuple, tuple, TUPLE) \ + RUN_ARON_MACRO(Tuple, tuple, TUPLE)*/ // All complex types go here -#define HANDLE_COMPLEX_TYPES \ +#define HANDLE_NDARRAY_TYPES \ RUN_ARON_MACRO(EigenMatrix, eigenmatrix, EIGEN_MATRIX) \ + RUN_ARON_MACRO(EigenQuaternion, eigenquaternion, EIGEN_QUATERNION) \ RUN_ARON_MACRO(IVTCByteImage, ivtcbyteimage, IVT_CBYTE_IMAGE) \ RUN_ARON_MACRO(OpenCVMat, opencvmat, OPENCV_MAT) \ - RUN_ARON_MACRO(PCLPointCloud, pclpointcloud, PCL_POINTCLOUD) + RUN_ARON_MACRO(PCLPointCloud, pclpointcloud, PCL_POINTCLOUD) \ + RUN_ARON_MACRO(Position, position, POSITION) \ + RUN_ARON_MACRO(Orientation, orientation, ORIENTATION) \ + RUN_ARON_MACRO(Pose, pose, POSE) -// All primitive types without cpp type. -// The target language type must be similar to the lowercase type +// All enum types (they differ from primitive types since they have a list of accepted values and names) +// TODO: Think about extending enums to StringEnums, FloatEnumns etc. +#define HANDLE_ENUM_TYPES \ + RUN_ARON_MACRO(IntEnum, intenum, INT_ENUM) + +// All primitive types #define HANDLE_PRIMITIVE_TYPES \ RUN_ARON_MACRO(Int, int, INT) \ RUN_ARON_MACRO(Long, long, LONG) \ RUN_ARON_MACRO(Float, float, FLOAT) \ RUN_ARON_MACRO(Double, double, DOUBLE) \ RUN_ARON_MACRO(String, string, STRING) \ - RUN_ARON_MACRO(Bool, bool, BOOL) - -#define HANDLE_PRIMITIVE_TYPES_EXCEPT_STRING \ - RUN_ARON_MACRO(Int, int, INT) \ - RUN_ARON_MACRO(Long, long, LONG) \ - RUN_ARON_MACRO(Float, float, FLOAT) \ - RUN_ARON_MACRO(Double, double, DOUBLE) \ - RUN_ARON_MACRO(Bool, bool, BOOL) - -namespace armarx::aron -{ - template<class T> - static constexpr bool is_aron_primitive_type_v = - std::is_same_v<T, int > || - std::is_same_v<T, long > || - std::is_same_v<T, float > || - std::is_same_v<T, double > || - std::is_same_v<T, bool > || - std::is_same_v<T, std::string>; -} + RUN_ARON_MACRO(Bool, bool, BOOL) \ + RUN_ARON_MACRO(Time, time, TIME) // All combined #define HANDLE_ALL_ARON_TYPES \ HANDLE_CONTAINER_TYPES \ - HANDLE_COMPLEX_TYPES \ + HANDLE_NDARRAY_TYPES \ + HANDLE_ENUM_TYPES \ HANDLE_PRIMITIVE_TYPES /************************************ - * ABSTRACT TYPES ******************* + * Intermediate types, just for hierarchy + * TODO: Remove ***********************************/ -#define HANDLE_CONTAINER_ARON_ABSTRACT_TYPES \ +/*#define HANDLE_CONTAINER_ARON_ABSTRACT_TYPES \ RUN_ARON_MACRO(AronDictSerializerType, arondictserializertype, ARON_DICT_SERIALIZER_TYPE) \ RUN_ARON_MACRO(AronListSerializerType, aronlistserializertype, ARON_LIST_SERIALIZER_TYPE) @@ -151,7 +135,7 @@ namespace armarx::aron #define HANDLE_ALL_ARON_ABSTRACT_TYPES \ HANDLE_CONTAINER_ARON_ABSTRACT_TYPES \ - HANDLE_COMPLEX_ARON_ABSTRACT_TYPES + HANDLE_COMPLEX_ARON_ABSTRACT_TYPES*/ /************************************ * DATA ***************************** @@ -165,17 +149,36 @@ namespace armarx::aron #define HANDLE_COMPLEX_DATA \ RUN_ARON_MACRO(NDArray, ndarray, NDARRAY) +// the lowercase name must be euqal to the cpp name +#define HANDLE_PRIMITIVE_DATA \ + RUN_ARON_MACRO(Int, int, INT) \ + RUN_ARON_MACRO(Long, long, LONG) \ + RUN_ARON_MACRO(Float, float, FLOAT) \ + RUN_ARON_MACRO(Double, double, DOUBLE) \ + RUN_ARON_MACRO(String, string, STRING) \ + RUN_ARON_MACRO(Bool, bool, BOOL) + +// if you only need the "real" primitives +#define HANDLE_PRIMITIVE_DATA_EXCEPT_STRING \ + RUN_ARON_MACRO(Int, int, INT) \ + RUN_ARON_MACRO(Long, long, LONG) \ + RUN_ARON_MACRO(Float, float, FLOAT) \ + RUN_ARON_MACRO(Double, double, DOUBLE) \ + RUN_ARON_MACRO(Bool, bool, BOOL) + // All three combined #define HANDLE_ALL_ARON_DATA \ HANDLE_CONTAINER_DATA \ HANDLE_COMPLEX_DATA \ - HANDLE_PRIMITIVE_TYPES + HANDLE_PRIMITIVE_DATA /************************************ - * MIXED **************************** + * What type corresponds to which data + * (t,t,T,d,d,D) => t in Type, d in Data ***********************************/ #define HANDLE_CONTAINER_CORRESPONDING \ RUN_ARON_MACRO(List, list, LIST, List, list, LIST) \ + RUN_ARON_MACRO(Pair, pair, PAIR, List, list, LIST) \ RUN_ARON_MACRO(Tuple, tuple, TUPLE, List, list, LIST) \ RUN_ARON_MACRO(Object, object, OBJECT, Dict, dict, DICT) \ RUN_ARON_MACRO(Dict, dict, DICT, Dict, dict, DICT) @@ -184,7 +187,13 @@ namespace armarx::aron RUN_ARON_MACRO(EigenMatrix, eigenmatrix, EIGEN_MATRIX, NDArray, ndarray, NDARRAY) \ RUN_ARON_MACRO(IVTCByteImage, ivtcbyteimage, IVT_CBYTE_IMAGE, NDArray, ndarray, NDARRAY) \ RUN_ARON_MACRO(OpenCVMat, opencvmat, OPENCV_MAT, NDArray, ndarray, NDARRAY) \ - RUN_ARON_MACRO(PCLPointCloud, pclpointcloud, PCL_POINTCLOUD, NDArray, ndarray, NDARRAY) + RUN_ARON_MACRO(PCLPointCloud, pclpointcloud, PCL_POINTCLOUD, NDArray, ndarray, NDARRAY) \ + RUN_ARON_MACRO(Position, position, POSITION, NDArray, ndarray, NDARRAY) \ + RUN_ARON_MACRO(Orientation, orientation, ORIENTATION, NDArray, ndarray, NDARRAY) \ + RUN_ARON_MACRO(Pose, pose, POSE, NDArray, ndarray, NDARRAY) + +#define HANDLE_ENUM_CORRESPONDING \ + RUN_ARON_MACRO(IntEnum, intenum, INT_ENUM, Int, int, INT) #define HANDLE_PRIMITIVE_CORRESPONDING \ RUN_ARON_MACRO(Int, int, INT, Int, int, INT) \ @@ -192,14 +201,17 @@ namespace armarx::aron RUN_ARON_MACRO(Float, float, FLOAT, Float, float, FLOAT) \ RUN_ARON_MACRO(Double, double, DOUBLE, Double, double, DOUBLE) \ RUN_ARON_MACRO(String, string, STRING, String, string, STRING) \ - RUN_ARON_MACRO(Bool, bool, BOOL, Bool, bool, BOOL) + RUN_ARON_MACRO(Bool, bool, BOOL, Bool, bool, BOOL) \ + RUN_ARON_MACRO(Time, time, TIME, Long, long, LONG) #define HANDLE_ALL_CORRESPONDING \ HANDLE_CONTAINER_CORRESPONDING \ HANDLE_COMPLEX_CORRESPONDING \ + HANDLE_ENUM_CORRESPONDING \ HANDLE_PRIMITIVE_CORRESPONDING -#define HANDLE_CONTAINER_ARON_TYPE_ARON_ABSTRACT_TYPE_CORRESPONDING \ +// TODO: Remove +/*#define HANDLE_CONTAINER_ARON_TYPE_ARON_ABSTRACT_TYPE_CORRESPONDING \ RUN_ARON_MACRO(List, list, LIST, AronListSerializerType, aronlistserializertype, ARON_LIST_SERIALIZER_TYPE) \ RUN_ARON_MACRO(Tuple, tuple, TUPLE, AronListSerializerType, aronlistserializertype, ARON_LIST_SERIALIZER_TYPE) \ RUN_ARON_MACRO(Object, object, OBJECT, AronDictSerializerType, arondictserializertype, ARON_DICT_SERIALIZER_TYPE) \ @@ -224,15 +236,17 @@ namespace armarx::aron #define HANDLE_ALL_ARON_DATA_ARON_ABSTRACT_TYPE_CORRESPONDING \ HANDLE_CONTAINER_ARON_DATA_ARON_ABSTRACT_TYPE_CORRESPONDING \ - HANDLE_COMPLEX_ARON_DATA_ARON_ABSTRACT_TYPE_CORRESPONDING + HANDLE_COMPLEX_ARON_DATA_ARON_ABSTRACT_TYPE_CORRESPONDING*/ /************************************ - * Related ************************** + * Related data types *************** + * (which on can be converted into what) + * automatically symmetric but not transitive ***********************************/ #define HANDLE_ARON_PRIMITIVE_DATA_RELATED \ RUN_ARON_MACRO(Int, int, INT, Long, long, LONG) \ RUN_ARON_MACRO(Int, int, INT, Float, float, FLOAT) \ RUN_ARON_MACRO(Int, int, INT, Double, double, DOUBLE) \ - RUN_ARON_MACRO(Long, long, LONG, Double, double, DOUBLE) \ RUN_ARON_MACRO(Long, long, LONG, Float, float, FLOAT) \ + RUN_ARON_MACRO(Long, long, LONG, Double, double, DOUBLE) \ RUN_ARON_MACRO(Float, float, FLOAT, Double, double, DOUBLE) diff --git a/source/RobotAPI/libraries/aron/aroncore/Debug.h b/source/RobotAPI/libraries/aron/aroncore/Debug.h new file mode 100644 index 0000000000000000000000000000000000000000..4dfdd115c48a76cc518d3c668dca0123db4db76e --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Debug.h @@ -0,0 +1,83 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <memory> +#include <string> + +// ArmarX +#include <RobotAPI/interface/aron.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> + +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h> + +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.h> + +namespace armarx::aron +{ + class Debug + { + public: + Debug() = delete; + + static std::string AronDataPtrToString(const data::AronDataPtr& data) + { + io::AronDataNlohmannJSONWriter w; + io::Visitor::SetupWriterFromAronDataPtr(w, data); + return w.getResult().dump(2); + } + + static std::string AronDataNavigatorPtrToString(const datanavigator::NavigatorPtr& data) + { + if (data == nullptr) + { + return ""; + } + io::AronDataNlohmannJSONWriter w; + io::Visitor::SetupWriterFromAronDataPtr(w, data); + return w.getResult().dump(2); + } + + static std::string AronTypePtrToString(const type::AronTypePtr& data) + { + io::NlohmannJSONWriter w; + io::Visitor::SetupWriterFromAronTypePtr(w, data); + return w.getResult().dump(2); + } + + static std::string AronTypeNavigatorPtrToString(const typenavigator::NavigatorPtr& data) + { + if (data == nullptr) + { + return ""; + } + io::NlohmannJSONWriter w; + io::Visitor::SetupWriterFromAronTypePtr(w, data); + return w.getResult().dump(2); + } + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/AronDescriptor.h b/source/RobotAPI/libraries/aron/aroncore/Descriptor.h similarity index 57% rename from source/RobotAPI/libraries/aron/aroncore/AronDescriptor.h rename to source/RobotAPI/libraries/aron/aroncore/Descriptor.h index 04b547c2516e12f398376a02c1370f8bbe91cd0e..0bf66dca733cdc835e5d385c899bb68382ad8fa0 100644 --- a/source/RobotAPI/libraries/aron/aroncore/AronDescriptor.h +++ b/source/RobotAPI/libraries/aron/aroncore/Descriptor.h @@ -31,53 +31,60 @@ #include <string> // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> - -namespace armarx +namespace armarx::aron::type { - namespace aron + enum Descriptor { - enum AronTypeDescriptor - { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - eAron##upperType##Type, + e##upperType, - HANDLE_ALL_ARON_TYPES + HANDLE_ALL_ARON_TYPES #undef RUN_ARON_MACRO - eAronUnknownType = -1 - }; + eUnknown = -1 + }; - enum AronDataDescriptor - { + const std::map<Descriptor, std::string> _descriptorstring = + { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - eAron##upperType, + { e##upperType, "armarx::aron::type::Descriptor::e" + std::string(#upperType) }, - HANDLE_ALL_ARON_DATA + HANDLE_ALL_ARON_TYPES #undef RUN_ARON_MACRO - eAronUnknown = -1 - }; + {eUnknown, "armarx::aron::type::Descriptor::eUnknown"} + }; + + std::string DESCRIPTOR_TO_STRING(const Descriptor d) + { + return _descriptorstring.at(d); + } +} - const std::map<AronTypeDescriptor, std::string> AronTypeDescriptorToString = - { +namespace armarx::aron::data +{ + enum Descriptor + { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - { eAron##upperType##Type, "eAron" + std::string(#upperType) + "Type" }, + e##upperType, - HANDLE_ALL_ARON_TYPES + HANDLE_ALL_ARON_DATA #undef RUN_ARON_MACRO - {eAronUnknownType, "eAronUnknownType"} - }; + eUnknown = -1 + }; - const std::map<AronDataDescriptor, std::string> AronDataDescriptorToString = - { + const std::map<Descriptor, std::string> _descriptorstring = + { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - { eAron##upperType, "eAron" + std::string(#upperType) }, + { e##upperType, "armarx::aron::data::Descriptor::e" + std::string(#upperType) }, - HANDLE_ALL_ARON_DATA + HANDLE_ALL_ARON_DATA #undef RUN_ARON_MACRO - {eAronUnknown, "eAronUnknown"} - }; + {eUnknown, "armarx::aron::data::Descriptor::eUnknown"} + }; + + std::string DESCRIPTOR_TO_STRING(const Descriptor d) + { + return _descriptorstring.at(d); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/Exception.h b/source/RobotAPI/libraries/aron/aroncore/Exception.h new file mode 100644 index 0000000000000000000000000000000000000000..5983bf829ee1a403638a893388fa325c51b192eb --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Exception.h @@ -0,0 +1,184 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL + +// ArmarX +#include <ArmarXCore/core/exceptions/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/Path.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> + +namespace armarx +{ + namespace aron + { + namespace exception + { + class AronException : + public armarx::LocalException + { + public: + AronException() = delete; + AronException(const std::string& caller, const std::string& method, const std::string& reason) : + LocalException(caller + "::" + method + ": " + reason + ".") + { + + } + + AronException(const std::string& caller, const std::string& method, const std::string& reason, const Path& path) : + LocalException(caller + "::" + method + ": " + reason + ". The path was: " + path.toString()) + { + + } + }; + + class NotImplementedYetException : + public AronException + { + public: + NotImplementedYetException() = delete; + NotImplementedYetException(const std::string& caller, const std::string& method) : + AronException(caller, method, "This method is not yet implemented!") + { + + } + }; + + class AronNotValidException : + public AronException + { + public: + AronNotValidException() = delete; + AronNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const data::AronDataPtr& data) : + AronException(caller, method, reason + ". The ice_id of the data was: " + data->ice_id()) + { + + } + + AronNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const data::AronDataPtr& data, const Path& path) : + AronException(caller, method, reason + ". The ice_id of the data was: " + data->ice_id(), path) + { + + } + + AronNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const type::AronTypePtr& type) : + AronException(caller, method, reason + ". The ice_id of the type was: " + type->ice_id()) + { + + } + + AronNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const type::AronTypePtr& type, const Path& path) : + AronException(caller, method, reason + ". The ice_id of the type was: " + type->ice_id(), path) + { + + } + }; + + class DescriptorNotValidException : + public AronException + { + public: + DescriptorNotValidException() = delete; + DescriptorNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const type::Descriptor& type) : + AronException(caller, method, reason + ". The name of the type-enum was: " + type::DESCRIPTOR_TO_STRING(type)) + { + + } + + DescriptorNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const type::Descriptor& type, const Path& path) : + AronException(caller, method, reason + ". The name of the type-enum was: " + type::DESCRIPTOR_TO_STRING(type), path) + { + + } + + DescriptorNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const data::Descriptor& data) : + AronException(caller, method, reason + ". The name of the data-enum was: " + data::DESCRIPTOR_TO_STRING(data)) + { + + } + + DescriptorNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const data::Descriptor& data, const Path& path) : + AronException(caller, method, reason + ". The name of the data-enum was: " + data::DESCRIPTOR_TO_STRING(data), path) + { + + } + }; + + class StringNotValidException : + public AronException + { + public: + StringNotValidException() = delete; + StringNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const std::string& input) : + AronException(caller, method, reason + ". Got: " + input) + { + + } + + StringNotValidException(const std::string& caller, const std::string& method, const std::string& reason, const std::string& input, const Path& path) : + AronException(caller, method, reason + ". Got: " + input, path) + { + + } + }; + + class IndexNotValidException : + public AronException + { + public: + IndexNotValidException() = delete; + IndexNotValidException(const std::string& caller, const std::string& method, const std::string& reason, int real, int expected) : + AronException(caller, method, reason + ". The requested index is: " + std::to_string(real) + ". The maximum index was: " + std::to_string(expected)) + { + + } + + IndexNotValidException(const std::string& caller, const std::string& method, const std::string& reason, int real, int expected, const Path& path) : + AronException(caller, method, reason + ". The requested index is: " + std::to_string(real) + ". The maximum index was: " + std::to_string(expected), path) + { + + } + }; + + class SizeNotValidException : + public AronException + { + public: + SizeNotValidException() = delete; + SizeNotValidException(const std::string& caller, const std::string& method, const std::string& reason, int real, int expected) : + AronException(caller, method, reason + ". The measured size is: " + std::to_string(real) + ". The expected size was: " + std::to_string(expected)) + { + + } + + SizeNotValidException(const std::string& caller, const std::string& method, const std::string& reason, int real, int expected, const Path& path) : + AronException(caller, method, reason + ". The measured size is: " + std::to_string(real) + ". The expected size was: " + std::to_string(expected), path) + { + + } + }; + } + } +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h b/source/RobotAPI/libraries/aron/aroncore/Factory.h similarity index 67% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h rename to source/RobotAPI/libraries/aron/aroncore/Factory.h index 0dc901f719822a1191fc3203f00285c490be1946..121e42cbeed07b5fcc90519e8977d1f1d238771b 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h +++ b/source/RobotAPI/libraries/aron/aroncore/Factory.h @@ -25,12 +25,24 @@ // STD/STL #include <memory> +#include <string> +#include <unordered_map> // ArmarX #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/Path.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +namespace armarx::aron +{ + template <typename Input, typename Output> + class Factory + { + public: + Factory() = default; + + virtual Output create(const Input&, const Path&) const = 0; + virtual Output createSpecific(const Input&, const Path&) const = 0; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/Path.cpp b/source/RobotAPI/libraries/aron/aroncore/Path.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f28913830604a34b10f7ec635e6a734ba7d75a7a --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Path.cpp @@ -0,0 +1,191 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "Path.h" + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/Exception.h> + +namespace armarx::aron +{ + Path::Path() : + rootIdentifier("\\"), + delimeter("->") + { + + } + + Path::Path(const std::vector<std::string>& p) : + path(p) + { + + } + + Path::Path(const std::string& s, const std::string& d): + rootIdentifier(s), + delimeter(d) + { + + } + + Path::Path(const std::string& s, const std::string& d, const std::vector<std::string>& p) : + rootIdentifier(s), + delimeter(d), + path(p) + { + + } + + Path::Path(const Path& p) : + rootIdentifier(p.getRootIdentifier()), + delimeter(p.getDelimeter()), + path(p.getPath()) + { + + } + + Path::Path(const Path& p, const std::string& s) : + Path(p) + { + append(s); + } + + Path::Path(const Path& p, const std::string& s, const std::string& s2) : + Path(p) + { + append(s); + append(s2); + } + + Path::Path(const Path& pa, const std::vector<std::string>& p) : + Path(pa) + { + for (const std::string& s : p) + { + append(s); + } + } + + void Path::setRootIdentifier(const std::string& s) + { + rootIdentifier = s; + } + + std::string Path::getRootIdentifier() const + { + return rootIdentifier; + } + + void Path::setDelimeter(const std::string& d) + { + delimeter = d; + } + + std::string Path::getDelimeter() const + { + return delimeter; + } + + void Path::append(const std::string& str) + { + path.push_back(str); + } + + std::vector<std::string> Path::getPath() const + { + return path; + } + + std::string Path::getLastElement() const + { + if (!hasElement()) + { + throw exception::AronException("AronNavigatorPath", "getLastElement", "Try to access last element of empty vector."); + } + return path.back(); + } + + std::string Path::getFirstElement() const + { + if (!hasElement()) + { + throw exception::AronException("AronNavigatorPath", "getFirstElement", "Try to access last element of empty vector."); + } + return path[0]; + } + + bool Path::hasElement() const + { + return path.size() > 0; + } + + size_t Path::size() const + { + return path.size(); + } + + std::string Path::toString() const + { + std::stringstream ss; + ss << rootIdentifier; + for (const std::string& s : path) + { + ss << delimeter << s; + } + return ss.str(); + } + + Path Path::withDetachedLastElement() const + { + std::vector<std::string> p = path; + p.pop_back(); + return Path(rootIdentifier, delimeter, p); + } + + Path Path::withDetachedFirstElement() const + { + std::vector<std::string> p = path; + p.erase(p.begin()); + return Path(rootIdentifier, delimeter, p); + } + + Path Path::getWithoutPrefix(const Path& pref) const + { + unsigned int firstWithoutMatch = 0; + for (const std::string& el : pref.getPath()) + { + if (path.size() <= firstWithoutMatch || el != path[firstWithoutMatch]) + { + break; + } + else + { + firstWithoutMatch++; + } + } + std::vector<std::string> elementsWithoutPrefix(path.begin() + firstWithoutMatch, path.end()); + return Path(rootIdentifier, delimeter, elementsWithoutPrefix); + + } +} diff --git a/source/RobotAPI/libraries/aron/aroncore/Path.h b/source/RobotAPI/libraries/aron/aroncore/Path.h new file mode 100644 index 0000000000000000000000000000000000000000..660532dbef004703acbbb47178dd807838d7035f --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Path.h @@ -0,0 +1,74 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include<vector> +#include<string> + +// ArmarX +#include <RobotAPI/interface/aron.h> + +namespace armarx::aron +{ + class Path + { + public: + Path(); + Path(const std::vector<std::string>&); + Path(const std::string&, const std::string&); + Path(const std::string&, const std::string&, const std::vector<std::string>&); + Path(const Path&); + Path(const Path&, const std::string&); + Path(const Path&, const std::string&, const std::string&); + Path(const Path&, const std::vector<std::string>&); + Path& operator=(const armarx::aron::Path&) = default; + + std::vector<std::string> getPath() const; + std::string getFirstElement() const; + std::string getLastElement() const; + bool hasElement() const; + size_t size() const; + + void setRootIdentifier(const std::string&); + std::string getRootIdentifier() const; + + void setDelimeter(const std::string&); + std::string getDelimeter() const; + + std::string toString() const; + + Path withDetachedFirstElement() const; + Path withDetachedLastElement() const; + Path getWithoutPrefix(const Path&) const; + + private: + void append(const std::string&); + + private: + std::string rootIdentifier; + std::string delimeter; + std::vector<std::string> path; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/Randomizer.h b/source/RobotAPI/libraries/aron/aroncore/Randomizer.h new file mode 100644 index 0000000000000000000000000000000000000000..b185ff0b93494d008eeb618ada2a6aac8d9547ea --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Randomizer.h @@ -0,0 +1,346 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <memory> +#include <numeric> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> + +namespace armarx::aron +{ + class AronRandomizer + { + public: + AronRandomizer() + { + initialize_random(); + }; + + typenavigator::AronTypeNavigatorPtr generateRandomType(bool mustBeObject = false) const + { + type::Descriptor nextType = eAronObjectType; + if (!mustBeObject) + { + std::vector<type::Descriptor> descriptors = + { +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + eAron##upperType##Type, + + HANDLE_ALL_ARON_TYPES +#undef RUN_ARON_MACRO + }; + + int randomType = generateRandom(descriptors.size(), 0); + nextType = descriptors[randomType]; + } + + switch (nextType) + { + case eAronObjectType: + { + typenavigator::AronObjectTypeNavigatorPtr t = typenavigator::AronObjectTypeNavigatorPtr(new typenavigator::AronObjectTypeNavigator(Path())); + std::string objectName = generateRandomWord(); + t->setObjectName(objectName); + + std::vector<std::string> usedNames({objectName}); + int members = generateRandom(4, 2); + std::set<std::string> usedKeys; + for (int i = 0; i < members; ++i) + { + std::string key = generateRandomWord(usedKeys); + usedKeys.insert(key); + + typenavigator::AronTypeNavigatorPtr m = generateRandomType(false); + t->addAcceptedType(key, m); + } + return t; + } + case eAronDictType: + { + typenavigator::AronDictTypeNavigatorPtr t = typenavigator::AronDictTypeNavigatorPtr(new typenavigator::AronDictTypeNavigator(Path())); + typenavigator::AronTypeNavigatorPtr a = generateRandomType(false); + + t->setAcceptedType(a); + return t; + } + case eAronTupleType: + { + typenavigator::AronTupleTypeNavigatorPtr t = typenavigator::AronTupleTypeNavigatorPtr(new typenavigator::AronTupleTypeNavigator(Path())); + + int members = generateRandom(4, 2); + for (int i = 0; i < members; ++i) + { + typenavigator::AronTypeNavigatorPtr m = generateRandomType(false); + t->addAcceptedType(m); + } + return t; + } + case eAronListType: + { + typenavigator::AronListTypeNavigatorPtr t = typenavigator::AronListTypeNavigatorPtr(new typenavigator::AronListTypeNavigator(Path())); + typenavigator::AronTypeNavigatorPtr a = generateRandomType(false); + + t->setAcceptedType(a); + return t; + } +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ +case eAron##upperType##Type: + + HANDLE_NDARRAY_TYPES +#undef RUN_ARON_MACRO + +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ +case eAron##upperType##Type: \ +{ \ + typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigatorPtr(new typenavigator::Aron##upperType##TypeNavigator(Path())); \ + return t; \ +} + + HANDLE_PRIMITIVE_TYPES +#undef RUN_ARON_MACRO + default: + { + throw armarx::aron::exception::DescriptorNotValidException("AronTest", "generateRandomType", "No valid type found!", nextType); + } + } + } + + datanavigator::AronDataNavigatorPtr generateAronDataFromType(const typenavigator::AronTypeNavigatorPtr& type) const + { + const type::Descriptor desc = type->getDescriptor(); + switch (desc) + { + // In an object, we do not want to edit the keys. + case eAronObjectType: + { + typenavigator::AronObjectTypeNavigatorPtr t = typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck(type); + datanavigator::AronDictDataNavigatorPtr d = datanavigator::AronDictDataNavigatorPtr(new datanavigator::AronDictDataNavigator()); + for (const auto& [k, tt] : t->getAcceptedTypes()) + { + d->addElement(k, generateAronDataFromType(tt)); + } + return d; + } + + // here all totally random + case eAronDictType: + { + typenavigator::AronDictTypeNavigatorPtr t = typenavigator::AronDictTypeNavigator::DynamicCastAndCheck(type); + return datanavigator::AronDataNavigatorPtr(new datanavigator::AronDictDataNavigator()); + } + +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ +case eAron##upperType##Type: \ +{ \ + typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ + return datanavigator::AronDataNavigatorPtr(new datanavigator::AronListDataNavigator()); \ +} + + HANDLE_LIST_SERIALIZER_TYPES +#undef RUN_ARON_MACRO + +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ +case eAron##upperType##Type: \ +{ \ + typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ + return datanavigator::AronDataNavigatorPtr(new datanavigator::AronNDArrayDataNavigator()); \ +} + + HANDLE_NDARRAY_TYPES +#undef RUN_ARON_MACRO + +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ +case eAron##upperType##Type: \ +{ \ + typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ + return datanavigator::AronDataNavigatorPtr(new datanavigator::Aron##upperType##DataNavigator()); \ +} + + HANDLE_PRIMITIVE_TYPES +#undef RUN_ARON_MACRO + default: + { + throw armarx::aron::exception::DescriptorNotValidException("AronTest", "generateAronDataFromType", "No valid type found!", desc); + } + } + } + + + void initializeRandomly(datanavigator::AronDictDataNavigatorPtr& data, const typenavigator::AronObjectTypeNavigatorPtr& type) const + { + for (auto& [key, nextData] : data->getElements()) + { + initializeRandomly(nextData, type->getAcceptedTypes()[key]); + } + } + + void initializeRandomly(datanavigator::AronDictDataNavigatorPtr& data, const typenavigator::AronDictTypeNavigatorPtr& type) const + { + data->clear(); + int numElements = generateRandom(5, 1); + std::set<std::string> usedKeys; + for (int i = 0; i < numElements; ++i) + { + std::string key = generateRandomWord(usedKeys); + usedKeys.insert(key); + datanavigator::AronDataNavigatorPtr newData = generateAronDataFromType(type->getAcceptedType()); + initializeRandomly(newData, type->getAcceptedType()); + data->addElement(key, newData); + } + } + + void initializeRandomly(datanavigator::AronListDataNavigatorPtr& data, const typenavigator::AronTupleTypeNavigatorPtr& type) const + { + unsigned int i = 0; + for (auto& nextData : data->getElements()) + { + initializeRandomly(nextData, type->getAcceptedTypes()[i++]); + } + } + + void initializeRandomly(datanavigator::AronListDataNavigatorPtr& data, const typenavigator::AronListTypeNavigatorPtr& type) const + { + data->clear(); + int numElements = generateRandom(5, 1); + for (int i = 0; i < numElements; ++i) + { + datanavigator::AronDataNavigatorPtr newData = generateAronDataFromType(type->getAcceptedType()); + initializeRandomly(newData, type->getAcceptedType()); + data->addElement(newData); + } + } + + void initializeRandomly(datanavigator::AronNDArrayDataNavigatorPtr& data, const typenavigator::AronNDArraySerializerTypeNavigatorPtr& type) const + { + std::vector<int> dims = data->getDimensions(); + int bytes = std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()); + std::vector<unsigned char> blob = generateRandomBlob(bytes); + data->setData(bytes, blob.data()); + } + + void initializeRandomly(datanavigator::AronIntDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const + { + data->setValue(generateRandom(1000, -1000)); + } + + void initializeRandomly(datanavigator::AronLongDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const + { + data->setValue(generateRandom(1000, -1000)); + } + + void initializeRandomly(datanavigator::AronFloatDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const + { + data->setValue(generateRandom(1000, -1000)); + } + + void initializeRandomly(datanavigator::AronDoubleDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const + { + data->setValue(generateRandom(1000, -1000)); + } + + void initializeRandomly(datanavigator::AronBoolDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const + { + data->setValue(generateRandom(1, 0)); + } + + void initializeRandomly(datanavigator::AronStringDataNavigatorPtr& data, const typenavigator::AronPrimitiveTypeNavigatorPtr& type) const + { + data->setValue(generateRandomWord()); + } + + void initializeRandomly(datanavigator::AronDataNavigatorPtr& data, const typenavigator::AronTypeNavigatorPtr& type) const + { + // Containers + type::Descriptor desc = type->getDescriptor(); + switch (desc) + { + +#define RUN_ARON_MACRO(upperType, lowerType, capsType, upperData, lowerData, capsData) \ +case eAron##upperType##Type: \ +{ \ + typenavigator::Aron##upperType##TypeNavigatorPtr t = typenavigator::Aron##upperType##TypeNavigator::DynamicCastAndCheck(type); \ + datanavigator::Aron##upperData##DataNavigatorPtr d = datanavigator::Aron##upperData##DataNavigator::DynamicCastAndCheck(data); \ + initializeRandomly(d, t); \ + break; \ +} + + HANDLE_ALL_CORRESPONDING +#undef RUN_ARON_MACRO + + default: + { + throw armarx::aron::exception::DescriptorNotValidException("AronTest", "initializeRandomly", "No valid type found!", desc); + } + } + } + + int generateRandom(int max, int min) const + { + max += 1; + int random = (std::rand() % (max - min)) + min; + return random; + } + + std::string generateRandomWord(const std::set<std::string>& usedKeys = {}) const + { + std::vector<string> words = + { + "Lorem", "ipsum", "dolor", "sit", "amet", "consetetur", "sadipscing", "elitr" + "sed", "diam", "nonumy", "eirmod", "tempor", "invidunt", "ut", "labore", "et" + "dolore", "magna", "aliquyam", "eratsed" + }; + + int i = generateRandom(words.size() - 1, 0); + std::string key = words[i]; + + while (usedKeys.count(key) > 0) + { + key = generateRandomWord(usedKeys); + } + + return key; + } + + std::vector<unsigned char> generateRandomBlob(unsigned int size) const + { + 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; + } + + protected: + void initialize_random() const + { + std::srand(std::time(nullptr)); + } + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/Resolver.cpp b/source/RobotAPI/libraries/aron/aroncore/Resolver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..58c699dd435eb69f9e70855329d70c5a812ea4e2 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Resolver.cpp @@ -0,0 +1,150 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Simox +#include <SimoxUtility/meta/type_name.h> + +// Header +#include "Resolver.h" + +namespace armarx::aron +{ + type::Descriptor AronResolver::GetDescriptor(const type::AronTypePtr& a) + { +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + { \ + type::Aron##upperType##Ptr aron = type::Aron##upperType##Ptr::dynamicCast(a); \ + if(aron) \ + { \ + return type::Descriptor::e##upperType; \ + } \ + } + HANDLE_ALL_ARON_TYPES +#undef RUN_ARON_MACRO + throw exception::AronNotValidException("Resolver", "GetTypeForAronAbstractType", "Could not cast AronType to a valid type", a); + } + + + + data::Descriptor AronResolver::GetDescriptor(const data::AronDataPtr& a) + { +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + { \ + data::Aron##upperType##Ptr aron = data::Aron##upperType##Ptr::dynamicCast(a); \ + if(aron) \ + { \ + return data::Descriptor::e##upperType; \ + } \ + } + HANDLE_ALL_ARON_DATA +#undef RUN_ARON_MACRO + throw exception::AronNotValidException("Resolver", "GetTypeForAronData", "Could not cast AronData to a valid type", a); + } + + + + bool AronResolver::Correspond(const type::Descriptor& t, const data::Descriptor& d) + { +#define RUN_ARON_MACRO(typeUpperType, typeLowerType, typeCapsType, dataUpperType, dataLowerType, dataCapsType) \ + if(t == type::Descriptor::e##typeUpperType && d == data::Descriptor::e##dataUpperType) \ + { \ + return true; \ + } + + HANDLE_ALL_CORRESPONDING +#undef RUN_ARON_MACRO + return false; + } + + data::Descriptor AronResolver::GetCorresponding(const type::Descriptor& d) + { +#define RUN_ARON_MACRO(typeUpperType, typeLowerType, typeCapsType, dataUpperType, dataLowerType, dataCapsType) \ + { \ + if(d == type::Descriptor::e##typeUpperType) \ + { \ + return data::Descriptor::e##dataUpperType; \ + } \ + } + HANDLE_ALL_CORRESPONDING +#undef RUN_ARON_MACRO + return data::Descriptor::eUnknown; + } + + bool AronResolver::AreRelated(const data::Descriptor& d, const data::Descriptor& d2) + { + if (d == d2) + { + return true; + } +#define RUN_ARON_MACRO(data1UpperType, data1LowerType, data1CapsType, data2UpperType, data2LowerType, data2CapsType) \ + if( \ + (d == data::Descriptor::e##data1UpperType && d2 == data::Descriptor::e##data2UpperType) || \ + (d2 == data::Descriptor::e##data1UpperType && d == data::Descriptor::e##data2UpperType) \ + ) \ + { \ + return true; \ + } + + HANDLE_ARON_PRIMITIVE_DATA_RELATED +#undef RUN_ARON_MACRO + return false; + } + + bool AronResolver::AreRelated(const type::Descriptor& t, const type::Descriptor& t2) + { + if (t == t2) + { + return true; + } +#define RUN_ARON_MACRO(type1UpperType, type1LowerType, type1CapsType, type2UpperType, type2LowerType, type2CapsType) \ + if( \ + (t == type::Descriptor::e##type1UpperType && t2 == type::Descriptor::e##type2UpperType) || \ + (t2 == type::Descriptor::e##type1UpperType && t == type::Descriptor::e##type2UpperType) \ + ) \ + { \ + return true; \ + } + + HANDLE_ARON_PRIMITIVE_DATA_RELATED +#undef RUN_ARON_MACRO + return false; + } + + data::Descriptor AronResolver::GetFirstIfRelated(const data::Descriptor& d, const data::Descriptor& d2) + { + if (AreRelated(d, d2)) + { + return d; + } + return d2; + } + + type::Descriptor AronResolver::GetFirstIfRelated(const type::Descriptor& t, const type::Descriptor& t2) + { + if (AreRelated(t, t2)) + { + return t; + } + return t2; + } +} diff --git a/source/RobotAPI/libraries/aron/aroncore/Resolver.h b/source/RobotAPI/libraries/aron/aroncore/Resolver.h new file mode 100644 index 0000000000000000000000000000000000000000..058184988352876e7eadf37ab871c1a622ba291e --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/Resolver.h @@ -0,0 +1,59 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <memory> +#include <typeindex> +#include <typeinfo> + +// ArmarX +#include <RobotAPI/interface/aron.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> + +namespace armarx::aron +{ + class AronResolver + { + private: // disallow creating this object. static use only + AronResolver() = delete; + + public: + static type::Descriptor GetDescriptor(const type::AronTypePtr&); + + static data::Descriptor GetDescriptor(const data::AronDataPtr&); + + static bool Correspond(const type::Descriptor&, const data::Descriptor&); + + static data::Descriptor GetCorresponding(const type::Descriptor&); + + static bool AreRelated(const data::Descriptor&, const data::Descriptor&); + static bool AreRelated(const type::Descriptor&, const type::Descriptor&); + + static data::Descriptor GetFirstIfRelated(const data::Descriptor&, const data::Descriptor&); + static type::Descriptor GetFirstIfRelated(const type::Descriptor&, const type::Descriptor&); + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/AronGenerateTypeInfo.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/GenerateTypeInfo.h similarity index 89% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/AronGenerateTypeInfo.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/GenerateTypeInfo.h index 43d30adb2c0d48644739a89a7e419267ad954bfe..48f2245d444e1a882df43efd3498f9163e02750e 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/AronGenerateTypeInfo.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/GenerateTypeInfo.h @@ -28,7 +28,7 @@ #include <string> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> namespace armarx { @@ -44,7 +44,7 @@ namespace armarx public: std::string typeName; std::string definedIn; - typenavigator::AronObjectTypeNavigatorPtr correspondingObjectType; + typenavigator::ObjectNavigatorPtr correspondingObjectType; std::map<std::string, AronGenerateTypeInfoPtr> nestedObjects; }; } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/AronIncludeInfo.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/IncludeInfo.h similarity index 100% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/AronIncludeInfo.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/IncludeInfo.h diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/AronReaderInfo.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/ReaderInfo.h similarity index 100% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/AronReaderInfo.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/ReaderInfo.h diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/AronWriterInfo.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/WriterInfo.h similarity index 100% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/AronWriterInfo.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/WriterInfo.h diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronCodeWriter.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/CodeWriter.h similarity index 81% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronCodeWriter.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/CodeWriter.h index aeb41664b8876eaddd1b1ab223c8abffb3f76a71..eb2eedf738a55c8bbb3c67f70a01c99d3b26ce16 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronCodeWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/CodeWriter.h @@ -33,14 +33,14 @@ // ArmarX #include <ArmarXCore/libraries/cppgen/MetaClass.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/AronWriterInfo.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/AronReaderInfo.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/AronGenerateTypeInfo.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/WriterInfo.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/ReaderInfo.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/GenerateTypeInfo.h> namespace armarx { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronSerializerFactory.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/SerializerFactory.h similarity index 82% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronSerializerFactory.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/SerializerFactory.h index c595c4e7a8d09058b01f2fd9731f496ce04a8a27..87deb0a291f952e7376b53bdfdeb2ea63e072afe 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronSerializerFactory.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/SerializerFactory.h @@ -29,14 +29,12 @@ #include <unordered_map> // Base Class -#include <RobotAPI/libraries/aron/aroncore/AronFactory.h> +#include <RobotAPI/libraries/aron/aroncore/Factory.h> // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/AronPath.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/Path.h> namespace armarx { @@ -53,8 +51,8 @@ namespace armarx public: AronSerializerFactory() = default; - virtual Output create(const Input&, const AronPath&) const = 0; - virtual Output createSpecific(const Input&, const AronPath&) const = 0; + virtual Output create(const Input&, const Path&) const = 0; + virtual Output createSpecific(const Input&, const Path&) const = 0; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/AronCppClass.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/AronCppClass.h similarity index 85% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/AronCppClass.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/AronCppClass.h index 61d72f288131240ebd45103cf39b72939128726f..70c7b9ea6f4dfb3ff9ba869ebb0df45b9b63d0e7 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/AronCppClass.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/AronCppClass.h @@ -28,12 +28,12 @@ #include <string> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReader.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriter.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/Reader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/DataWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/Writer.h> namespace armarx diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/AronCppWriter.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/Writer.cpp similarity index 94% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/AronCppWriter.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/Writer.cpp index c22a9cd656de7f76538238e32679e80fdb8e59e9..49d109432ad6fbd4e513d71b0477609dcc2f74eb 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/AronCppWriter.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/Writer.cpp @@ -26,10 +26,9 @@ #include <SimoxUtility/algorithm/string.h> // Header -#include "AronCppWriter.h" +#include "Writer.h" // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> namespace armarx { @@ -55,7 +54,7 @@ namespace armarx toAron->methodName = "toAron"; toAron->returnType = "armarx::aron::datanavigator::AronDictDataNavigatorPtr"; toAron->writerClassType = "armarx::aron::io::AronDataNavigatorWriter"; - toAron->include = "<RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h>"; + toAron->include = "<RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h>"; dataWriters.push_back(toAron); } } @@ -68,7 +67,7 @@ namespace armarx fromAron->methodName = "fromAron"; fromAron->argumentType = "armarx::aron::datanavigator::AronDictDataNavigatorPtr"; fromAron->readerClassType = "armarx::aron::io::AronDataNavigatorReader"; - fromAron->include = "<RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h>"; + fromAron->include = "<RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/AronDataNavigatorReader.h>"; dataReaders.push_back(fromAron); } { @@ -87,7 +86,7 @@ namespace armarx toAronType->methodName = "toInitialAronType"; toAronType->returnType = "armarx::aron::typenavigator::AronObjectTypeNavigatorPtr"; toAronType->writerClassType = "armarx::aron::io::AronTypeNavigatorWriter"; - toAronType->include = "<RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h>"; + toAronType->include = "<RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.h>"; initialTypeWriters.push_back(toAronType); // The toAron Serializer is visible by default @@ -105,7 +104,7 @@ namespace armarx // Convert to Object type and create class object if (publicGenerateObjectType->correspondingObjectType == nullptr) { - throw exception::AronException("AronTypeClassCppWriter", "generateTypeClasses", "An received public type is null. Abort due to error!"); + throw exception::AronException("ClassCppWriter", "generateTypeClasses", "An received public type is null. Abort due to error!"); } cppSerializer::AronObjectTypeCppSerializerPtr objectSerializer = cppSerializer::AronObjectTypeCppSerializerPtr(new cppSerializer::AronObjectTypeCppSerializer(publicGenerateObjectType->correspondingObjectType)); @@ -270,7 +269,7 @@ namespace armarx } } - CppClassPtr AronTypeClassCppWriter::setupCppClassFromObjectType(const typenavigator::AronObjectTypeNavigatorPtr& o) const + CppClassPtr AronTypeClassCppWriter::setupCppClassFromObjectType(const typenavigator::ObjectNavigatorPtr& o) const { cppSerializer::AronObjectTypeCppSerializerPtr objectSerializer = cppSerializer::AronObjectTypeCppSerializerPtr(new cppSerializer::AronObjectTypeCppSerializer(o)); @@ -278,7 +277,7 @@ namespace armarx std::vector<std::string> split = simox::alg::split(cppTypename, "::"); if (split.size() < 1) { - throw exception::AronException("AronTypeClassCppWriter", "setupCppClassFromObjectType", "The cpp name of an inner type was empty. Please check the type definition file if all object names are set correctly."); + throw exception::AronException("ClassCppWriter", "setupCppClassFromObjectType", "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); diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/AronCppWriter.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/Writer.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/AronCppWriter.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/Writer.h index 227392d597aaa068444d4546adf6f73f4ce26351..b6034755c0e8227f746a126a1819d15ed25c6f9e 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/AronCppWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/Writer.h @@ -30,14 +30,14 @@ #include <vector> // Parent class -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronCodeWriter.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/CodeWriter.h> // ArmarX #include <ArmarXCore/libraries/cppgen/CppMethod.h> #include <ArmarXCore/libraries/cppgen/CppClass.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronAllCppSerializers.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/AllSerializers.h> namespace armarx { @@ -66,7 +66,7 @@ namespace armarx private: void generateInnerTypeClasses(CppClassPtr& classToAdd, const std::map<std::string, AronGenerateTypeInfoPtr>& localGenerateTypes); - CppClassPtr setupCppClassFromObjectType(const typenavigator::AronObjectTypeNavigatorPtr&) const; + CppClassPtr setupCppClassFromObjectType(const typenavigator::ObjectNavigatorPtr&) const; private: }; diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/AllSerializers.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/AllSerializers.h new file mode 100644 index 0000000000000000000000000000000000000000..14f4f3f9e77e74dccf46fbed56b0720490ceb79a --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/AllSerializers.h @@ -0,0 +1,9 @@ +#pragma once + +// This file is generated! + +#include "serializer/Serializer.h" +#include "serializer/SerializerFactory.h" +#include "serializer/container.h" +#include "serializer/ndarray.h" +#include "serializer/primitive.h" diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.cpp similarity index 98% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.cpp index a64a9a0a962bf587782b552f1fcd6e2615bcab2b..c060265e924d4fb89f72ce2e7e0aca9def2ce438 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.cpp @@ -24,10 +24,10 @@ // STD/STL // Header -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/SerializerFactory.h> namespace armarx { @@ -103,12 +103,12 @@ namespace armarx return unescaped_accessor; } - std::string AronTypeCppSerializer::ExtractCppTypenamesFromNavigator(const typenavigator::AronTypeNavigatorPtr& n) + std::string AronTypeCppSerializer::ExtractCppTypenamesFromNavigator(const typenavigator::NavigatorPtr& n) { AronTypeCppSerializerPtr cpp = AronTypeCppSerializer::FromAronTypeNaviagtorPtr(n); return cpp->getCppTypename(); } - std::vector<std::string> AronTypeCppSerializer::ExtractCppTypenamesFromList(const std::vector<typenavigator::AronTypeNavigatorPtr>& n) + std::vector<std::string> AronTypeCppSerializer::ExtractCppTypenamesFromList(const std::vector<typenavigator::NavigatorPtr>& n) { std::vector<std::string> ret; for (const auto& typenav : n) @@ -118,7 +118,7 @@ namespace armarx return ret; } - AronTypeCppSerializerPtr AronTypeCppSerializer::FromAronTypeNaviagtorPtr(const typenavigator::AronTypeNavigatorPtr& n) + AronTypeCppSerializerPtr AronTypeCppSerializer::FromAronTypeNaviagtorPtr(const typenavigator::NavigatorPtr& n) { return FACTORY->create(n, n->getPath()); } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h similarity index 94% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h index 51bab528dacaf7e873dfe795c510540886412a48..37f9934980c499d965bbc9cbcb59e5f3af1f5d32 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h @@ -41,8 +41,8 @@ #include <ArmarXCore/libraries/cppgen/CppClass.h> #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> namespace armarx { @@ -119,10 +119,10 @@ namespace armarx static std::string EscapeAccessor(const std::string&); static std::string UnescapeAccessor(const std::string&); - static std::string ExtractCppTypenamesFromNavigator(const typenavigator::AronTypeNavigatorPtr&); - static std::vector<std::string> ExtractCppTypenamesFromList(const std::vector<typenavigator::AronTypeNavigatorPtr>&); + static std::string ExtractCppTypenamesFromNavigator(const typenavigator::NavigatorPtr&); + static std::vector<std::string> ExtractCppTypenamesFromList(const std::vector<typenavigator::NavigatorPtr>&); - static AronTypeCppSerializerPtr FromAronTypeNaviagtorPtr(const typenavigator::AronTypeNavigatorPtr&); + static AronTypeCppSerializerPtr FromAronTypeNaviagtorPtr(const typenavigator::NavigatorPtr&); private: // members diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/SerializerFactory.cpp similarity index 75% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/SerializerFactory.cpp index 9bc980d9fc8816a2c4a40f6fb1a6cb4f1bf6eefb..e67d41379f9f853843ccdc65b95ca954aad1ea28 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/SerializerFactory.cpp @@ -24,7 +24,7 @@ // STD/STL // Header -#include "AronTypeCppSerializerFactory.h" +#include "SerializerFactory.h" namespace armarx { @@ -37,39 +37,39 @@ namespace armarx namespace cppSerializer { // Map types to factories - const std::unordered_map<AronTypeDescriptor, AronTypeCppSerializerFactoryPtr> AronTypeCppSerializerFactory::FACTORIES = + const std::unordered_map<type::Descriptor, AronTypeCppSerializerFactoryPtr> AronTypeCppSerializerFactory::FACTORIES = { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - {AronTypeDescriptor::eAron##upperType##Type, AronTypeCppSerializerFactoryPtr(new Aron##upperType##TypeCppSerializerFactory())}, \ + {type::Descriptor::eAron##upperType##Type, AronTypeCppSerializerFactoryPtr(new Aron##upperType##TypeCppSerializerFactory())}, \ HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO }; // Access method - cppSerializer::AronTypeCppSerializerPtr AronTypeCppSerializerFactory::create(const typenavigator::AronTypeNavigatorPtr& n, const AronPath& path) const + cppSerializer::AronTypeCppSerializerPtr AronTypeCppSerializerFactory::create(const typenavigator::AronTypeNavigatorPtr& n, const Path& path) const { - CheckIfInputIsNull("AronDataNavigatorFactory", "create", path, n); + CheckIfPtrIsNull("NavigatorFactory", "create", path, n); auto res = n->getResult(); auto factory_iterator = FACTORIES.find(AronResolver::GetDescriptorForAronType(res)); if (factory_iterator == FACTORIES.end()) { - throw exception::AronExceptionWithPathInfo("AronDataNavigatorFactory", "create", "Cannot find the desired factory for input (ice_id): " + res->ice_id() + ". Cannot create navigator", path); + throw exception::AronException("NavigatorFactory", "create", "Cannot find the desired factory for input (ice_id): " + res->ice_id() + ". Cannot create navigator", path); } return factory_iterator->second->createSpecific(n, path); } - cppSerializer::AronTypeCppSerializerPtr AronTypeCppSerializerFactory::createSpecific(const typenavigator::AronTypeNavigatorPtr&, const AronPath&) const + cppSerializer::AronTypeCppSerializerPtr AronTypeCppSerializerFactory::createSpecific(const typenavigator::AronTypeNavigatorPtr&, const Path&) const { - throw exception::AronException("AronDataNavigatorFactory", "createSpecific", "Called disallowed method. Use child class instead!"); + throw exception::AronException("NavigatorFactory", "createSpecific", "Called disallowed method. Use child class instead!"); } // Container Factories #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - cppSerializer::AronTypeCppSerializerPtr Aron##upperType##TypeCppSerializerFactory::createSpecific(const typenavigator::AronTypeNavigatorPtr& n, const AronPath& path) const \ + cppSerializer::AronTypeCppSerializerPtr Aron##upperType##TypeCppSerializerFactory::createSpecific(const typenavigator::AronTypeNavigatorPtr& n, const Path& path) const \ { \ CheckIfInputIsNull("Aron"+std::string(#upperType)+"TypeCppSerializerFactory", "createSpecific[BeforeCast]", path, n); \ typenavigator::Aron##upperType##TypeNavigatorPtr casted = typenavigator::Aron##upperType##TypeNavigator::DynamicCast(n); \ @@ -78,7 +78,7 @@ namespace armarx } HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/SerializerFactory.h similarity index 82% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/SerializerFactory.h index e9c26d88abcaf7f26ca7e516ec9c0dd7a12a456c..54e9b386f94454de216974974d46c8b355d6b563 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializerFactory.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/SerializerFactory.h @@ -28,12 +28,12 @@ #include <unordered_map> // Base Class -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/AronSerializerFactory.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/SerializerFactory.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronAllCppSerializers.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/AllSerializers.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> namespace armarx { @@ -53,11 +53,11 @@ namespace armarx { public: AronTypeCppSerializerFactory() = default; - virtual cppSerializer::AronTypeCppSerializerPtr create(const typenavigator::AronTypeNavigatorPtr&, const AronPath&) const override; - virtual cppSerializer::AronTypeCppSerializerPtr createSpecific(const typenavigator::AronTypeNavigatorPtr&, const AronPath&) const override; + virtual cppSerializer::AronTypeCppSerializerPtr create(const typenavigator::AronTypeNavigatorPtr&, const Path&) const override; + virtual cppSerializer::AronTypeCppSerializerPtr createSpecific(const typenavigator::AronTypeNavigatorPtr&, const Path&) const override; private: - static const std::unordered_map<AronTypeDescriptor, AronTypeCppSerializerFactoryPtr> FACTORIES; + static const std::unordered_map<type::Descriptor, AronTypeCppSerializerFactoryPtr> FACTORIES; }; // Factories @@ -67,11 +67,11 @@ namespace armarx { \ public: \ Aron##upperType##TypeCppSerializerFactory() = default; \ - virtual cppSerializer::AronTypeCppSerializerPtr createSpecific(const typenavigator::AronTypeNavigatorPtr&, const AronPath&) const override; \ + virtual cppSerializer::AronTypeCppSerializerPtr createSpecific(const typenavigator::AronTypeNavigatorPtr&, const Path&) const override; \ }; HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Dict.cpp similarity index 98% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Dict.cpp index 2918f4035f29ad81d8fc9bbe60c82825dc1dc06e..d86af8c690c9727c92e10532f4bc9dfae266a493 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Dict.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronDictTypeCppSerializer.h" +#include "Dict.h" namespace armarx @@ -40,7 +40,7 @@ namespace armarx const std::string AronDictTypeCppSerializer::DICT_VALUE_ACCESSOR = "_value"; // constructors - AronDictTypeCppSerializer::AronDictTypeCppSerializer(const typenavigator::AronDictTypeNavigatorPtr& n) : + AronDictTypeCppSerializer::AronDictTypeCppSerializer(const typenavigator::DictNavigatorPtr& n) : AronTypeCppSerializer("std::map<std::string, " + FromAronTypeNaviagtorPtr(n->getAcceptedType())->getCppTypename() + ">", simox::meta::get_type_name(typeid(data::AronDict)), simox::meta::get_type_name(typeid(type::AronDictType))), typenavigator(n) { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Dict.h similarity index 92% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Dict.h index bf0b9d031e474782b74842dca55f372ec347ca33..e7852cbc99b10228e9196a9aa27c195e8d36c1f8 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Dict.h @@ -28,10 +28,10 @@ #include <map> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.h> namespace armarx @@ -57,7 +57,7 @@ namespace armarx public: // constructors AronDictTypeCppSerializer() = delete; - AronDictTypeCppSerializer(const typenavigator::AronDictTypeNavigatorPtr&); + AronDictTypeCppSerializer(const typenavigator::DictNavigatorPtr&); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -77,7 +77,7 @@ namespace armarx static const std::string DICT_KEY_ACCESSOR; static const std::string DICT_VALUE_ACCESSOR; - typenavigator::AronDictTypeNavigatorPtr typenavigator; + typenavigator::DictNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/List.cpp similarity index 98% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/List.cpp index b44448dcdf84777d6c6837e1b6e317d57559b7a2..343c965e2687175ad6f3deb882dac3d5776414eb 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/List.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronListTypeCppSerializer.h" +#include "List.h" namespace armarx { @@ -37,7 +37,7 @@ namespace armarx const std::string AronListTypeCppSerializer::LIST_ITERATOR_ACCESSOR = "_iterator"; // constructors - AronListTypeCppSerializer::AronListTypeCppSerializer(const typenavigator::AronListTypeNavigatorPtr& e) : + AronListTypeCppSerializer::AronListTypeCppSerializer(const typenavigator::ListNavigatorPtr& e) : AronTypeCppSerializer("std::vector<" + FromAronTypeNaviagtorPtr(e->getAcceptedType())->getCppTypename() + ">", simox::meta::get_type_name(typeid(data::AronList)), simox::meta::get_type_name(typeid(type::AronListType))), typenavigator(e) { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/List.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/List.h index 0caa35d539eb10424541582638e8fe7cb3e0522c..dc82a200cb75e00eeee545412119b3cd01a01f67 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/List.h @@ -28,10 +28,10 @@ #include <vector> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> namespace armarx { @@ -54,7 +54,7 @@ namespace armarx public: // constructors - AronListTypeCppSerializer(const typenavigator::AronListTypeNavigatorPtr&); + AronListTypeCppSerializer(const typenavigator::ListNavigatorPtr&); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -72,7 +72,7 @@ namespace armarx // members static const std::string LIST_ITERATOR_ACCESSOR; - typenavigator::AronListTypeNavigatorPtr typenavigator; + typenavigator::ListNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Object.cpp similarity index 99% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Object.cpp index 312847cef04a904fb014728558efdf6c2061aa67..ed37bf22d4a115f4cbbdb052da16126f052fb680 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Object.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronObjectTypeCppSerializer.h" +#include "Object.h" namespace armarx @@ -39,7 +39,7 @@ namespace armarx const std::string AronObjectTypeCppSerializer::EXTENDS_ITERATOR_ACCESSOR = "_extends"; // constructors - AronObjectTypeCppSerializer::AronObjectTypeCppSerializer(const typenavigator::AronObjectTypeNavigatorPtr& e) : + AronObjectTypeCppSerializer::AronObjectTypeCppSerializer(const typenavigator::ObjectNavigatorPtr& e) : AronTypeCppSerializer(e->getObjectName(), simox::meta::get_type_name(typeid(data::AronDict)), simox::meta::get_type_name(typeid(type::AronObjectType))), typenavigator(e) { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Object.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Object.h index a1d6c27d2adb3ea775b559e777fc736554646064..eb631b29c2dd38d1270f85e52a9277a984ccced2 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Object.h @@ -28,10 +28,10 @@ #include <map> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> namespace armarx @@ -56,7 +56,7 @@ namespace armarx public: // constructors - AronObjectTypeCppSerializer(const typenavigator::AronObjectTypeNavigatorPtr&); + AronObjectTypeCppSerializer(const typenavigator::ObjectNavigatorPtr&); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -74,7 +74,7 @@ namespace armarx // members static const std::string EXTENDS_ITERATOR_ACCESSOR; - typenavigator::AronObjectTypeNavigatorPtr typenavigator; + typenavigator::ObjectNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Tuple.cpp similarity index 98% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Tuple.cpp index c74685ad977771f6861422907ea6d7e2253915dd..9d9d21fcd0526c86dfe0d2e15c910f7b0a3d1b4b 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Tuple.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronTupleTypeCppSerializer.h" +#include "Tuple.h" namespace armarx @@ -39,7 +39,7 @@ namespace armarx const std::string AronTupleTypeCppSerializer::TUPLE_ITERATOR_ACCESSOR = "_iterator"; // constructors - AronTupleTypeCppSerializer::AronTupleTypeCppSerializer(const typenavigator::AronTupleTypeNavigatorPtr& e) : + AronTupleTypeCppSerializer::AronTupleTypeCppSerializer(const typenavigator::TupleNavigatorPtr& e) : AronTypeCppSerializer("std::tuple<" + simox::alg::join(ExtractCppTypenamesFromList(e->getAcceptedTypes()), ", ") + ">", simox::meta::get_type_name(typeid(data::AronList)), simox::meta::get_type_name(typeid(type::AronTupleType))), typenavigator(e) { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Tuple.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Tuple.h index 1c49e328143eaf9dfa9ee2b34bc3e6a2f7653d7c..cb4a56356969e918d4dbbfe6dd4cfa282823d7ce 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/container/Tuple.h @@ -28,10 +28,10 @@ #include <map> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.h> namespace armarx { @@ -55,7 +55,7 @@ namespace armarx public: // constructors - AronTupleTypeCppSerializer(const typenavigator::AronTupleTypeNavigatorPtr& e); + AronTupleTypeCppSerializer(const typenavigator::TupleNavigatorPtr& e); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -73,7 +73,7 @@ namespace armarx // members static const std::string TUPLE_ITERATOR_ACCESSOR; - typenavigator::AronTupleTypeNavigatorPtr typenavigator; + typenavigator::TupleNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.cpp similarity index 92% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.cpp index e74e3b24b1bdbe5f111320376108242f9d9ac876..0fc8c00ab849e44ecd68279ed758bcf4756a73d1 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronEigenMatrixTypeCppSerializer.h" +#include "EigenMatrix.h" namespace armarx { @@ -47,8 +47,8 @@ namespace armarx }; // constructors - AronEigenMatrixTypeCppSerializer::AronEigenMatrixTypeCppSerializer(const typenavigator::AronEigenMatrixTypeNavigatorPtr& n) : - AronTypeCppSerializer("std::shared_ptr<::Eigen::Matrix<" + ACCEPTED_TYPES.at(n->getUsedType()).first + ", " + std::to_string(n->getRows()) + ", " + std::to_string(n->getCols()) + ">>", simox::meta::get_type_name(typeid(data::AronNDArray)), simox::meta::get_type_name(typeid(type::AronEigenMatrixType))), + AronEigenMatrixTypeCppSerializer::AronEigenMatrixTypeCppSerializer(const typenavigator::EigenMatrixNavigatorPtr& n) : + AronTypeCppSerializer("std::shared_ptr<::Eigen::Matrix<" + ACCEPTED_TYPES.at(n->getTypename()).first + ", " + std::to_string(n->getRows()) + ", " + std::to_string(n->getCols()) + ">>", simox::meta::get_type_name(typeid(data::AronNDArray)), simox::meta::get_type_name(typeid(type::AronEigenMatrixType))), typenavigator(n) { } @@ -73,7 +73,7 @@ namespace armarx CppBlockPtr AronEigenMatrixTypeCppSerializer::getResetBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine(accessor + " = " + getCppTypename() + "(new ::Eigen::Matrix<" + ACCEPTED_TYPES.at(typenavigator->getUsedType()).first + ", " + std::to_string(typenavigator->getRows()) + ", " + std::to_string(typenavigator->getCols()) + ">());"); + b->addLine(accessor + " = " + getCppTypename() + "(new ::Eigen::Matrix<" + ACCEPTED_TYPES.at(typenavigator->getTypename()).first + ", " + std::to_string(typenavigator->getRows()) + ", " + std::to_string(typenavigator->getCols()) + ">());"); return b; } @@ -81,7 +81,7 @@ namespace armarx { CppBlockPtr b = CppBlockPtr(new CppBlock()); simox::alg::to_string<int>(typenavigator->getDimensions(), ", "); - b->addLine("w.writeEigenMatrixType({" + simox::alg::to_string<int>(typenavigator->getDimensions(), ", ") + "}, \"" + typenavigator->getUsedType() + "\");"); + b->addLine("w.writeEigenMatrixType({" + simox::alg::to_string<int>(typenavigator->getDimensions(), ", ") + "}, \"" + typenavigator->getTypename() + "\");"); return b; } @@ -89,21 +89,21 @@ namespace armarx { CppBlockPtr b = CppBlockPtr(new CppBlock()); simox::alg::to_string<int>(typenavigator->getDimensions(), ", "); - b->addLine("w.writeEigenMatrixType({" + accessor + "->rows(), " + accessor + "->cols()}, \"" + typenavigator->getUsedType() + "\");"); + b->addLine("w.writeEigenMatrixType({" + accessor + "->rows(), " + accessor + "->cols()}, \"" + typenavigator->getTypename() + "\");"); return b; } CppBlockPtr AronEigenMatrixTypeCppSerializer::getInitializeBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine(accessor + " = " + getCppTypename() + "(new ::Eigen::Matrix<" + ACCEPTED_TYPES.at(typenavigator->getUsedType()).first + ", " + std::to_string(typenavigator->getRows()) + ", " + std::to_string(typenavigator->getCols()) + ">());"); + b->addLine(accessor + " = " + getCppTypename() + "(new ::Eigen::Matrix<" + ACCEPTED_TYPES.at(typenavigator->getTypename()).first + ", " + std::to_string(typenavigator->getRows()) + ", " + std::to_string(typenavigator->getCols()) + ">());"); return b; } CppBlockPtr AronEigenMatrixTypeCppSerializer::getWriteBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writeNDArray({" + accessor + "->rows(), " + accessor + "->cols(), " + std::to_string(ACCEPTED_TYPES.at(typenavigator->getUsedType()).second) + "}, \"" + typenavigator->getUsedType() + "\", reinterpret_cast<unsigned char*>(" + accessor + "->data()));"); + b->addLine("w.writeNDArray({" + accessor + "->rows(), " + accessor + "->cols(), " + std::to_string(ACCEPTED_TYPES.at(typenavigator->getTypename()).second) + "}, \"" + typenavigator->getTypename() + "\", reinterpret_cast<unsigned char*>(" + accessor + "->data()));"); return b; } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.h index fbc998f7f3072cc385c37f3778b2d60f56e621b0..2a2dc270a775813339748f27e33d6f500d503e16 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/EigenMatrix.h @@ -28,10 +28,10 @@ #include <map> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.h> namespace armarx { @@ -55,7 +55,7 @@ namespace armarx public: // constructors - AronEigenMatrixTypeCppSerializer(const typenavigator::AronEigenMatrixTypeNavigatorPtr&); + AronEigenMatrixTypeCppSerializer(const typenavigator::EigenMatrixNavigatorPtr&); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -73,7 +73,7 @@ namespace armarx // Members static const std::map<std::string, std::pair<std::string, int>> ACCEPTED_TYPES; - typenavigator::AronEigenMatrixTypeNavigatorPtr typenavigator; + typenavigator::EigenMatrixNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.cpp similarity index 94% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.cpp index 200ea10097b9e2685995d518648ebee31b442dcf..5361e1969b82ce7d03f95496bade263e613c6c56 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronIVTCByteImageTypeCppSerializer.h" +#include "IVTCByteImage.h" namespace armarx { @@ -43,12 +43,12 @@ namespace armarx }; // constructors - AronIVTCByteImageTypeCppSerializer::AronIVTCByteImageTypeCppSerializer(const typenavigator::AronIVTCByteImageTypeNavigatorPtr& e) : + AronIVTCByteImageTypeCppSerializer::AronIVTCByteImageTypeCppSerializer(const typenavigator::IVTCByteImageNavigatorPtr& e) : AronTypeCppSerializer("std::shared_ptr<CByteImage>", simox::meta::get_type_name(typeid(data::AronNDArray)), simox::meta::get_type_name(typeid(type::AronIVTCByteImageType))), typenavigator(e) { // check if type exists - ACCEPTED_TYPES.at(typenavigator->getUsedType()); + ACCEPTED_TYPES.at(typenavigator->getTypename()); } std::vector<CppFieldPtr> AronIVTCByteImageTypeCppSerializer::getPublicVariableDeclarations(const std::string& name) const @@ -78,21 +78,21 @@ namespace armarx CppBlockPtr AronIVTCByteImageTypeCppSerializer::getInitializeBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine(accessor + " = " + getCppTypename() + "(new CByteImage(" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + ", " + ACCEPTED_TYPES.at(typenavigator->getUsedType()).first + "));"); + b->addLine(accessor + " = " + getCppTypename() + "(new CByteImage(" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + ", " + ACCEPTED_TYPES.at(typenavigator->getTypename()).first + "));"); return b; } CppBlockPtr AronIVTCByteImageTypeCppSerializer::getWriteInitialTypeBlock(const std::string&) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writeIVTCByteImageType({" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + "}, \"" + typenavigator->getUsedType() + "\");"); + b->addLine("w.writeIVTCByteImageType({" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + "}, \"" + typenavigator->getTypename() + "\");"); return b; } CppBlockPtr AronIVTCByteImageTypeCppSerializer::getWriteCurrentTypeBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writeIVTCByteImageType({" + accessor + "->width, " + accessor + "->height} \"" + typenavigator->getUsedType() + "\");"); + b->addLine("w.writeIVTCByteImageType({" + accessor + "->width, " + accessor + "->height} \"" + typenavigator->getTypename() + "\");"); return b; } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.h index da6382571b063134a9802ffd285ab1ece39c25d4..9c07c1e9ca9efbbb5d1dce06a4c9059181470c0d 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/IVTCByteImage.h @@ -28,10 +28,10 @@ #include <map> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.h> namespace armarx { @@ -55,7 +55,7 @@ namespace armarx public: // constructors - AronIVTCByteImageTypeCppSerializer(const typenavigator::AronIVTCByteImageTypeNavigatorPtr&); + AronIVTCByteImageTypeCppSerializer(const typenavigator::IVTCByteImageNavigatorPtr&); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -73,7 +73,7 @@ namespace armarx // members static const std::map<std::string, std::pair<std::string, int>> ACCEPTED_TYPES; - typenavigator::AronIVTCByteImageTypeNavigatorPtr typenavigator; + typenavigator::IVTCByteImageNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.cpp similarity index 96% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.cpp index 5b76c62e07283ac406bc8043c7c4cf057fcf672b..fa3ba06c9b2be2ba993d8fe8f1ca35402e6a333e 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronOpenCVMatTypeCppSerializer.h" +#include "OpenCVMat.h" namespace armarx { @@ -51,12 +51,12 @@ namespace armarx const std::string AronOpenCVMatTypeCppSerializer::OPENCVMAT_DIFF_ACCESSOR = "_dimensions"; // constructors - AronOpenCVMatTypeCppSerializer::AronOpenCVMatTypeCppSerializer(const typenavigator::AronOpenCVMatTypeNavigatorPtr& e) : + AronOpenCVMatTypeCppSerializer::AronOpenCVMatTypeCppSerializer(const typenavigator::OpenCVMatNavigatorPtr& e) : AronTypeCppSerializer("std::shared_ptr<cv::Mat>", simox::meta::get_type_name(typeid(data::AronNDArray)), simox::meta::get_type_name(typeid(type::AronOpenCVMatType))), typenavigator(e) { // check if type exists - ACCEPTED_TYPES.at(e->getUsedType()); + ACCEPTED_TYPES.at(e->getTypename()); } std::vector<CppFieldPtr> AronOpenCVMatTypeCppSerializer::getPublicVariableDeclarations(const std::string& name) const @@ -96,14 +96,14 @@ namespace armarx CppBlockPtr AronOpenCVMatTypeCppSerializer::getInitializeBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine(accessor + " = " + getCppTypename() + "(new cv::Mat(std::vector<int>({" + simox::alg::to_string<int>(typenavigator->getDimensions(), ", ") + "}), " + ACCEPTED_TYPES.at(typenavigator->getUsedType()).first + "));"); + b->addLine(accessor + " = " + getCppTypename() + "(new cv::Mat(std::vector<int>({" + simox::alg::to_string<int>(typenavigator->getDimensions(), ", ") + "}), " + ACCEPTED_TYPES.at(typenavigator->getTypename()).first + "));"); return b; } CppBlockPtr AronOpenCVMatTypeCppSerializer::getWriteInitialTypeBlock(const std::string&) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writeOpenCVMatType({" + simox::alg::to_string<int>(typenavigator->getDimensions(), ", ") + "}, \"" + typenavigator->getUsedType() + "\");"); + b->addLine("w.writeOpenCVMatType({" + simox::alg::to_string<int>(typenavigator->getDimensions(), ", ") + "}, \"" + typenavigator->getTypename() + "\");"); return b; } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.h index d786070b8165b567a2da3de59256d96e3cf3ef46..4c7ed0433d3466227294925ab6dc921d52ef6864 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/OpenCVMat.h @@ -28,10 +28,10 @@ #include <map> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.h> namespace armarx { @@ -55,7 +55,7 @@ namespace armarx public: // constructors - AronOpenCVMatTypeCppSerializer(const typenavigator::AronOpenCVMatTypeNavigatorPtr& n); + AronOpenCVMatTypeCppSerializer(const typenavigator::OpenCVMatNavigatorPtr& n); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -76,7 +76,7 @@ namespace armarx static const std::string OPENCVMAT_DIMENSIONS_ACCESSOR; static const std::string OPENCVMAT_DIFF_ACCESSOR; - typenavigator::AronOpenCVMatTypeNavigatorPtr typenavigator; + typenavigator::OpenCVMatNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.cpp similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.cpp index d4d7f8f70891607b20d437bb50793f8737f8be73..609e4c893bdfb29bde1e15fa1a80523a0425a3e5 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronPCLPointCloudTypeCppSerializer.h" +#include "PCLPointCloud.h" namespace armarx { @@ -48,8 +48,8 @@ namespace armarx }; // constructors - AronPCLPointCloudTypeCppSerializer::AronPCLPointCloudTypeCppSerializer(const typenavigator::AronPCLPointCloudTypeNavigatorPtr& n) : - AronTypeCppSerializer("std::shared_ptr<pcl::PointCloud<" + ACCEPTED_TYPES.at(n->getUsedType()).first + ">>", simox::meta::get_type_name(typeid(data::AronNDArray)), simox::meta::get_type_name(typeid(type::AronPCLPointCloudType))), + AronPCLPointCloudTypeCppSerializer::AronPCLPointCloudTypeCppSerializer(const typenavigator::PCLPointCloudNavigatorPtr& n) : + AronTypeCppSerializer("std::shared_ptr<pcl::PointCloud<" + ACCEPTED_TYPES.at(n->getTypename()).first + ">>", simox::meta::get_type_name(typeid(data::AronNDArray)), simox::meta::get_type_name(typeid(type::AronPCLPointCloudType))), typenavigator(n) { } @@ -74,35 +74,35 @@ namespace armarx CppBlockPtr AronPCLPointCloudTypeCppSerializer::getResetBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine(accessor + " = " + getCppTypename() + "(new pcl::PointCloud<" + ACCEPTED_TYPES.at(typenavigator->getUsedType()).first + ">(" + accessor + "->width, " + accessor + "->height));"); + b->addLine(accessor + " = " + getCppTypename() + "(new pcl::PointCloud<" + ACCEPTED_TYPES.at(typenavigator->getTypename()).first + ">(" + accessor + "->width, " + accessor + "->height));"); return b; } CppBlockPtr AronPCLPointCloudTypeCppSerializer::getInitializeBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine(accessor + " = " + getCppTypename() + "(new pcl::PointCloud<" + ACCEPTED_TYPES.at(typenavigator->getUsedType()).first + ">(" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + "));"); + b->addLine(accessor + " = " + getCppTypename() + "(new pcl::PointCloud<" + ACCEPTED_TYPES.at(typenavigator->getTypename()).first + ">(" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + "));"); return b; } CppBlockPtr AronPCLPointCloudTypeCppSerializer::getWriteInitialTypeBlock(const std::string&) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writePCLPointCloudType({" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + "}, \"" + typenavigator->getUsedType() + "\");"); + b->addLine("w.writePCLPointCloudType({" + std::to_string(typenavigator->getWidth()) + ", " + std::to_string(typenavigator->getHeight()) + "}, \"" + typenavigator->getTypename() + "\");"); return b; } CppBlockPtr AronPCLPointCloudTypeCppSerializer::getWriteCurrentTypeBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writePCLPointCloudType({" + accessor + "->width, " + accessor + "->height}, \"" + typenavigator->getUsedType() + "\");"); + b->addLine("w.writePCLPointCloudType({" + accessor + "->width, " + accessor + "->height}, \"" + typenavigator->getTypename() + "\");"); return b; } CppBlockPtr AronPCLPointCloudTypeCppSerializer::getWriteBlock(const std::string& accessor) const { CppBlockPtr b = CppBlockPtr(new CppBlock()); - b->addLine("w.writeNDArray({" + accessor + "->width, " + accessor + "->height, " + std::to_string(ACCEPTED_TYPES.at(typenavigator->getUsedType()).second) + "}, \"" + typenavigator->getUsedType() + "\", reinterpret_cast<unsigned char*>(" + accessor + "->points.data()));"); + b->addLine("w.writeNDArray({" + accessor + "->width, " + accessor + "->height, " + std::to_string(ACCEPTED_TYPES.at(typenavigator->getTypename()).second) + "}, \"" + typenavigator->getTypename() + "\", reinterpret_cast<unsigned char*>(" + accessor + "->points.data()));"); return b; } @@ -110,7 +110,7 @@ namespace armarx { CppBlockPtr b = CppBlockPtr(new CppBlock()); b->addLine("const auto [dims, _] = r.readStartNDArray();"); - b->addLine(accessor + " = " + getCppTypename() + "(new pcl::PointCloud<" + ACCEPTED_TYPES.at(typenavigator->getUsedType()).first + ">(dims[0], dims[1]));"); + b->addLine(accessor + " = " + getCppTypename() + "(new pcl::PointCloud<" + ACCEPTED_TYPES.at(typenavigator->getTypename()).first + ">(dims[0], dims[1]));"); b->addLine("r.readEndNDArray(reinterpret_cast<unsigned char*>(" + accessor + "->points.data()));"); return b; } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.h index de9c97d18420f43b34fdf081377e40769f1a92bd..aac4ddc2d094f7bcf1dc4746143ebeb2dde2ef64 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/ndarray/PCLPointCloud.h @@ -28,10 +28,10 @@ #include <map> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.h> namespace armarx { @@ -54,7 +54,7 @@ namespace armarx public: // constructors - AronPCLPointCloudTypeCppSerializer(const typenavigator::AronPCLPointCloudTypeNavigatorPtr&); + AronPCLPointCloudTypeCppSerializer(const typenavigator::PCLPointCloudNavigatorPtr&); // virtual implementations virtual std::vector<CppFieldPtr> getPublicVariableDeclarations(const std::string&) const override; @@ -72,7 +72,7 @@ namespace armarx // members static const std::map<std::string, std::pair<std::string, int>> ACCEPTED_TYPES; - typenavigator::AronPCLPointCloudTypeNavigatorPtr typenavigator; + typenavigator::PCLPointCloudNavigatorPtr typenavigator; }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/primitive/Primitive.cpp similarity index 99% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/primitive/Primitive.cpp index 8e96c5e6cd4edbb4497189e1b1723709467aec49..cb7eb9046b12e54b0fb04b201152e4ea32d1949c 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/primitive/Primitive.cpp @@ -27,7 +27,7 @@ #include <map> // Header -#include "AronPrimitiveTypeCppSerializer.h" +#include "Primitive.h" namespace armarx { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/primitive/Primitive.h similarity index 92% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/primitive/Primitive.h index 5abc26edd72cdf103238fa35d088f150a9710468..e6cf6eee87f0e531f0fee53313759d87ca84ad0e 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/primitive/Primitive.h @@ -27,11 +27,11 @@ #include <string> // Base Class -#include "AronTypeCppSerializer.h" +#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriter/cpp/serializer/Serializer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h> namespace armarx { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronAllCppSerializers.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronAllCppSerializers.h deleted file mode 100644 index 2154806d9f7646c151eb07472e733cbad9e80b6e..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronAllCppSerializers.h +++ /dev/null @@ -1,41 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <string> -#include <map> - -// ArmarX -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronDictTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronListTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronObjectTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronTupleTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronEigenMatrixTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPCLPointCloudTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronIVTCByteImageTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronOpenCVMatTypeCppSerializer.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/codeWriters/cppWriter/typeSerializers/AronPrimitiveTypeCppSerializer.h> diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/AronTypeReader.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/Reader.h similarity index 89% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/AronTypeReader.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/Reader.h index fb82683a0bd93ef64bf645da121c4b0f81dc3365..4f29d4efe9ae36ce98faa46b224bdec4becb8765 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/AronTypeReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/Reader.h @@ -28,10 +28,10 @@ #include <filesystem> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/AronReaderInfo.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/AronWriterInfo.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/AronGenerateTypeInfo.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/ReaderInfo.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/WriterInfo.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/GenerateTypeInfo.h> namespace armarx { diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.cpp similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.cpp index 6779b170af7fa321ccc35e5d5766e9b7ec4ec144..935b15304c1d7d437d553e03e120f1086a08752f 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.cpp @@ -28,7 +28,7 @@ #include <SimoxUtility/algorithm/string.h> // Header -#include "AronTypeXMLData.h" +#include "Data.h" // ArmarX #include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> @@ -79,7 +79,7 @@ namespace armarx { if (!HasAttribute(node, att)) { - throw exception::AronStringNotValidException("AronTypeXMLReaderData", "EnforceAttribute", "A <" + node.name() + ">-tag does not have the correct attribute", att); + throw exception::StringNotValidException("XMLReaderData", "EnforceAttribute", "A <" + node.name() + ">-tag does not have the correct attribute", att); } } @@ -112,7 +112,7 @@ namespace armarx { if (!(HasTagName(node, name))) { - throw exception::AronStringNotValidException("AronTypeXMLReaderData", "EnforceTagName", "The node <" + node.name() + "> has the wrong tag", name); + throw exception::StringNotValidException("XMLReaderData", "EnforceTagName", "The node <" + node.name() + "> has the wrong tag", name); } } @@ -143,7 +143,7 @@ namespace armarx { if (!AronTypeXMLReaderData::CheckExactChildSize(node, size)) { - throw exception::AronSizeNotValidException("AronTypeXMLReaderData", "EnforceChildSize", "The node <" + node.name() + "> has the wrong number of children", node.nodes().size(), size); + throw exception::SizeNotValidException("XMLReaderData", "EnforceChildSize", "The node <" + node.name() + "> has the wrong number of children", node.nodes().size(), size); } } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.h index 38a27f5dab1ad4c78989fa6c07c1392380308f8c..bcdd0142737757067deaf0a4e0033f79aa680059 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.h @@ -30,12 +30,12 @@ // ArmarX #include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h> namespace armarx diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReader.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Reader.cpp similarity index 87% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReader.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Reader.cpp index ae4efcea13c7552bd6735f3ee4c134aa3a5b87a4..5e6df57804e97ccede27711ef9ef7a5cef470e8c 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReader.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Reader.cpp @@ -25,13 +25,13 @@ // Header -#include "AronTypeXMLReader.h" +#include "Reader.h" // ArmarX #include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.h> namespace armarx { @@ -75,7 +75,7 @@ namespace armarx { if (cpp_includes_index != -1) { - throw exception::AronException("AronTypeXMLReader", "parse", "Already found an include tag. Please check the xml file."); + throw exception::AronException("XMLReader", "parse", "Already found an include tag. Please check the xml file."); } else { @@ -86,7 +86,7 @@ namespace armarx { if (include_aron_file_index != -1) { - throw exception::AronException("AronTypeXMLReader", "parse", "Already found an use type tag. Please check the xml file."); + throw exception::AronException("XMLReader", "parse", "Already found an use type tag. Please check the xml file."); } else { @@ -97,7 +97,7 @@ namespace armarx { if (generate_types_index != -1) { - throw exception::AronException("AronTypeXMLReader", "parse", "Already found an generate type tag. Please check the xml file."); + throw exception::AronException("XMLReader", "parse", "Already found an generate type tag. Please check the xml file."); } else { @@ -106,7 +106,7 @@ namespace armarx } else { - throw exception::AronStringNotValidException("AronTypeXMLReader", "parse", "Found an unexpected xml tag", child.name()); + throw exception::StringNotValidException("XMLReader", "parse", "Found an unexpected xml tag", child.name()); } index++; } @@ -137,7 +137,7 @@ namespace armarx for (const auto& generateType : children[generate_types_index].nodes()) { // ugly workaround - const typenavigator::AronObjectTypeNavigatorPtr aronObj = readGenerateType(generateType); + const typenavigator::ObjectNavigatorPtr aronObj = readGenerateType(generateType); const std::map<std::string, AronGenerateTypeInfoPtr> generatedObjects = factory.GetAllKnownGeneratedPublicObjects(); generateTypes.push_back(generatedObjects.at(aronObj->getObjectName())); } @@ -165,10 +165,10 @@ namespace armarx return xmlinclude; } - typenavigator::AronObjectTypeNavigatorPtr AronTypeXMLReader::readGenerateType(const RapidXmlReaderNode& node) const + typenavigator::ObjectNavigatorPtr AronTypeXMLReader::readGenerateType(const RapidXmlReaderNode& node) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_TYPE_TAG); - return typenavigator::AronObjectTypeNavigator::DynamicCast(factory.createSpecific(node, AronPath())); + return typenavigator::ObjectNavigator::DynamicCast(factory.createSpecific(node, Path())); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReader.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Reader.h similarity index 89% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReader.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Reader.h index 3677b04a4b95cabec5dbb350dec31bf10a85410c..266786fe2ed4204925e88116407ed0ebbeab935a 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Reader.h @@ -28,14 +28,14 @@ #include <filesystem> // Base Class -#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/AronTypeReader.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/AronTypeReader.h> // ArmarX #include <SimoxUtility/xml.h> #include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/AronTypeXMLReaderFactory.h> namespace armarx { @@ -63,7 +63,7 @@ namespace armarx std::string readCppInclude(const RapidXmlReaderNode& node) const; std::string readAronInclude(const RapidXmlReaderNode& node) const; - typenavigator::AronObjectTypeNavigatorPtr readGenerateType(const RapidXmlReaderNode& node) const; + typenavigator::ObjectNavigatorPtr readGenerateType(const RapidXmlReaderNode& node) const; private: AronObjectTypeXMLReaderFactory factory; diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.cpp b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/ReaderFactory.cpp similarity index 79% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.cpp rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/ReaderFactory.cpp index 8d6a40b60d29d9f8aaccfd8a2d7412592daee89e..585e2e343fde639fd471aabb9c399611d4ef0c0b 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/ReaderFactory.cpp @@ -27,11 +27,11 @@ #include <SimoxUtility/algorithm/string.h> // Header -#include "AronTypeXMLReaderFactory.h" +#include "ReaderFactory.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLData.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/Data.h> namespace armarx { @@ -45,14 +45,14 @@ namespace armarx std::map<std::string, AronGenerateTypeInfoPtr> AronTypeXMLReaderFactory::AllKnownGeneratedPublicObjects = {}; - typenavigator::AronTypeNavigatorPtr AronTypeXMLReaderFactory::create(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronTypeXMLReaderFactory::create(const RapidXmlReaderNode& node, const Path& path) const { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ {AronTypeXMLReaderData::ARON_GENERATE_##capsType##_TAG, AronTypeXMLReaderFactoryPtr(new Aron##upperType##TypeXMLReaderFactory())}, static const std::map<std::string, AronTypeXMLReaderFactoryPtr> Factories = { HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES HANDLE_PRIMITIVE_TYPES }; #undef RUN_ARON_MACRO @@ -60,7 +60,7 @@ namespace armarx const std::string tag = simox::alg::to_lower(node.name()); if (tag == "") { - throw exception::AronException("AronTypeXMLReaderFactory", "create", "An node is empty. Cannot find facory for empty nodes."); + throw exception::AronException("XMLReaderFactory", "create", "An node is empty. Cannot find facory for empty nodes."); } auto factory_iterator = Factories.find(tag); if (factory_iterator != Factories.end()) @@ -77,7 +77,7 @@ namespace armarx return AllKnownGeneratedPublicObjects; } - typenavigator::AronTypeNavigatorPtr AronTypeXMLReaderFactory::ResolveTypename(const std::string& name) + typenavigator::NavigatorPtr AronTypeXMLReaderFactory::ResolveTypename(const std::string& name) { const auto public_it = AllKnownGeneratedPublicObjects.find(name); if (public_it != AllKnownGeneratedPublicObjects.end()) @@ -85,11 +85,11 @@ namespace armarx return public_it->second->correspondingObjectType; } - throw exception::AronStringNotValidException("AronTypeXMLReaderFactory", "ResolveTypename", "Could not find a tag. Please note that you cant make use of nested objects yet", name); + throw exception::StringNotValidException("XMLReaderFactory", "ResolveTypename", "Could not find a tag. Please note that you cant make use of nested objects yet", name); } // Object type - typenavigator::AronTypeNavigatorPtr AronObjectTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronObjectTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceAttribute(node, AronTypeXMLReaderData::ARON_NAME_ATTRIBUTE_NAME); const std::string extends = AronTypeXMLReaderData::GetAttributeWithDefault(node, AronTypeXMLReaderData::ARON_EXTENDS_ATTRIBUTE_NAME, ""); @@ -98,12 +98,12 @@ namespace armarx bool object_is_nested = TheObjectWeAreGoingToGenerateNowStack.size() > 0; // set the new object - typenavigator::AronObjectTypeNavigatorPtr aronObjectType = typenavigator::AronObjectTypeNavigatorPtr(new typenavigator::AronObjectTypeNavigator(path)); + typenavigator::ObjectNavigatorPtr aronObjectType = typenavigator::ObjectNavigatorPtr(new typenavigator::ObjectNavigator(path)); if (object_is_nested) { if (name.rfind("::") != std::string::npos) { - throw exception::AronStringNotValidException("AronObjectTypeXMLReaderFactory", "createSpecific", "Namespaces are not allowed in nested classes", name); + throw exception::StringNotValidException("AronObjectTypeXMLReaderFactory", "createSpecific", "Namespaces are not allowed in nested classes", name); } } aronObjectType->setObjectName(name); @@ -122,7 +122,7 @@ namespace armarx } else { - throw exception::AronStringNotValidException("AronObjectTypeXMLReaderFactory", "createSpecific", "An extends name could not be found. Perhaps you need to change the order of your types or you have to add another UseType", extends); + throw exception::StringNotValidException("AronObjectTypeXMLReaderFactory", "createSpecific", "An extends name could not be found. Perhaps you need to change the order of your types or you have to add another UseType", extends); } } @@ -136,7 +136,7 @@ namespace armarx const std::string key = objectChild.attribute_value(AronTypeXMLReaderData::ARON_KEY_ATTRIBUTE_NAME.c_str()); std::vector<RapidXmlReaderNode> children = objectChild.nodes(); - typenavigator::AronTypeNavigatorPtr childNavigator = create(children[0], AronPath(path, key)); + typenavigator::NavigatorPtr childNavigator = create(children[0], Path(path, key)); aronObjectType->addAcceptedType(key, childNavigator); } @@ -159,22 +159,22 @@ namespace armarx } // List type (List) - typenavigator::AronTypeNavigatorPtr AronListTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronListTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_LIST_TAG); - typenavigator::AronListTypeNavigatorPtr list(new typenavigator::AronListTypeNavigator(path)); + typenavigator::ListNavigatorPtr list(new typenavigator::ListNavigator(path)); AronTypeXMLReaderData::EnforceChildSize(node, 1); std::vector<RapidXmlReaderNode> listTypeNodeChildren = node.nodes(); const RapidXmlReaderNode typeNode = listTypeNodeChildren[0]; - typenavigator::AronTypeNavigatorPtr type = create(typeNode, AronPath(path, "type")); + typenavigator::NavigatorPtr type = create(typeNode, Path(path, "type")); list->setAcceptedType(type); return list; } // List type (Dict) - typenavigator::AronTypeNavigatorPtr AronDictTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronDictTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_DICT_TAG); @@ -182,14 +182,14 @@ namespace armarx AronTypeXMLReaderData::EnforceChildSize(node, 1); std::vector<RapidXmlReaderNode> dictTypeNodeChildren = node.nodes(); const RapidXmlReaderNode typeNode = dictTypeNodeChildren[0]; - typenavigator::AronTypeNavigatorPtr type = create(typeNode, AronPath(path, "type")); + typenavigator::NavigatorPtr type = create(typeNode, Path(path, "type")); dict->setAcceptedType(type); return dict; } // List types (Tuple) - typenavigator::AronTypeNavigatorPtr AronTupleTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronTupleTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_TUPLE_TAG); std::vector<RapidXmlReaderNode> nodeChildren = node.nodes(); @@ -208,14 +208,14 @@ namespace armarx std::vector<RapidXmlReaderNode> typeNodeChildren = tupleTypeDeclarationNode.nodes(); const RapidXmlReaderNode typeNode = typeNodeChildren[0]; - typenavigator::AronTypeNavigatorPtr type = create(typeNode, AronPath(path, "<" + std::to_string(i++) + ">")); + typenavigator::NavigatorPtr type = create(typeNode, Path(path, "<" + std::to_string(i++) + ">")); tuple->addAcceptedType(type); } return tuple; } // Complex type (IVTCByteImage) - typenavigator::AronTypeNavigatorPtr AronIVTCByteImageTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronIVTCByteImageTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_IVT_CBYTE_IMAGE_TAG); AronTypeXMLReaderData::EnforceAttribute(node, AronTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME); @@ -227,12 +227,12 @@ namespace armarx typenavigator::AronIVTCByteImageTypeNavigatorPtr complex(new typenavigator::AronIVTCByteImageTypeNavigator(path)); complex->setWidth(width); complex->setHeight(height); - complex->setUsedType(type); + complex->setTypename(type); return complex; } // Complex type (EigenMatrix) - typenavigator::AronTypeNavigatorPtr AronEigenMatrixTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronEigenMatrixTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_EIGEN_MATRIX_TAG); AronTypeXMLReaderData::EnforceAttribute(node, AronTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME); @@ -244,12 +244,12 @@ namespace armarx typenavigator::AronEigenMatrixTypeNavigatorPtr complex(new typenavigator::AronEigenMatrixTypeNavigator(path)); complex->setRows(rows); complex->setCols(cols); - complex->setUsedType(type); + complex->setTypename(type); return complex; } // Complex type (OpenCVMat) - typenavigator::AronTypeNavigatorPtr AronOpenCVMatTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronOpenCVMatTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_OPENCV_MAT_TAG); AronTypeXMLReaderData::EnforceAttribute(node, AronTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME); @@ -260,12 +260,12 @@ namespace armarx typenavigator::AronOpenCVMatTypeNavigatorPtr complex(new typenavigator::AronOpenCVMatTypeNavigator(path)); complex->setDimensions(dimensions); - complex->setUsedType(type); + complex->setTypename(type); return complex; } // Complex type (PCLPointCloud) - typenavigator::AronTypeNavigatorPtr AronPCLPointCloudTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const AronPath& path) const + typenavigator::NavigatorPtr AronPCLPointCloudTypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode& node, const Path& path) const { AronTypeXMLReaderData::EnforceTagName(node, AronTypeXMLReaderData::ARON_GENERATE_PCL_POINTCLOUD_TAG); AronTypeXMLReaderData::EnforceAttribute(node, AronTypeXMLReaderData::ARON_TYPE_ATTRIBUTE_NAME); @@ -277,13 +277,13 @@ namespace armarx typenavigator::AronPCLPointCloudTypeNavigatorPtr complex(new typenavigator::AronPCLPointCloudTypeNavigator(path)); complex->setWidth(width); complex->setHeight(height); - complex->setUsedType(type); + complex->setTypename(type); return complex; } // Primitve Types #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - typenavigator::AronTypeNavigatorPtr Aron##upperType##TypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode&, const AronPath& path) const \ + typenavigator::AronTypeNavigatorPtr Aron##upperType##TypeXMLReaderFactory::createSpecific(const RapidXmlReaderNode&, const Path& path) const \ { \ return typenavigator::AronTypeNavigatorPtr(new typenavigator::Aron##upperType##TypeNavigator(path)); \ } diff --git a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.h b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/ReaderFactory.h similarity index 76% rename from source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.h rename to source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/ReaderFactory.h index 8347da4c914e1058b3c8be10f9b80417b31966a9..ea75dba6a7c1b89027368c4fed08c5d4a23e6c0b 100644 --- a/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/xmlReader/AronTypeXMLReaderFactory.h +++ b/source/RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/xml/ReaderFactory.h @@ -30,14 +30,14 @@ #include <stack> // Base Class -#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReaders/AronTypeReader.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/typeReader/AronTypeReader.h> // ArmarX #include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> -#include <RobotAPI/libraries/aron/aroncore/AronFactory.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/codegenerator/AronGenerateTypeInfo.h> +#include <RobotAPI/libraries/aron/aroncore/Factory.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/codegenerator/GenerateTypeInfo.h> namespace armarx @@ -52,18 +52,18 @@ namespace armarx typedef std::shared_ptr<AronTypeXMLReaderFactory> AronTypeXMLReaderFactoryPtr; class AronTypeXMLReaderFactory : - virtual public AronPtrOutputFactory<RapidXmlReaderNode, typenavigator::AronTypeNavigatorPtr> + virtual public AronPtrOutputFactory<RapidXmlReaderNode, typenavigator::NavigatorPtr> { public: AronTypeXMLReaderFactory() = default; - virtual typenavigator::AronTypeNavigatorPtr create(const RapidXmlReaderNode&, const AronPath&) const override; - virtual typenavigator::AronTypeNavigatorPtr createSpecific(const RapidXmlReaderNode&, const AronPath&) const override = 0; + virtual typenavigator::NavigatorPtr create(const RapidXmlReaderNode&, const Path&) const override; + virtual typenavigator::NavigatorPtr createSpecific(const RapidXmlReaderNode&, const Path&) const override = 0; static std::map<std::string, AronGenerateTypeInfoPtr> GetAllKnownGeneratedPublicObjects(); protected: - static typenavigator::AronTypeNavigatorPtr ResolveTypename(const std::string&); + static typenavigator::NavigatorPtr ResolveTypename(const std::string&); protected: static std::stack<AronGenerateTypeInfoPtr> TheObjectWeAreGoingToGenerateNowStack; @@ -76,11 +76,11 @@ namespace armarx { \ public: \ Aron##upperType##TypeXMLReaderFactory() = default; \ - virtual typenavigator::AronTypeNavigatorPtr createSpecific(const RapidXmlReaderNode&, const AronPath&) const override; \ + virtual typenavigator::AronTypeNavigatorPtr createSpecific(const RapidXmlReaderNode&, const Path&) const override; \ }; HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.h b/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.h deleted file mode 100644 index f2ba2a0c573707004c5245d2b60777ccfc3b5a58..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReader.h> - -// ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h> - - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronDataConverter; - typedef std::shared_ptr<AronDataConverter> AronDataConverterPtr; - - class AronDataConverter - { - private: - AronDataConverter() = delete; - - public: - static void ConvertFromReader(AronDataReader&, AronDataWriter&, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure = nullptr); - public: - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.cpp deleted file mode 100644 index df6afd5b61fe220e2c23087edd70f671225963b6..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.cpp +++ /dev/null @@ -1,70 +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/>. - * - * @author Fabian Peller (fabian dot peller at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#include <numeric> - -#include "AronDataRapidXMLWriter.h" - -namespace armarx -{ - namespace aron - { - namespace io - { - // Containers -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - bool AronDataRapidXMLWriter::writeStart##upperType() \ - { \ - return true; \ - } \ - \ - bool AronDataRapidXMLWriter::writeEnd##upperType() \ - { \ - return true; \ - } - - HANDLE_CONTAINER_DATA -#undef RUN_ARON_MACRO - - // Complex Types -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - bool AronDataRapidXMLWriter::write##upperType(const std::vector<int>& dims, const std::string& t, const unsigned char* data) \ - { \ - return true; \ - } - - HANDLE_COMPLEX_DATA -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - bool AronDataRapidXMLWriter::writePrimitive(const lowerType& x) \ - { \ - return true; \ - } - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriterToken.h deleted file mode 100644 index 9e2959e8d17caeb60eb03150773e394633137a32..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriterToken.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// Simox -#include <SimoxUtility/xml.h> - -// Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriterToken.h> - -// ArmarX -#include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronDataRapidXMLWriterToken; - typedef std::shared_ptr<AronDataRapidXMLWriterToken> AronDataRapidXMLWriterTokenPtr; - - class AronDataRapidXMLWriterToken : - virtual public AronDataClassWriterToken<RapidXmlReaderNode, RapidXmlReaderNode> - { - public: - using PointerType = AronDataRapidXMLWriterTokenPtr; - - public: - // constructor - AronDataRapidXMLWriterToken() = delete; - AronDataRapidXMLWriterToken(const AronDataDescriptor desc, const RapidXmlReaderNode& d) : - AronWriterToken<AronDataDescriptor, RapidXmlReaderNode, RapidXmlReaderNode>(desc, d), - AronDataClassWriterToken<RapidXmlReaderNode, RapidXmlReaderNode>(desc, d) - { - - } - - // public member functions - virtual void addElement(const RapidXmlReaderNode& n) override - { - auto desc = this->getDescriptor(); - switch (desc) - { - case eAronDict: - { - break; - } - case eAronList: - { - break; - } - default: - throw exception::AronDataDescriptorNotValidException("AronDataRapidXMLWriterToken", "addElement", "Could not resove a type of a token. Allowed are only containers.", desc); - } - } - - private: - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronReaderToken.h deleted file mode 100644 index 8c607047c398bbfcdd66255bd2a1b81024ac9fab..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronReaderToken.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// Base class -#include <RobotAPI/libraries/aron/aroncore/io/AronReaderWriterToken.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/AronResolver.h> - - -namespace armarx -{ - namespace aron - { - namespace io - { - template<typename AronDescriptorTypename, typename ElementReturnPtrTypename, typename ElementTypename> - class AronReaderToken; - - template<typename AronDescriptorTypename, typename ElementReturnPtrTypename, typename ElementTypename> - using AronReaderTokenPtr = std::shared_ptr<AronReaderToken<AronDescriptorTypename, ElementReturnPtrTypename, ElementTypename>> ; - - template<typename AronDescriptorTypename, typename ElementReturnPtrTypename, typename ElementTypename> - class AronReaderToken : - public AronReaderWriterToken - { - public: - AronReaderToken() = delete; - AronReaderToken(const AronDescriptorTypename& desc, const ElementTypename& e) : - descriptor(desc), element(e), currentIndex(0), maxIndex(0), currentKey("") - { - }; - - bool checkedAllChildren() const - { - return currentIndex >= allKeys.size() && currentIndex >= maxIndex; - } - - AronDescriptorTypename getDescriptor() const - { - return descriptor; - } - - unsigned int getChildrenSize() const - { - return maxIndex; - } - - void setCurrentKey(const std::string& s) - { - if (s.empty()) - { - throw exception::AronException("AronReaderToken", "setCurrentKey", "The passed key is empty."); - } - currentKey = s; - } - - virtual bool currentIsEligableForResolvingKey() const = 0; - std::string resolveCurrentKey() const - { - if (!this->currentIsEligableForResolvingKey()) - { - throw exception::AronException("AronReaderToken", "resolveCurrentKey", "Cant get key of token."); - } - - // check outOfBounds - if (this->currentIndex >= this->maxIndex) - { - throw exception::AronSizeNotValidException("AronReaderToken", "resolveCurrentKey", "Index out of bounds.", this->currentIndex, this->maxIndex); - } - - // ugly workaround - if (this->currentKey == "") // probably in a dict where the caller does not know which keys are there - { - if (this->allKeys.size() == 0) - { - throw exception::AronException("AronReaderToken", "resolveCurrentKey", "The currentKey is not set and the list of all keys is empty!"); - } - return this->allKeys[this->currentIndex]; - } - return this->currentKey; - } - - - virtual ElementReturnPtrTypename getCurrentElement() const = 0; - ElementReturnPtrTypename getCurrentElementAndIncreaseCnt() - { - ElementReturnPtrTypename next = getCurrentElement(); - this->currentIndex++; - return next; - } - - protected: - // members - AronDescriptorTypename descriptor; - ElementTypename element; - - unsigned int currentIndex; - unsigned int maxIndex; - - // dict and object members - std::string currentKey; - std::vector<std::string> allKeys; - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronReaderWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronReaderWriterToken.h deleted file mode 100644 index b887020db836ed7a2336d4c8f016c7a315b90ae4..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronReaderWriterToken.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> - - - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronReaderWriterToken; - typedef std::shared_ptr<AronReaderWriterToken> AronReaderWriterTokenPtr; - - class AronReaderWriterToken - { - public: - AronReaderWriterToken() = default; - - protected: - // TODO: Remove copy from ReaderWriter - const std::string ARON_READER_WRITER_TOKEN_OBJECT_NAME_SLUG = "ARON_OBJECT_NAME"; - const std::string ARON_READER_WRITER_TOKEN_DICT_ACCEPTED_TYPE_SLUG = "ARON_DICT_ACCEPTED_TYPE"; - const std::string ARON_READER_WRITER_TOKEN_LIST_ACCEPTED_TYPE_SLUG = "ARON_LIST_ACCEPTED_TYPE"; - - const std::string ARON_READER_WRITER_TOKEN_NDARRAY_NAME_SLUG = "ARON_NDARRAY_NAME"; - const std::string ARON_READER_WRITER_TOKEN_NDARRAY_DIMENSIONS_SLUG = "ARON_NDARRAY_DIMESIONS"; - const std::string ARON_READER_WRITER_TOKEN_NDARRAY_TYPE_SLUG = "ARON_NDARRAY_TYPE"; - const std::string ARON_READER_WRITER_TOKEN_NDARRAY_DATA_SLUG = "ARON_NDARRAY_DATA"; - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - const std::string ARON_READER_WRITER_TOKEN_##capsType##_TYPENAME_SLUG = "ARON_" + std::string(#capsType) + "_TYPE"; - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReaderWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReaderWriter.h deleted file mode 100644 index 47a78243317b382a4ef7b818ee23dd8a788e0b3a..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReaderWriter.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> - -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronReaderWriter.h> - - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronTypeReaderWriter; - typedef std::shared_ptr<AronTypeReaderWriter> AronTypeReaderWriterPtr; - - class AronTypeReaderWriter : - public AronReaderWriter - { - public: - AronTypeReaderWriter() = default; - - protected: - const std::string ARON_TYPE_READER_WRITER_NDARRAY_NAME_SLUG = "ARON_NDARRAY_NAME"; - const std::string ARON_TYPE_READER_WRITER_NDARRAY_DIMENSIONS_SLUG = "ARON_NDARRAY_DIMESIONS"; - const std::string ARON_TYPE_READER_WRITER_NDARRAY_TYPE_SLUG = "ARON_NDARRAY_TYPE"; - const std::string ARON_TYPE_READER_WRITER_NDARRAY_DATA_SLUG = "ARON_NDARRAY_DATA"; - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - const std::string ARON_TYPE_READER_WRITER_##capsType##_TYPENAME = "ARON_" + std::string(#capsType) + "_TYPE"; - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.h deleted file mode 100644 index 234a546c678bba4bd80efcae19555dd1b5c112b7..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriter.h> - -// ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> - - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronTypeWriterVisitor; - typedef std::shared_ptr<AronTypeWriterVisitor> AronTypeWriterVisitorPtr; - - class AronTypeWriterVisitor : - virtual public AronTypeWriter - { - private: - AronTypeWriterVisitor() = delete; - - public: - static void SetupWriterFromAronTypePtr(AronTypeWriter&, const typenavigator::AronTypeNavigatorPtr&); - static void SetupWriterFromAronTypePtr(AronTypeWriter&, const type::AronTypePtr&); - - public: - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.h deleted file mode 100644 index 29788d39f0f4c73265bb86bdbe0abed33cf635a7..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <stack> - -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReader.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReaderToken.h> - - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronTypeNavigatorReader; - typedef std::shared_ptr<AronTypeNavigatorReader> AronTypeNavigatorReaderPtr; - - class AronTypeNavigatorReader : - virtual public AronTypeClassReader<typenavigator::AronContainerTypeNavigatorPtr, AronTypeNavigatorReaderTokenPtr> - { - public: - using PointerType = AronTypeNavigatorReaderPtr; - - public: - // constructors - AronTypeNavigatorReader() = delete; - AronTypeNavigatorReader(const typenavigator::AronContainerTypeNavigatorPtr& n); - AronTypeNavigatorReader(const type::AronContainerTypePtr& n); - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual int readStart##upperType##Type() override; \ - virtual bool readEnd##upperType##Type() override; \ - - HANDLE_CONTAINER_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual std::pair<std::vector<int>, std::string> read##upperType##Type() override; \ - - HANDLE_COMPLEX_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual void read##upperType##Type() override; \ - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - - private: - typenavigator::AronTypeNavigatorPtr getCurrentAndGoToNext(); - typenavigator::AronTypeNavigatorPtr getCurrent(); - - private: - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReaderToken.h deleted file mode 100644 index 12cca75857b599f5338040e8cca6fe5770ed0076..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReaderToken.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReaderToken.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> - -namespace armarx -{ - namespace aron - { - namespace io - { - // BaseClass - class AronTypeNavigatorReaderToken; - typedef std::shared_ptr<AronTypeNavigatorReaderToken> AronTypeNavigatorReaderTokenPtr; - - class AronTypeNavigatorReaderToken : - virtual public AronTypeClassReaderToken<typenavigator::AronTypeNavigatorPtr, typenavigator::AronContainerTypeNavigatorPtr> - { - public: - using PointerType = AronTypeNavigatorReaderTokenPtr; - - public: - // constructors - AronTypeNavigatorReaderToken() = delete; - AronTypeNavigatorReaderToken(const AronTypeDescriptor desc, const typenavigator::AronContainerTypeNavigatorPtr& type) : - AronReaderToken<AronTypeDescriptor, typenavigator::AronTypeNavigatorPtr, typenavigator::AronContainerTypeNavigatorPtr>(desc, type), - AronTypeClassReaderToken<typenavigator::AronTypeNavigatorPtr, typenavigator::AronContainerTypeNavigatorPtr>(desc, type) - { - switch (descriptor) - { - case eAronObjectType: - { - allKeys = typenavigator::AronObjectTypeNavigator::DynamicCast(element)->getAllKeys(); - maxIndex = allKeys.size(); - break; - } - case eAronDictType: - { - maxIndex = 1; - break; - } - case eAronTupleType: - { - maxIndex = typenavigator::AronTupleTypeNavigator::DynamicCast(element)->childrenSize(); - break; - } - case eAronListType: - { - maxIndex = 1; - break; - } - default: - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorReaderToken", "AronTypeNavigatorReaderToken", "Received an invalid instance for a reader token.", desc); - } - } - - std::string getObjectName() const override - { - if(descriptor == eAronObjectType) - { - const typenavigator::AronObjectTypeNavigatorPtr next = typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck(getCurrentElement()); - return next->getObjectName(); - } - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorReaderToken", "AronTypeNavigatorReaderToken", "Could not get object nme of a non-object token", descriptor); - } - - AronTypeDescriptor getTypeOfNextElement() const override - { - const typenavigator::AronTypeNavigatorPtr next = getCurrentElement(); - return next->getDescriptor(); - } - - typenavigator::AronTypeNavigatorPtr getCurrentElement() const override - { - switch (descriptor) - { - case eAronObjectType: - { - typenavigator::AronObjectTypeNavigatorPtr casted = typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck(element); - typenavigator::AronTypeNavigatorPtr ret = casted->getAcceptedType(resolveCurrentKey()); - return ret; - } - case eAronDictType: - { - typenavigator::AronDictTypeNavigatorPtr casted = typenavigator::AronDictTypeNavigator::DynamicCastAndCheck(element); - typenavigator::AronTypeNavigatorPtr ret = casted->getAcceptedType(); - return ret; - } - case eAronTupleType: - { - typenavigator::AronTupleTypeNavigatorPtr casted = typenavigator::AronTupleTypeNavigator::DynamicCastAndCheck(element); - typenavigator::AronTypeNavigatorPtr ret = casted->getAcceptedType(currentIndex); - return ret; - } - case eAronListType: - { - typenavigator::AronListTypeNavigatorPtr casted = typenavigator::AronListTypeNavigator::DynamicCastAndCheck(element); - typenavigator::AronTypeNavigatorPtr ret = casted->getAcceptedType(); - return ret; - } - default: - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); - } - } - - private: - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReaderToken.h deleted file mode 100644 index 86111ca6c43b028d9a36e8e953f461e6cc19cd21..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReaderToken.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// Simox -#include <SimoxUtility/json.h> - -// Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReaderToken.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronResolver.h> - -namespace armarx -{ - namespace aron - { - namespace io - { - // BaseClass - class AronTypeNlohmannJSONReaderToken; - typedef std::shared_ptr<AronTypeNlohmannJSONReaderToken> AronTypeNlohmannJSONReaderTokenPtr; - - class AronTypeNlohmannJSONReaderToken : - virtual public AronTypeClassReaderToken<nlohmann::json, nlohmann::json> - { - public: - using PointerType = AronTypeNlohmannJSONReaderTokenPtr; - - public: - // constructors - AronTypeNlohmannJSONReaderToken() = delete; - AronTypeNlohmannJSONReaderToken(const AronTypeDescriptor desc, const nlohmann::json& type) : - AronReaderToken<AronTypeDescriptor, nlohmann::json, nlohmann::json>(desc, type), - AronTypeClassReaderToken<nlohmann::json, nlohmann::json>(desc, type) - { - switch (descriptor) - { - case eAronObjectType: - { - for (auto it = type.begin(); it != type.end(); ++it) - { - if ( - it.key() == ARON_READER_WRITER_TOKEN_OBJECT_NAME_SLUG || -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ -it.key() == ARON_READER_WRITER_TOKEN_##capsType##_TYPENAME_SLUG || - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - it.key() == ARON_READER_WRITER_TOKEN_DICT_ACCEPTED_TYPE_SLUG || - it.key() == ARON_READER_WRITER_TOKEN_LIST_ACCEPTED_TYPE_SLUG || - it.key() == ARON_READER_WRITER_TOKEN_NDARRAY_NAME_SLUG || - it.key() == ARON_READER_WRITER_TOKEN_NDARRAY_DIMENSIONS_SLUG || - it.key() == ARON_READER_WRITER_TOKEN_NDARRAY_TYPE_SLUG - ) - { - continue; - } - - allKeys.push_back(it.key()); - } - maxIndex = allKeys.size(); - break; - } - case eAronDictType: - { - maxIndex = 1; - break; - } - case eAronTupleType: - { - maxIndex = type.size(); - break; - } - case eAronListType: - { - maxIndex = 1; - break; - } - default: - throw exception::AronTypeDescriptorNotValidException("AronTypeNlohmannJSONReaderToken", "AronTypeNlohmannJSONReaderToken", "Received an invalid instance for a reader token.", desc); - } - } - - std::string getObjectName() const override - { - if (descriptor == eAronObjectType) - { - return element[ARON_READER_WRITER_TOKEN_OBJECT_NAME_SLUG]; - } - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorReaderToken", "AronTypeNavigatorReaderToken", "Could not get object nme of a non-object token", descriptor); - } - - AronTypeDescriptor getTypeOfNextElement() const override - { - const nlohmann::json next = getCurrentElement(); - - if (next.is_object()) - { - if (next.find(ARON_READER_WRITER_TOKEN_DICT_ACCEPTED_TYPE_SLUG) != next.end()) - { - return eAronDictType; - } - if (next.find(ARON_READER_WRITER_TOKEN_LIST_ACCEPTED_TYPE_SLUG) != next.end()) - { - return eAronListType; - } - if (next.find(ARON_READER_WRITER_TOKEN_NDARRAY_NAME_SLUG) != next.end()) - { -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - if (next[ARON_READER_WRITER_TOKEN_NDARRAY_NAME_SLUG] == std::string(#upperType)) \ - { \ - return eAron##upperType##Type; \ - } - - HANDLE_COMPLEX_TYPES -#undef RUN_ARON_MACRO - throw exception::AronException("AronTypeNlohmannJSONReaderToken", "getTypeOfNextElement", "Could not determine the type of an nlohmann::json object. Found indicator of NDArray but could not resolve real type. Found JSON: " + next[ARON_READER_WRITER_TOKEN_NDARRAY_NAME_SLUG].dump(2)); - } - return eAronObjectType; - } - if (next.is_array()) - { - return eAronTupleType; - } - if (next.is_string()) - { -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - if (next == ARON_READER_WRITER_TOKEN_##capsType##_TYPENAME_SLUG) \ - { \ - return eAron##upperType##Type; \ - } - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - } - throw exception::AronException("AronTypeNlohmannJSONReaderToken", "getTypeOfNextElement", "Could not determine the type of an nlohmann::json object. Could not convert to AronTypeDescriptor enum. Found JSON: " + next.dump(2)); - } - - nlohmann::json getCurrentElement() const override - { - switch (descriptor) - { - case eAronObjectType: - { - nlohmann::json ret = element[resolveCurrentKey()]; - return ret; - } - case eAronDictType: - { - nlohmann::json ret = element[ARON_READER_WRITER_TOKEN_DICT_ACCEPTED_TYPE_SLUG]; - return ret; - } - case eAronTupleType: - { - nlohmann::json ret = element[currentIndex]; - return ret; - } - case eAronListType: - { - nlohmann::json ret = element[ARON_READER_WRITER_TOKEN_LIST_ACCEPTED_TYPE_SLUG]; - return ret; - } - default: - throw exception::AronTypeDescriptorNotValidException("AronTypeNlohmannJSONReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); - } - } - - private: - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriterToken.h deleted file mode 100644 index dd1fc3caff7d836ec136f46797539af9f4df14f8..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriterToken.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriterToken.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronTypeNavigatorWriterToken; - typedef std::shared_ptr<AronTypeNavigatorWriterToken> AronTypeNavigatorWriterTokenPtr; - - class AronTypeNavigatorWriterToken : - virtual public AronTypeClassWriterToken<typenavigator::AronContainerTypeNavigatorPtr, typenavigator::AronTypeNavigatorPtr> - { - public: - using PointerType = AronTypeNavigatorWriterTokenPtr; - - public: - // constructor - AronTypeNavigatorWriterToken() = delete; - AronTypeNavigatorWriterToken(const AronTypeDescriptor desc, const typenavigator::AronContainerTypeNavigatorPtr& t) : - AronWriterToken<AronTypeDescriptor, typenavigator::AronContainerTypeNavigatorPtr, typenavigator::AronTypeNavigatorPtr>(desc, t), - AronTypeClassWriterToken<typenavigator::AronContainerTypeNavigatorPtr, typenavigator::AronTypeNavigatorPtr>(desc, t) - { - } - - // virtual member functions - virtual void addElement(const typenavigator::AronTypeNavigatorPtr& n) override - { - switch (descriptor) - { - case eAronDictType: - { - typenavigator::AronDictTypeNavigatorPtr casted = typenavigator::AronDictTypeNavigator::DynamicCastAndCheck(element); - casted->setAcceptedType(n); - break; - } - case eAronListType: - { - typenavigator::AronListTypeNavigatorPtr casted = typenavigator::AronListTypeNavigator::DynamicCastAndCheck(element); - casted->setAcceptedType(n); - break; - } - case eAronObjectType: - { - typenavigator::AronObjectTypeNavigatorPtr casted = typenavigator::AronObjectTypeNavigator::DynamicCastAndCheck(element); - casted->addAcceptedType(currentKey, n); - break; - } - case eAronTupleType: - { - typenavigator::AronTupleTypeNavigatorPtr casted = typenavigator::AronTupleTypeNavigator::DynamicCastAndCheck(element); - casted->addAcceptedType(n); - currentIndex++; - break; - } - default: - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorWriterToken", "addElement", "Could not resove a type of a navigator. Allowed are only containers. The path was: " + getElement()->pathToString(), descriptor); - } - } - - virtual void setName(const std::string& n) override - { - if (descriptor != AronTypeDescriptor::eAronObjectType) - { - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorWriterToken", "setName", "Cant set the name of a non-object token. The path was: " + getElement()->pathToString(), descriptor); - } - typenavigator::AronObjectTypeNavigatorPtr casted = typenavigator::AronObjectTypeNavigator::DynamicCast(element); - casted->setObjectName(n); - } - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.h deleted file mode 100644 index 8241d0c31ffc4145d7af67c7bd225fd294cef7d5..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD / STL -#include <memory> -#include <stack> -#include <sstream> - -// Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriterToken.h> - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronTypeNlohmannJSONWriter : - virtual public AronTypeClassWriter<nlohmann::json, AronTypeNlohmannJSONWriterTokenPtr> - { - public: - AronTypeNlohmannJSONWriter() = default; - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool writeStart##upperType##Type() override; \ - virtual bool writeEnd##upperType##Type() override; - - HANDLE_CONTAINER_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type(const std::vector<int>&, const std::string&) override; \ - - HANDLE_COMPLEX_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type() override; - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - - private: - - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.cpp deleted file mode 100644 index 4dcf9562ff8cfbe2bc7778b452cc7e7259c08992..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.cpp +++ /dev/null @@ -1,71 +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/>. - * - * @author Fabian Peller (fabian dot peller at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#include "AronTypeRapidXMLWriter.h" - -namespace armarx -{ - namespace aron - { - namespace io - { - bool AronTypeXMLWriter::writeStartDictType() - { - return true; - } - - bool AronTypeXMLWriter::writeEndDictType() - { - return true; - } - - bool AronTypeXMLWriter::writeStartListType() - { - return true; - } - - bool AronTypeXMLWriter::writeEndListType() - { - return true; - } - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - bool AronTypeXMLWriter::write##upperType##Type(const std::vector<int>& d, const std::string& t) \ - { \ - return true; \ - } - - HANDLE_COMPLEX_TYPES -#undef RUN_ARON_MACRO - -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - bool AronTypeXMLWriter::write##upperType##Type() \ - { \ - return true; \ - } - - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriterToken.h deleted file mode 100644 index c33498ad83af9d074ea62235ab5a974c09be354e..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriterToken.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// Simox -#include <SimoxUtility/xml.h> - -// Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriterToken.h> - -// ArmarX -#include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> - -namespace armarx -{ - namespace aron - { - namespace io - { - class AronTypeRapidXMLWriterToken; - typedef std::shared_ptr<AronTypeRapidXMLWriterToken> AronTypeRapidXMLWriterTokenPtr; - - class AronTypeRapidXMLWriterToken : - virtual public AronTypeClassWriterToken<RapidXmlReaderNode, RapidXmlReaderNode> - { - public: - using PointerType = AronTypeRapidXMLWriterTokenPtr; - - public: - // constructor - AronTypeRapidXMLWriterToken() = delete; - AronTypeRapidXMLWriterToken(const AronTypeDescriptor desc, const RapidXmlReaderNode& t) : - AronWriterToken<AronTypeDescriptor, RapidXmlReaderNode, RapidXmlReaderNode>(desc, t), - AronTypeClassWriterToken<RapidXmlReaderNode, RapidXmlReaderNode>(desc, t) - { - } - - // virtual member functions - virtual void addElement(const RapidXmlReaderNode& n) override - { - auto desc = getDescriptor(); - switch (desc) - { - case eAronDictType: - { - break; - } - case eAronListType: - { - break; - } - case eAronObjectType: - { - break; - } - case eAronTupleType: - { - break; - } - default: - throw exception::AronTypeDescriptorNotValidException("AronTypeRapidXMLWriterToken", "addElement", "Could not resove a type of a navigator. Allowed are only containers.", desc); - } - } - - // name functions - void setName(const std::string& n) override - { - auto desc = getDescriptor(); - if (desc != AronTypeDescriptor::eAronObjectType) - { - throw exception::AronTypeDescriptorNotValidException("AronTypeRapidXMLWriterToken", "setName", "Cant set the name of a non-object token.", desc); - } - } - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/AronWriterToken.h deleted file mode 100644 index 271d18054bb6631078d9eec67b1b8955255bb085..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronWriterToken.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -* This file is part of ArmarX. -* -* 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/>. -* -* @author Fabian Peller (fabian dot peller at kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#pragma once - -// STD/STL -#include <memory> -#include <string> - -// Base class -#include <RobotAPI/libraries/aron/aroncore/io/AronReaderWriterToken.h> - -// ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronException.h> - - - -namespace armarx -{ - namespace aron - { - namespace io - { - template<typename AronDescriptorTypename, typename ElementTypename, typename ElementAddTypename> - class AronWriterToken; - - template<typename AronDescriptorTypename, typename ElementTypename, typename ElementAddTypename> - using AronWriterTokenPtr = std::shared_ptr<AronWriterToken<AronDescriptorTypename, ElementTypename, ElementAddTypename>> ; - - template<typename AronDescriptorTypename, typename ElementTypename, typename ElementAddTypename> - class AronWriterToken : - public AronReaderWriterToken - { - public: - AronWriterToken() = delete; - AronWriterToken(const AronDescriptorTypename& desc, const ElementTypename& e) : - descriptor(desc), element(e), currentIndex(0), currentKey("") - { - }; - - // virtual definitions - virtual void addElement(const ElementAddTypename&) = 0; - virtual std::string toElementAccessor() const = 0; - - void setCurrentKey(const std::string& s) - { - if (s.empty()) - { - throw exception::AronException("AronWriterToken", "setCurrentKey", "The passed key is empty."); - } - currentKey = s; - } - - virtual ElementTypename getElement() const - { - return element; - } - - virtual AronDescriptorTypename getDescriptor() const - { - return descriptor; - } - - protected: - // members - AronDescriptorTypename descriptor; - ElementTypename element; - - // current index - unsigned int currentIndex; - - // current key - std::string currentKey; - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/Data.h b/source/RobotAPI/libraries/aron/aroncore/io/Data.h new file mode 100644 index 0000000000000000000000000000000000000000..87d20324fc2e461e19d3c4a358d085c1459086ee --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/io/Data.h @@ -0,0 +1,58 @@ +/* +* This file is part of ArmarX. +* +* 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/>. +* +* @author Fabian Peller (fabian dot peller at kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#pragma once + +// STD/STL +#include <memory> +#include <string> + +// ArmarX +#include <ArmarXCore/core/exceptions/Exception.h> + +#include <RobotAPI/libraries/aron/aroncore/Config.h> + + + +namespace armarx::aron::io +{ + class Data + { + private: + Data() = delete; + + public: + // TODO: Remove copy from ReaderWriter + static constexpr char* READER_WRITER_OBJECT_NAME_SLUG = "ARON_OBJECT_NAME"; + static constexpr char* READER_WRITER_DICT_ACCEPTED_TYPE_SLUG = "ARON_DICT_ACCEPTED_TYPE"; + static constexpr char* READER_WRITER_LIST_ACCEPTED_TYPE_SLUG = "ARON_LIST_ACCEPTED_TYPE"; + + static constexpr char* READER_WRITER_NDARRAY_NAME_SLUG = "ARON_NDARRAY_NAME"; + static constexpr char* READER_WRITER_NDARRAY_DIMENSIONS_SLUG = "ARON_NDARRAY_DIMESIONS"; + static constexpr char* READER_WRITER_NDARRAY_TYPE_SLUG = "ARON_NDARRAY_TYPE"; + static constexpr char* READER_WRITER_NDARRAY_DATA_SLUG = "ARON_NDARRAY_DATA"; + +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + static constexpr char* READER_WRITER_##capsType##_TYPENAME_SLUG = #capsType; + + HANDLE_PRIMITIVE_TYPES +#undef RUN_ARON_MACRO + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/ReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/ReaderToken.h new file mode 100644 index 0000000000000000000000000000000000000000..0e8a4db2a5fe1a7e93b8be9e0b6a7d10b382a298 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/io/ReaderToken.h @@ -0,0 +1,123 @@ +/* +* This file is part of ArmarX. +* +* 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/>. +* +* @author Fabian Peller (fabian dot peller at kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#pragma once + +// STD/STL +#include <memory> +#include <string> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/Resolver.h> +#include <RobotAPI/libraries/aron/aroncore/io/Data.h> + + +namespace armarx::aron::io +{ + template<typename AronDescriptorTypename, typename ElementReturnPtrTypename, typename ElementTypename> + class ReaderToken; + + template<typename AronDescriptorTypename, typename ElementReturnPtrTypename, typename ElementTypename> + using ReaderTokenPtr = std::shared_ptr<ReaderToken<AronDescriptorTypename, ElementReturnPtrTypename, ElementTypename>> ; + + template<typename AronDescriptorTypename, typename ElementReturnPtrTypename, typename ElementTypename> + class ReaderToken + { + public: + ReaderToken() = delete; + ReaderToken(const AronDescriptorTypename& desc, const ElementTypename& e) : + descriptor(desc), element(e), currentIndex(0), maxIndex(0), currentKey("") + { + }; + + bool checkedAllChildren() const + { + return currentIndex >= allKeys.size() && currentIndex >= maxIndex; + } + + AronDescriptorTypename getDescriptor() const + { + return descriptor; + } + + unsigned int getChildrenSize() const + { + return maxIndex; + } + + void setCurrentKey(const std::string& s) + { + if (s.empty()) + { + throw exception::AronException("AronReaderToken", "setCurrentKey", "The passed key is empty."); + } + currentKey = s; + } + + virtual bool currentIsEligableForResolvingKey() const = 0; + std::string resolveCurrentKey() const + { + if (!this->currentIsEligableForResolvingKey()) + { + throw exception::AronException("AronReaderToken", "resolveCurrentKey", "Cant get key of token."); + } + + // check outOfBounds + if (this->currentIndex >= this->maxIndex) + { + throw exception::SizeNotValidException("AronReaderToken", "resolveCurrentKey", "Index out of bounds.", this->currentIndex, this->maxIndex); + } + + // ugly workaround + if (this->currentKey == "") // probably in a dict where the caller does not know which keys are there + { + if (this->allKeys.size() == 0) + { + throw exception::AronException("AronReaderToken", "resolveCurrentKey", "The currentKey is not set and the list of all keys is empty!"); + } + return this->allKeys[this->currentIndex]; + } + return this->currentKey; + } + + + virtual ElementReturnPtrTypename getCurrentElement() const = 0; + ElementReturnPtrTypename getCurrentElementAndIncreaseCnt() + { + ElementReturnPtrTypename next = getCurrentElement(); + this->currentIndex++; + return next; + } + + protected: + // members + AronDescriptorTypename descriptor; + ElementTypename element; + + unsigned int currentIndex; + unsigned int maxIndex; + + // dict and object members + std::string currentKey; + std::vector<std::string> allKeys; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/WriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/WriterToken.h new file mode 100644 index 0000000000000000000000000000000000000000..be17968da1e9ecfb2d56b10d312ca134c1ab0f39 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/io/WriterToken.h @@ -0,0 +1,85 @@ +/* +* This file is part of ArmarX. +* +* 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/>. +* +* @author Fabian Peller (fabian dot peller at kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#pragma once + +// STD/STL +#include <memory> +#include <string> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/io/Data.h> + + +namespace armarx::aron::io +{ + template<typename AronDescriptorTypename, typename ElementTypename, typename ElementAddTypename> + class WriterToken; + + template<typename AronDescriptorTypename, typename ElementTypename, typename ElementAddTypename> + using WriterTokenPtr = std::shared_ptr<WriterToken<AronDescriptorTypename, ElementTypename, ElementAddTypename>> ; + + template<typename AronDescriptorTypename, typename ElementTypename, typename ElementAddTypename> + class WriterToken + { + public: + WriterToken() = delete; + WriterToken(const AronDescriptorTypename& desc, const ElementTypename& e) : + descriptor(desc), element(e), currentIndex(0), currentKey("") + { + }; + + // virtual definitions + virtual void addElement(const ElementAddTypename&) = 0; + virtual std::string toElementAccessor() const = 0; + + void setCurrentKey(const std::string& s) + { + if (s.empty()) + { + throw exception::AronException("AronWriterToken", "setCurrentKey", "The passed key is empty."); + } + currentKey = s; + } + + virtual ElementTypename getElement() const + { + return element; + } + + virtual AronDescriptorTypename getDescriptor() const + { + return descriptor; + } + + protected: + // members + AronDescriptorTypename descriptor; + ElementTypename element; + + // current index + unsigned int currentIndex; + + // current key + std::string currentKey; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReader.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/Reader.h similarity index 73% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReader.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/Reader.h index 38b9c9123ed1dc858dfc6bd2970a4a8e72f8aa0e..1e124ed12fb6b18f8489a51f7764f30a0a6bdb36 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/Reader.h @@ -23,28 +23,21 @@ // STD/STL #include <memory> #include <string> - -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReaderWriter.h> +#include <vector> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> -namespace armarx +namespace armarx::aron::dataIO { - namespace aron - { - namespace io - { - class AronDataReader; - typedef std::shared_ptr<AronDataReader> AronDataReaderPtr; + class Reader; + typedef std::shared_ptr<Reader> AronDataReaderPtr; - class AronDataReader : - public AronDataReaderWriter + class Reader { public: - AronDataReader() = default; + Reader() = default; #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ virtual int readStart##upperType() = 0; \ @@ -63,7 +56,7 @@ namespace armarx #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ virtual void readPrimitive(lowerType&) = 0; \ - HANDLE_PRIMITIVE_TYPES + HANDLE_PRIMITIVE_DATA #undef RUN_ARON_MACRO template<class T> @@ -78,8 +71,6 @@ namespace armarx virtual bool readKey(const std::string&) = 0; // Helper functions - virtual AronDataDescriptor getTypeOfNextAron(const AronTypeDescriptor) const = 0; + virtual data::Descriptor getTypeOfNextAron(const type::Descriptor) const = 0; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/dataIO/ReaderWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/ReaderWriter.h new file mode 100644 index 0000000000000000000000000000000000000000..a6a42098d8a198c7aa1ace6751cce3e7130c4cfa --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/ReaderWriter.h @@ -0,0 +1,22 @@ +/* +* This file is part of ArmarX. +* +* 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/>. +* +* @author Fabian Peller (fabian dot peller at kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#pragma once + diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/Writer.h similarity index 63% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/Writer.h index c7d204840e15a42e18d05b7387eaa7d56c11e171..a2c53ecc8557afbcbfcf01a058d93d819d418df7 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/Writer.h @@ -24,52 +24,42 @@ #include <memory> #include <string> -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReaderWriter.h> - // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> -namespace armarx +namespace armarx::aron::dataIO { - namespace aron - { - namespace io - { - class AronDataWriter; - typedef std::shared_ptr<AronDataWriter> AronDataWriterPtr; + class Writer; + typedef std::shared_ptr<Writer> WriterPtr; - class AronDataWriter : - public AronDataReaderWriter + class Writer { public: - AronDataWriter() = default; + Writer() = default; #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ virtual bool writeStart##upperType() = 0; \ - virtual bool writeEnd##upperType() = 0; \ + virtual bool writeEnd##upperType() = 0; HANDLE_CONTAINER_DATA #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType(const std::vector<int>&, const std::string&, const unsigned char*) = 0; \ + virtual bool writeStart##upperType(const std::vector<int>&, const std::string&) = 0; \ + virtual bool writeEnd##upperType(const unsigned char*) = 0; HANDLE_COMPLEX_DATA #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool writePrimitive(const lowerType&) = 0; \ + virtual bool writePrimitive(const lowerType&) = 0; - HANDLE_PRIMITIVE_TYPES + HANDLE_PRIMITIVE_DATA #undef RUN_ARON_MACRO virtual bool writeKey(const std::string&) = 0; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/converter/Converter.cpp similarity index 80% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/converter/Converter.cpp index c552a0c87cc2227b53f1dcce42c7b2cc77cf03a3..bff144b141b29c2293c4159f3658005e20983570 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataConverter/AronDataConverter.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/converter/Converter.cpp @@ -23,9 +23,9 @@ #include <numeric> // Header -#include "AronDataConverter.h" +#include "Converter.h" -#include <RobotAPI/libraries/aron/aroncore/AronDebug.h> +#include <RobotAPI/libraries/aron/aroncore/Debug.h> @@ -35,10 +35,10 @@ namespace armarx { namespace io { - void AronDataConverter::ConvertFromReader(AronDataReader& reader, AronDataWriter& writer, const aron::typenavigator::AronTypeNavigatorPtr& expectedStructure) + void Converter::ConvertFromReader(Reader& reader, AronDataWriter& writer, const aron::typenavigator::NavigatorPtr& expectedStructure) { - AronTypeDescriptor t_desc = expectedStructure != nullptr ? expectedStructure->getDescriptor() : eAronUnknownType; - AronDataDescriptor desc = reader.getTypeOfNextAron(t_desc); + type::Descriptor t_desc = expectedStructure != nullptr ? expectedStructure->getDescriptor() : eAronUnknownType; + data::Descriptor desc = reader.getTypeOfNextAron(t_desc); switch (desc) { case eAronDict: @@ -46,7 +46,7 @@ namespace armarx int elements = reader.readStartDict(); writer.writeStartDict(); - typenavigator::AronTypeNavigatorPtr childType = nullptr; + typenavigator::NavigatorPtr childType = nullptr; if (t_desc == eAronDictType) { auto t = typenavigator::AronDictTypeNavigator::DynamicCast(expectedStructure); @@ -64,7 +64,7 @@ namespace armarx childType = t->getAcceptedType(key); } - AronDataConverter::ConvertFromReader(reader, writer, childType); + Converter::ConvertFromReader(reader, writer, childType); } writer.writeEndDict(); @@ -77,7 +77,7 @@ namespace armarx int elements = reader.readStartList(); writer.writeStartList(); - typenavigator::AronTypeNavigatorPtr childType = nullptr; + typenavigator::NavigatorPtr childType = nullptr; if (t_desc == eAronListType) { auto t = typenavigator::AronListTypeNavigator::DynamicCast(expectedStructure); @@ -92,7 +92,7 @@ namespace armarx childType = t->getAcceptedType(i); } - AronDataConverter::ConvertFromReader(reader, writer, childType); + Converter::ConvertFromReader(reader, writer, childType); } writer.writeEndList(); @@ -127,7 +127,7 @@ case eAron##upperType: \ default: { - throw exception::AronDataDescriptorNotValidException("LegacyAronDataReader", "SetupReaderAndGetResult", "Data-Type could not be resolved", desc); + throw exception::DescriptorNotValidException("LegacyAronDataReader", "SetupReaderAndGetResult", "Data-Type could not be resolved", desc); } } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReaderWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/converter/Converter.h similarity index 51% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReaderWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/converter/Converter.h index e2d92fb3082a416c6867ce98870935cc94a3a4bf..1c2c1775bb6382f6a49934720fbc7ccef50cd5bb 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReaderWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/converter/Converter.h @@ -25,32 +25,25 @@ #include <string> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> - #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronReaderWriter.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/Reader.h> -namespace armarx +namespace armarx::aron::dataIO { - namespace aron - { - namespace io - { - class AronDataReaderWriter; - typedef std::shared_ptr<AronDataReaderWriter> AronDataReaderWriterPtr; + class Converter; + typedef std::shared_ptr<Converter> ConverterPtr; - class AronDataReaderWriter : - public AronReaderWriter - { - public: - AronDataReaderWriter() = default; + class Converter + { + private: + Converter() = delete; - protected: - const std::string ARON_DATA_READER_WRITER_NDARRAY_DIMENSIONS_SLUG = "ARON_NDARRAY_DIMESIONS"; - const std::string ARON_DATA_READER_WRITER_NDARRAY_TYPE_SLUG = "ARON_NDARRAY_TYPE"; - const std::string ARON_DATA_READER_WRITER_NDARRAY_DATA_SLUG = "ARON_NDARRAY_DATA"; - }; - } - } + public: + static void ConvertFromReader(dataIO::Reader&, dataIO::Writer&, const aron::typenavigator::NavigatorPtr& expectedStructure = nullptr); + public: + }; } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReader.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/Reader.h similarity index 92% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReader.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/Reader.h index 16fdc8c3712e756e4b65ff8d767e863eb27c56e9..a197af85b82be3e6b8c8df0643dc2250485efcab 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/Reader.h @@ -26,7 +26,7 @@ #include <stack> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/Reader.h> @@ -44,7 +44,7 @@ namespace armarx template <typename InputTypename, typename TokenPtrTypename> class AronDataClassReader : - virtual public AronDataReader + virtual public Reader { public: AronDataClassReader() = delete; @@ -68,7 +68,7 @@ namespace armarx return true; } - AronDataDescriptor getTypeOfNextAron(const AronTypeDescriptor hint) const override + data::Descriptor getTypeOfNextAron(const type::Descriptor hint) const override { if (stack.empty()) { diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/ReaderToken.h similarity index 73% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReaderToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/ReaderToken.h index 472551a1d2e5ae0cfffefd75645c24cb35599ed4..7ef36c67648922dce48e481aa8f18afab593335c 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReaderToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/ReaderToken.h @@ -25,11 +25,11 @@ #include <string> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronReaderToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/ReaderToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> @@ -47,7 +47,7 @@ namespace armarx template<typename ElementReturnPtrTypename, typename ElementAddTypename> class AronDataClassReaderToken : - virtual public AronReaderToken<AronDataDescriptor, ElementReturnPtrTypename, ElementAddTypename> + virtual public ReaderToken<data::Descriptor, ElementReturnPtrTypename, ElementAddTypename> { public: using PointerType = AronDataClassReaderTokenPtr<ElementReturnPtrTypename, ElementAddTypename>; @@ -55,20 +55,20 @@ namespace armarx public: // constructors AronDataClassReaderToken() = delete; - AronDataClassReaderToken(const AronDataDescriptor desc, const ElementAddTypename& data) : - AronReaderToken<AronDataDescriptor, ElementReturnPtrTypename, ElementAddTypename>(desc, data) + AronDataClassReaderToken(const data::Descriptor desc, const ElementAddTypename& data) : + ReaderToken<data::Descriptor, ElementReturnPtrTypename, ElementAddTypename>(desc, data) { } bool currentIsEligableForResolvingKey() const override { - if (this->descriptor == AronDataDescriptor::eAronDict) + if (this->descriptor == data::Descriptor::eAronDict) { return true; } return false; } - virtual AronDataDescriptor getTypeOfNextElement(const AronTypeDescriptor) const = 0; + virtual data::Descriptor getTypeOfNextElement(const type::Descriptor) const = 0; private: }; } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.cpp b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReader.cpp similarity index 79% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReader.cpp index 36e59e623fd1a669b73f2d7291d6dfd68828e279..3b6e16173cc298dc100eeb57f5d7913bc3537ccf 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReader.cpp @@ -23,12 +23,12 @@ #include <numeric> // Header -#include "AronDataNavigatorReader.h" +#include "NavigatorReader.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.h> @@ -45,12 +45,12 @@ namespace armarx AronDataNavigatorReader::AronDataNavigatorReader(const data::AronContainerPtr& n) : AronDataClassReader<datanavigator::AronContainerDataNavigatorPtr, AronDataNavigatorReaderTokenPtr>( - datanavigator::AronContainerDataNavigator::DynamicCast(datanavigator::AronDataNavigator::FromAronData(n)) + datanavigator::AronContainerDataNavigator::DynamicCast(datanavigator::Navigator::FromAronData(n)) ) { } - datanavigator::AronDataNavigatorPtr AronDataNavigatorReader::getCurrentAndGoToNext() + datanavigator::NavigatorPtr AronDataNavigatorReader::getCurrentAndGoToNext() { if (!readInitialStart) { @@ -61,7 +61,7 @@ namespace armarx return lastToken->getCurrentElementAndIncreaseCnt(); } - datanavigator::AronDataNavigatorPtr AronDataNavigatorReader::getCurrent() + datanavigator::NavigatorPtr AronDataNavigatorReader::getCurrent() { if (!readInitialStart) { @@ -77,9 +77,9 @@ namespace armarx { \ datanavigator::AronDataNavigatorPtr current_nav = getCurrentAndGoToNext(); \ auto desc = current_nav->getDescriptor(); \ - if (desc != AronDataDescriptor::eAron##upperType) \ + if (desc != data::Descriptor::eAron##upperType) \ { \ - throw exception::AronDataDescriptorNotValidException("AronDataNavigatorReader", "readStart" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ + throw exception::data::DescriptorNotValidException("NavigatorReader", "readStart" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ return false; \ } \ datanavigator::Aron##upperType##DataNavigatorPtr current_nav_casted = datanavigator::Aron##upperType##DataNavigator::DynamicCast(current_nav); \ @@ -93,9 +93,9 @@ namespace armarx { \ AronDataNavigatorReaderTokenPtr token = stack.top(); \ auto desc = token->getDescriptor(); \ - if (desc != AronDataDescriptor::eAron##upperType) \ + if (desc != data::Descriptor::eAron##upperType) \ { \ - throw exception::AronDataDescriptorNotValidException("AronDataNavigatorReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ + throw exception::data::DescriptorNotValidException("NavigatorReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ return false; \ } \ \ @@ -123,7 +123,7 @@ namespace armarx { \ if(data == NULL) \ { \ - throw exception::AronException("AronDataNavigatorReader", "readEnd" + std::string(#upperType), "The corresponding data pointer of an complex aron ptr is NULL."); \ + throw exception::AronException("NavigatorReader", "readEnd" + std::string(#upperType), "The corresponding data pointer of an complex aron ptr is NULL."); \ } \ datanavigator::AronDataNavigatorPtr nav = getCurrentAndGoToNext(); \ datanavigator::AronNDArrayDataNavigatorPtr casted = datanavigator::AronNDArrayDataNavigator::DynamicCast(nav); \ diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReader.h similarity index 84% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReader.h index 80ae71d9955f8375a745d78c03084d4277bde873..b063624a5cab4be4a228bdd8101c16a486855cc3 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReader.h @@ -25,11 +25,11 @@ #include <stack> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/Reader.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReaderToken.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReaderToken.h> namespace armarx @@ -74,8 +74,8 @@ namespace armarx #undef RUN_ARON_MACRO private: - datanavigator::AronDataNavigatorPtr getCurrent(); - datanavigator::AronDataNavigatorPtr getCurrentAndGoToNext(); + datanavigator::NavigatorPtr getCurrent(); + datanavigator::NavigatorPtr getCurrentAndGoToNext(); private: }; diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReaderToken.h similarity index 76% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReaderToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReaderToken.h index 3dd510087246330e2a23e3668502f0eb99d09286..bab991ed76f834e08800fde76c096002e2638618 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReaderToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/NavigatorReaderToken.h @@ -25,11 +25,11 @@ #include <string> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReaderToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/ReaderToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> namespace armarx { @@ -50,8 +50,8 @@ namespace armarx public: // constructors AronDataNavigatorReaderToken() = delete; - AronDataNavigatorReaderToken(const AronDataDescriptor desc, const datanavigator::AronContainerDataNavigatorPtr& data) : - AronReaderToken<AronDataDescriptor, datanavigator::AronDataNavigatorPtr, datanavigator::AronContainerDataNavigatorPtr>(desc, data), + AronDataNavigatorReaderToken(const data::Descriptor desc, const datanavigator::AronContainerDataNavigatorPtr& data) : + ReaderToken<data::Descriptor, datanavigator::AronDataNavigatorPtr, datanavigator::AronContainerDataNavigatorPtr>(desc, data), AronDataClassReaderToken<datanavigator::AronDataNavigatorPtr, datanavigator::AronContainerDataNavigatorPtr>(desc, data) { switch (descriptor) @@ -68,11 +68,11 @@ namespace armarx break; } default: - throw exception::AronDataDescriptorNotValidException("AronDataNavigatorReaderToken", "AronDataNavigatorReaderToken", "Received an invalid instance for a reader token.", desc); + throw exception::DescriptorNotValidException("NavigatorReaderToken", "NavigatorReaderToken", "Received an invalid instance for a reader token.", desc); } } - AronDataDescriptor getTypeOfNextElement(const AronTypeDescriptor) const override + data::Descriptor getTypeOfNextElement(const type::Descriptor) const override { const datanavigator::AronDataNavigatorPtr next = getCurrentElement(); return next->getDescriptor(); @@ -95,7 +95,7 @@ namespace armarx return ret; } default: - throw exception::AronDataDescriptorNotValidException("AronDataNavigatorReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); + throw exception::DescriptorNotValidException("NavigatorReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.cpp b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp similarity index 85% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp index 9ed694579537a17152bd63a8af48b82c06b3dd91..042e876682c00b60f3548d5c0171b0633b7bbf0e 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.cpp @@ -23,12 +23,12 @@ #include <numeric> // Header -#include "AronDataNlohmannJSONReader.h" +#include "NlohmannJSONReader.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.h> @@ -84,9 +84,9 @@ namespace armarx { \ AronDataNlohmannJSONReaderTokenPtr token = stack.top(); \ auto desc = token->getDescriptor(); \ - if (desc != AronDataDescriptor::eAron##upperType) \ + if (desc != data::Descriptor::eAron##upperType) \ { \ - throw exception::AronDataDescriptorNotValidException("AronDataNlohmannJSONReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ + throw exception::data::DescriptorNotValidException("NlohmannJSONReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ return false; \ } \ \ @@ -115,7 +115,7 @@ namespace armarx { \ if(data == NULL) \ { \ - throw exception::AronException("AronDataNlohmannJSONReader", "readEnd" + std::string(#upperType), "The corresponding data pointer of an complex aron ptr is NULL."); \ + throw exception::AronException("NlohmannJSONReader", "readEnd" + std::string(#upperType), "The corresponding data pointer of an complex aron ptr is NULL."); \ } \ nlohmann::json j = getCurrentAndGoToNext(); \ std::vector<int> dims = j[ARON_DATA_READER_WRITER_NDARRAY_DIMENSIONS_SLUG]; \ diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h similarity index 91% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h index 7cfee40ab0ed2c5ce6da420c826be04876c2dea6..cd0d8f153564ea885bf4dcbbfe04f48cfc971ee2 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h @@ -25,10 +25,10 @@ #include <stack> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/Reader.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReaderToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h> namespace armarx { diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h similarity index 73% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReaderToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h index e488481b77f69ebd2d636f5b8dfb2357b44bcf2e..42caef60a14328247b52dd79ae3484b15883d6ad 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReaderToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h @@ -28,11 +28,11 @@ #include <SimoxUtility/json.h> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/AronDataClassReaderToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/ReaderToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronResolver.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Resolver.h> namespace armarx { @@ -53,8 +53,8 @@ namespace armarx public: // constructors AronDataNlohmannJSONReaderToken() = delete; - AronDataNlohmannJSONReaderToken(const AronDataDescriptor desc, const nlohmann::json& data) : - AronReaderToken<AronDataDescriptor, nlohmann::json, nlohmann::json>(desc, data), + AronDataNlohmannJSONReaderToken(const data::Descriptor desc, const nlohmann::json& data) : + ReaderToken<data::Descriptor, nlohmann::json, nlohmann::json>(desc, data), AronDataClassReaderToken<nlohmann::json, nlohmann::json>(desc, data) { switch (descriptor) @@ -74,17 +74,17 @@ namespace armarx break; } default: - throw exception::AronDataDescriptorNotValidException("AronDataNlohmannJSONReaderToken", "AronDataNlohmannJSONReaderToken", "Received an invalid instance for a reader token.", desc); + throw exception::DescriptorNotValidException("NlohmannJSONReaderToken", "NlohmannJSONReaderToken", "Received an invalid instance for a reader token.", desc); } } - AronDataDescriptor getTypeOfNextElement(const AronTypeDescriptor hint) const override + data::Descriptor getTypeOfNextElement(const type::Descriptor hint) const override { const nlohmann::json next = getCurrentElement(); if (next.is_object()) { // Check if specific NDArray key exists - if (next.find(ARON_READER_WRITER_TOKEN_NDARRAY_DATA_SLUG) != next.end()) + if (next.find(READER_WRITER_DATA_NDARRAY_DATA_SLUG) != next.end()) { return eAronNDArray; } @@ -97,15 +97,15 @@ namespace armarx if (next.is_number_integer()) { - AronDataDescriptor d = AronResolver::GetFirstIfDescriptorsAreRelated( - AronResolver::GetCorrespondingDataDescriptor(hint), + data::Descriptor d = AronResolver::GetFirstIfRelated( + AronResolver::GetCorresponding(hint), eAronLong); return d; } if (next.is_number_float()) { - AronDataDescriptor d = AronResolver::GetFirstIfDescriptorsAreRelated( - AronResolver::GetCorrespondingDataDescriptor(hint), + data::Descriptor d = AronResolver::GetFirstIfRelated( + AronResolver::GetCorresponding(hint), eAronDouble); return d; } @@ -117,7 +117,7 @@ namespace armarx { return eAronString; } - throw exception::AronException("AronDataNlohmannJSONReaderToken", "getTypeOfNextElement", "Could not determine the type of an nlohmann::json object. Could not convert to AronDataDescriptor enum."); + throw exception::AronException("NlohmannJSONReaderToken", "getTypeOfNextElement", "Could not determine the type of an nlohmann::json object. Could not convert to data::Descriptor enum."); } nlohmann::json getCurrentElement() const override @@ -135,7 +135,7 @@ namespace armarx return ret; } default: - throw exception::AronDataDescriptorNotValidException("AronDataNlohmannJSONReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); + throw exception::DescriptorNotValidException("NlohmannJSONReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.cpp b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.cpp similarity index 76% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.cpp index 91633187f53627ccb31d402fa037b6ac20fbc067..9f2b94d315b070009a1c6fabdc20c61ac00ebe56 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.cpp @@ -23,10 +23,10 @@ #include <numeric> // Header -#include "AronDataWriterVisitor.h" +#include "Visitor.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronResolver.h> +#include <RobotAPI/libraries/aron/aroncore/Resolver.h> @@ -37,14 +37,14 @@ namespace armarx namespace io { - void AronDataWriterVisitor::SetupWriterFromAronDataPtr(AronDataWriter& writer, const datanavigator::AronDataNavigatorPtr& aron) + void Visitor::SetupWriterFromAronDataPtr(AronDataWriter& writer, const datanavigator::NavigatorPtr& aron) { SetupWriterFromAronDataPtr(writer, aron->getResult()); } - void AronDataWriterVisitor::SetupWriterFromAronDataPtr(AronDataWriter& writer, const data::AronDataPtr& aron) + void Visitor::SetupWriterFromAronDataPtr(AronDataWriter& writer, const data::AronDataPtr& aron) { - AronDataDescriptor desc = AronResolver::GetDescriptorForAronData(aron); + data::Descriptor desc = AronResolver::GetDescriptor(aron); switch (desc) { case eAronDict: @@ -54,7 +54,7 @@ namespace armarx for (const auto& [key, value] : casted->elements) { writer.writeKey(key); - AronDataWriterVisitor::SetupWriterFromAronDataPtr(writer, value); + Visitor::SetupWriterFromAronDataPtr(writer, value); } writer.writeEndDict(); break; @@ -65,7 +65,7 @@ namespace armarx writer.writeStartList(); for (const auto& value : casted->elements) { - AronDataWriterVisitor::SetupWriterFromAronDataPtr(writer, value); + Visitor::SetupWriterFromAronDataPtr(writer, value); } writer.writeEndList(); break; @@ -94,7 +94,7 @@ case eAron##upperType: \ default: { - throw exception::AronDataDescriptorNotValidException("LegacyAronDataWriter", "SetupWriterFromAronDataPtr", "Data-Type could not be resolved. The ice_id of the input was: " + aron->ice_id(), desc); + throw exception::DescriptorNotValidException("LegacyAronDataWriter", "SetupWriterFromAronDataPtr", "Data-Type could not be resolved. The ice_id of the input was: " + aron->ice_id(), desc); } } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronReaderWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.h similarity index 66% rename from source/RobotAPI/libraries/aron/aroncore/io/AronReaderWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.h index 90007e2496354ad87b24ce558841b6b2291a44a4..7f2955c64ea3bb6d5a2e308ae0bf5502cc3c6ea9 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronReaderWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/visitor/Visitor.h @@ -25,29 +25,24 @@ #include <string> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> - #include <RobotAPI/interface/aron.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> - -namespace armarx +namespace armarx::aron::dataIO { - namespace aron - { - namespace io - { - class AronReaderWriter; - typedef std::shared_ptr<AronReaderWriter> AronReaderWriterPtr; + class Visitor; + typedef std::shared_ptr<Visitor> VisitorPtr; - class AronReaderWriter - { - public: - AronReaderWriter() = default; + class Visitor + { + private: + Visitor() = delete; - protected: + public: + static void SetupWriterFromAronDataPtr(AronDataWriter&, const datanavigator::NavigatorPtr&); + static void SetupWriterFromAronDataPtr(AronDataWriter&, const data::AronDataPtr&); - }; - } - } + public: + }; } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/Writer.h similarity index 81% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/Writer.h index 700d55261442907d22f6a1c391e9e60c55b94568..91f9dc4810cd1ef38b8419ce4c2774acaff071ad 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/Writer.h @@ -26,7 +26,7 @@ #include <stack> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/DataWriter.h> @@ -68,18 +68,18 @@ namespace armarx { if (lastRemovedToken == nullptr) { - throw exception::AronException("AronDataClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken is NULL. Perhaps you never called a writeEnd* method?"); + throw exception::AronException("ClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken is NULL. Perhaps you never called a writeEnd* method?"); } if (lastRemovedToken->getElement() == nullptr) { - throw exception::AronException("AronDataClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken->getElement() is NULL."); + throw exception::AronException("ClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken->getElement() is NULL."); } } void assertStackIsEmpty() const { if (stack.size() != 0) { - throw exception::AronException("AronDataClassWriter", "assertStackIsEmpty", "The Size of the stack is not 0. Perhaps you never called a writeEnd* method?"); + throw exception::AronException("ClassWriter", "assertStackIsEmpty", "The Size of the stack is not 0. Perhaps you never called a writeEnd* method?"); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/WriterToken.h similarity index 75% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriterToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/WriterToken.h index 3aeb7a9517133ed252e6c284a175f8b23b726aa2..905b88440b75917f0ede1a5c3c35cc36fcabe284 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriterToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/WriterToken.h @@ -25,11 +25,11 @@ #include <string> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/WriterToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> namespace armarx { @@ -45,7 +45,7 @@ namespace armarx template<typename ElementTypename, typename ElementAddTypename> class AronDataClassWriterToken : - virtual public AronWriterToken<AronDataDescriptor, ElementTypename, ElementAddTypename> + virtual public WriterToken<data::Descriptor, ElementTypename, ElementAddTypename> { public: using PointerType = AronDataClassWriterToken<ElementTypename, ElementAddTypename>; @@ -53,8 +53,8 @@ namespace armarx public: // constructor AronDataClassWriterToken() = delete; - AronDataClassWriterToken(const AronDataDescriptor desc, const ElementTypename& n) : - AronWriterToken<AronDataDescriptor, ElementTypename, ElementAddTypename>(desc, n) + AronDataClassWriterToken(const data::Descriptor desc, const ElementTypename& n) : + WriterToken<data::Descriptor, ElementTypename, ElementAddTypename>(desc, n) {} // public member functions @@ -69,7 +69,7 @@ namespace armarx case eAronList: return std::to_string(this->currentIndex); default: - throw exception::AronDataDescriptorNotValidException("AronDataClassWriterToken", "toElementAccessor", "Could not resove a type of a navigator. Allowed are only container and complex types due to performance.", this->descriptor); + throw exception::DescriptorNotValidException("ClassWriterToken", "toElementAccessor", "Could not resove a type of a navigator. Allowed are only container and complex types due to performance.", this->descriptor); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.cpp similarity index 87% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.cpp index a39b26b541809f6e5e2cfcadc50bc6005f50d059..b237088f31665174d619cd72b37f419c584de3b3 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.cpp @@ -23,10 +23,10 @@ #include <numeric> // Header -#include "AronDataNavigatorWriter.h" +#include "NavigatorWriter.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> @@ -37,9 +37,9 @@ namespace armarx namespace io { - AronPath AronDataNavigatorWriter::generateAronPath() + Path AronDataNavigatorWriter::generatePath() { - AronPath path; + Path path; if (!wroteInitialStartContainer) { wroteInitialStartContainer = true; @@ -47,7 +47,7 @@ namespace armarx else { AronDataNavigatorWriterTokenPtr parent_token = stack.top(); - path = AronPath(parent_token->getElement()->getPath(), parent_token->toElementAccessor()); + path = Path(parent_token->getElement()->getPath(), parent_token->toElementAccessor()); } return path; } @@ -56,7 +56,7 @@ namespace armarx #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ bool AronDataNavigatorWriter::writeStart##upperType() \ { \ - AronPath path = generateAronPath(); \ + Path path = generatePath(); \ datanavigator::Aron##upperType##DataNavigatorPtr data = datanavigator::Aron##upperType##DataNavigatorPtr(new datanavigator::Aron##upperType##DataNavigator(path)); \ AronDataNavigatorWriterTokenPtr new_token = AronDataNavigatorWriterTokenPtr(new AronDataNavigatorWriterToken(data->getDescriptor(), data)); \ stack.push(new_token); \ @@ -83,7 +83,7 @@ namespace armarx #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ bool AronDataNavigatorWriter::write##upperType(const std::vector<int>& dims, const std::string& t, const unsigned char* data) \ { \ - AronPath path = generateAronPath(); \ + Path path = generatePath(); \ AronDataNavigatorWriterTokenPtr token = stack.top(); \ datanavigator::Aron##upperType##DataNavigatorPtr aron(new datanavigator::Aron##upperType##DataNavigator(path)); \ aron->setDimensions(dims); \ @@ -100,7 +100,7 @@ namespace armarx #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ bool AronDataNavigatorWriter::writePrimitive(const lowerType& x) \ { \ - AronPath path = generateAronPath(); \ + Path path = generatePath(); \ AronDataNavigatorWriterTokenPtr token = stack.top(); \ datanavigator::Aron##upperType##DataNavigatorPtr aron(new datanavigator::Aron##upperType##DataNavigator(path)); \ aron->setValue(x); \ diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h similarity index 83% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h index ab1022c8f33f8dc7e1558e08e268f487d5f796e9..bc857cc6d726c17f06cc609bada6236aead8d2ca 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h @@ -25,12 +25,12 @@ #include <stack> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/Writer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriterToken.h> namespace armarx { @@ -67,7 +67,7 @@ namespace armarx #undef RUN_ARON_MACRO private: - AronPath generateAronPath(); + Path generatePath(); }; } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriterToken.h similarity index 77% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriterToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriterToken.h index 4ec86cfe30b7068ab1d7a00d8441e64deae609f5..4c0a533183ce88e5c7dd710c9f6c223ee244f01f 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriterToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriterToken.h @@ -25,11 +25,11 @@ #include <string> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/WriterToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h> namespace armarx { @@ -49,8 +49,8 @@ namespace armarx public: // constructor AronDataNavigatorWriterToken() = delete; - AronDataNavigatorWriterToken(const AronDataDescriptor desc, const datanavigator::AronContainerDataNavigatorPtr& d) : - AronWriterToken<AronDataDescriptor, datanavigator::AronContainerDataNavigatorPtr, datanavigator::AronDataNavigatorPtr>(desc, d), + AronDataNavigatorWriterToken(const data::Descriptor desc, const datanavigator::AronContainerDataNavigatorPtr& d) : + WriterToken<data::Descriptor, datanavigator::AronContainerDataNavigatorPtr, datanavigator::AronDataNavigatorPtr>(desc, d), AronDataClassWriterToken<datanavigator::AronContainerDataNavigatorPtr, datanavigator::AronDataNavigatorPtr>(desc, d) { @@ -76,7 +76,7 @@ namespace armarx break; } default: - throw exception::AronDataDescriptorNotValidException("AronDataNavigatorWriterToken", "addElement", "Could not resove a type of a navigator. Allowed are only containers. The path was: " + element->pathToString(), desc); + throw exception::DescriptorNotValidException("NavigatorWriterToken", "addElement", "Could not resove a type of a navigator. Allowed are only containers. The path was: " + element->pathToString(), desc); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp similarity index 95% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp index f3e54dbba44d39b157a4bff869a6a4ad38bf84a5..66178dcfccf2c53fb3b73b786f180118a6a80e43 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp @@ -23,7 +23,7 @@ #include <numeric> -#include "AronDataNlohmannJSONWriter.h" +#include "NlohmannJSONWriter.h" namespace armarx { @@ -37,7 +37,7 @@ namespace armarx bool AronDataNlohmannJSONWriter::writeStart##upperType() \ { \ nlohmann::json data; \ - AronDataNlohmannJSONWriterTokenPtr new_token = AronDataNlohmannJSONWriterTokenPtr(new AronDataNlohmannJSONWriterToken(AronDataDescriptor::eAron##upperType, data)); \ + AronDataNlohmannJSONWriterTokenPtr new_token = AronDataNlohmannJSONWriterTokenPtr(new AronDataNlohmannJSONWriterToken(data::Descriptor::eAron##upperType, data)); \ stack.push(new_token); \ return true; \ } \ diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h similarity index 87% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h index 4324e1a94ae2ee0fb956f62c648d66dfdfe2add0..32a84a4f134a54bedab76652f6d79a91c65374b3 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h @@ -26,11 +26,11 @@ #include <sstream> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/Writer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h> namespace armarx { diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h similarity index 80% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriterToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h index 4246f10e36d3735c8ac55873976fe28cc1a09181..41dde7ccbde0fb982d2a289e4ee8ca9c44f2be90 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriterToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h @@ -28,10 +28,10 @@ #include <SimoxUtility/json.h> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/WriterToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> namespace armarx { @@ -51,8 +51,8 @@ namespace armarx public: // constructor AronDataNlohmannJSONWriterToken() = delete; - AronDataNlohmannJSONWriterToken(const AronDataDescriptor desc, const nlohmann::json& d) : - AronWriterToken<AronDataDescriptor, nlohmann::json, nlohmann::json>(desc, d), + AronDataNlohmannJSONWriterToken(const data::Descriptor desc, const nlohmann::json& d) : + WriterToken<data::Descriptor, nlohmann::json, nlohmann::json>(desc, d), AronDataClassWriterToken<nlohmann::json, nlohmann::json>(desc, d) { @@ -76,7 +76,7 @@ namespace armarx break; } default: - throw exception::AronDataDescriptorNotValidException("AronDataNlohmannJSONWriterToken", "addElement", "Could not resove a type of a token. Allowed are only containers.", desc); + throw exception::DescriptorNotValidException("NlohmannJSONWriterToken", "addElement", "Could not resove a type of a token. Allowed are only containers.", desc); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReader.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/Reader.h similarity index 61% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReader.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/Reader.h index 5d8034c983c76a5c2b32de7e9b92d2a0e5b17b5e..8dd4d2580a84003c5a61c77cd527c06c2ab7efdb 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/Reader.h @@ -24,45 +24,38 @@ #include <memory> #include <string> -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReaderWriter.h> - // ArmarX #include <ArmarXCore/core/exceptions/Exception.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/Writer.h> -namespace armarx +namespace armarx::aron::typeIO { - namespace aron - { - namespace io - { - class AronTypeReader; - typedef std::shared_ptr<AronTypeReader> AronTypeReaderPtr; + class Reader; + typedef std::shared_ptr<Reader> ReaderPtr; - class AronTypeReader : - public AronTypeReaderWriter + class Reader { public: - AronTypeReader() = default; + Reader() = default; #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual int readStart##upperType##Type() = 0; \ - virtual bool readEnd##upperType##Type() = 0; \ + virtual int readStart##upperType() = 0; \ + virtual bool readEnd##upperType() = 0; HANDLE_CONTAINER_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual std::pair<std::vector<int>, std::string> read##upperType##Type() = 0; \ + virtual std::pair<std::vector<int>, std::string> readStart##upperType() = 0; \ + virtual void readEnd##upperType() = 0; - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual void read##upperType##Type() = 0; \ + virtual void read##upperType() = 0; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO @@ -72,8 +65,6 @@ namespace armarx virtual std::string readObjectName() = 0; // Helper functions - virtual AronTypeDescriptor getTypeOfNextAron() const = 0; + virtual type::Descriptor getTypeOfNextAron() const = 0; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/Writer.h similarity index 62% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/Writer.h index 1a9f64515ac3c1631bc527c1d3f1d1296b7b2852..33b00be8317dcbafee6d57f92f7140a9ce039909 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/Writer.h @@ -24,53 +24,45 @@ #include <memory> #include <string> -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReaderWriter.h> - // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> -namespace armarx +namespace armarx::aron::typeIO { - namespace aron - { - namespace io - { - class AronTypeWriter; - typedef std::shared_ptr<AronTypeWriter> AronTypeWriterPtr; + class Writer; + typedef std::shared_ptr<Writer> TypeWriterPtr; - class AronTypeWriter : - public AronTypeReaderWriter + class Writer { public: - AronTypeWriter() = default; + Writer() = default; #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool writeStart##upperType##Type() = 0; \ - virtual bool writeEnd##upperType##Type() = 0; \ + virtual bool writeStart##upperType() = 0; \ + virtual bool writeEnd##upperType() = 0; HANDLE_CONTAINER_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type(const std::vector<int>&, const std::string&) = 0; \ + virtual bool writeStart##upperType(const std::vector<int>&, const std::string&) = 0; \ + virtual bool writeEnd##upperType() = 0; - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type() = 0; \ + virtual bool write##upperType() = 0; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO + virtual std::string readKey() = 0; virtual bool writeKey(const std::string&) = 0; virtual bool writeObjectName(const std::string&) = 0; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/converter/Converter.cpp similarity index 82% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/converter/Converter.cpp index 6db59a989d2e05fafb843baef278a21fae8108d8..0d596e72f0cd16bc5e91ae713df678b140d8d8fd 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/converter/Converter.cpp @@ -23,7 +23,7 @@ #include <numeric> // Header -#include "AronTypeConverter.h" +#include "Converter.h" @@ -34,9 +34,9 @@ namespace armarx { namespace io { - void AronTypeConverter::ConvertFromReader(AronTypeReader& reader, AronTypeWriter& writer) + void Converter::ConvertFromReader(Reader& reader, Writer& writer) { - AronTypeDescriptor desc = reader.getTypeOfNextAron(); + type::Descriptor desc = reader.getTypeOfNextAron(); switch (desc) { case eAronObjectType: @@ -51,7 +51,7 @@ namespace armarx { std::string key = reader.readKey(); writer.writeKey(key); - AronTypeConverter::ConvertFromReader(reader, writer); + Converter::ConvertFromReader(reader, writer); } writer.writeEndObjectType(); @@ -63,7 +63,7 @@ namespace armarx reader.readStartDictType(); writer.writeStartDictType(); - AronTypeConverter::ConvertFromReader(reader, writer); + Converter::ConvertFromReader(reader, writer); writer.writeEndDictType(); reader.readEndDictType(); @@ -76,7 +76,7 @@ namespace armarx for (int i = 0; i < elements; ++i) { - AronTypeConverter::ConvertFromReader(reader, writer); + Converter::ConvertFromReader(reader, writer); } writer.writeEndTupleType(); @@ -88,7 +88,7 @@ namespace armarx reader.readStartListType(); writer.writeStartListType(); - AronTypeConverter::ConvertFromReader(reader, writer); + Converter::ConvertFromReader(reader, writer); writer.writeEndListType(); reader.readEndListType(); @@ -102,7 +102,7 @@ case eAron##upperType##Type: \ break; \ } - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ @@ -118,7 +118,7 @@ case eAron##upperType##Type: \ default: { - throw exception::AronTypeDescriptorNotValidException("LegacyAronTypeReader", "SetupReaderAndGetResult", "Type-Type could not be resolved", desc); + throw exception::DescriptorNotValidException("LegacyAronTypeReader", "SetupReaderAndGetResult", "Type-Type could not be resolved", desc); } } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/converter/Converter.h similarity index 53% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/converter/Converter.h index 133d605cb4417910933fbd4983247ddc420cebee..1c502479c70f7078c34ac97d675d7a2a59cd0187 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeConverter/AronTypeConverter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/converter/Converter.h @@ -25,35 +25,27 @@ #include <string> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/Reader.h> // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.h> -namespace armarx +namespace armarx::aron::typeIO { - namespace aron + class Converter; + typedef std::shared_ptr<Converter> AronTypeConverterPtr; + + class Converter { - namespace io - { - class AronTypeConverter; - typedef std::shared_ptr<AronTypeConverter> AronTypeConverterPtr; - - class AronTypeConverter - { - private: - AronTypeConverter() = delete; - - public: - static void ConvertFromReader(AronTypeReader&, AronTypeWriter&); - - public: - }; - } - } + private: + Converter() = delete; + + public: + static void ConvertFromReader(Reader&, Writer&); + + public: + }; } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReader.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/Reader.h similarity index 76% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReader.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/Reader.h index 2c011b1bbeb572ba4f3045e2d44a888405949cb5..d51ba0257f323d5be15fdca123010695bb9a5acb 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/Reader.h @@ -25,31 +25,27 @@ #include <string> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/Reader.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> -namespace armarx -{ - namespace aron - { - namespace io +namespace armarx::aron::typeIO { template <typename InputTypename, typename TokenPtrTypename> - class AronTypeClassReader; + class TokenizedReader; template <typename InputTypename, typename TokenPtrTypename> - using AronTypeClassReaderPtr = std::shared_ptr<AronTypeClassReader<InputTypename, TokenPtrTypename>> ; + using TokenizedReaderPtr = std::shared_ptr<TokenizedReader<InputTypename, TokenPtrTypename>> ; template <typename InputTypename, typename TokenPtrTypename> - class AronTypeClassReader : - public AronTypeReader + class TokenizedReader : + public Reader { public: - AronTypeClassReader() = delete; - AronTypeClassReader(const InputTypename& input) : + TokenizedReader() = delete; + TokenizedReader(const InputTypename& input) : input(input) { } @@ -75,12 +71,12 @@ namespace armarx return token->getObjectName(); } - virtual AronTypeDescriptor getTypeOfNextAron() const override + virtual type::Descriptor getTypeOfNextAron() const override { if (stack.empty()) { // completely unknown. We assume a object on the top level - return eAronObjectType; + return type::Descriptor::eObject; } TokenPtrTypename lastToken = stack.top(); @@ -92,6 +88,4 @@ namespace armarx bool readInitialStart = false; std::stack<TokenPtrTypename> stack; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/ReaderToken.h similarity index 57% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReaderToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/ReaderToken.h index 4d4879c82cd6e7cbde4426be8fbedcdce2b4de43..bae41b88e6594c22c356a958e91e7330dc566711 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReaderToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/ReaderToken.h @@ -25,43 +25,39 @@ #include <string> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronReaderToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/ReaderToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> -namespace armarx -{ - namespace aron - { - namespace io +namespace armarx::aron::typeIO { template<typename ElementReturnPtrTypename, typename ElementAddTypename> - class AronTypeClassReaderToken; + class ReaderToken; template<typename ElementReturnPtrTypename, typename ElementAddTypename> - using AronTypeClassReaderTokenPtr = std::shared_ptr<AronTypeClassReaderToken<ElementReturnPtrTypename, ElementAddTypename>>; + using ReaderTokenPtr = std::shared_ptr<ReaderToken<ElementReturnPtrTypename, ElementAddTypename>>; template<typename ElementReturnPtrTypename, typename ElementAddTypename> - class AronTypeClassReaderToken : - virtual public AronReaderToken<AronTypeDescriptor, ElementReturnPtrTypename, ElementAddTypename> + class ReaderToken : + virtual public io::ReaderToken<type::Descriptor, ElementReturnPtrTypename, ElementAddTypename> { public: - using PointerType = AronTypeClassReaderTokenPtr<ElementReturnPtrTypename, ElementAddTypename>; + using PointerType = ReaderTokenPtr<ElementReturnPtrTypename, ElementAddTypename>; public: // constructors - AronTypeClassReaderToken() = delete; - AronTypeClassReaderToken(const AronTypeDescriptor desc, const ElementAddTypename& type) : - AronReaderToken<AronTypeDescriptor, ElementReturnPtrTypename, ElementAddTypename>(desc, type) + ReaderToken() = delete; + ReaderToken(const type::Descriptor desc, const ElementAddTypename& type) : + io::ReaderToken<type::Descriptor, ElementReturnPtrTypename, ElementAddTypename>(desc, type) { } bool currentIsEligableForResolvingKey() const override { - if (this->descriptor == AronTypeDescriptor::eAronObjectType) + if (this->descriptor == type::Descriptor::eObject) { return true; } @@ -69,10 +65,8 @@ namespace armarx } virtual std::string getObjectName() const = 0; - virtual AronTypeDescriptor getTypeOfNextElement() const = 0; + virtual type::Descriptor getTypeOfNextElement() const = 0; private: }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.cpp b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReader.cpp similarity index 70% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReader.cpp index f548134ab93af6657a265310be8a7612c6781339..84439806547d0fcd948f9ccb7b6e9e58b7390786 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NavigatorReader/AronTypeNavigatorReader.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReader.cpp @@ -23,12 +23,12 @@ #include <numeric> // Header -#include "AronTypeNavigatorReader.h" +#include "NavigatorReader.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h> @@ -38,19 +38,19 @@ namespace armarx { namespace io { - AronTypeNavigatorReader::AronTypeNavigatorReader(const typenavigator::AronContainerTypeNavigatorPtr& n) : - AronTypeClassReader<typenavigator::AronContainerTypeNavigatorPtr, AronTypeNavigatorReaderTokenPtr>(n) + NavigatorReader::NavigatorReader(const typenavigator::AronContainerTypeNavigatorPtr& n) : + Reader<typenavigator::AronContainerTypeNavigatorPtr, AronTypeNavigatorReaderTokenPtr>(n) { } - AronTypeNavigatorReader::AronTypeNavigatorReader(const type::AronContainerTypePtr& n) : - AronTypeClassReader<typenavigator::AronContainerTypeNavigatorPtr, AronTypeNavigatorReaderTokenPtr>( - typenavigator::AronContainerTypeNavigator::DynamicCast(typenavigator::AronTypeNavigator::FromAronType(n)) + NavigatorReader::NavigatorReader(const type::AronContainerTypePtr& n) : + Reader<typenavigator::AronContainerTypeNavigatorPtr, AronTypeNavigatorReaderTokenPtr>( + typenavigator::AronContainerTypeNavigator::DynamicCast(typenavigator::Navigator::FromAronType(n)) ) { } - typenavigator::AronTypeNavigatorPtr AronTypeNavigatorReader::getCurrentAndGoToNext() + typenavigator::NavigatorPtr NavigatorReader::getCurrentAndGoToNext() { if (!readInitialStart) { @@ -61,7 +61,7 @@ namespace armarx return lastToken->getCurrentElementAndIncreaseCnt(); } - typenavigator::AronTypeNavigatorPtr AronTypeNavigatorReader::getCurrent() + typenavigator::NavigatorPtr NavigatorReader::getCurrent() { if (!readInitialStart) { @@ -77,9 +77,9 @@ namespace armarx { \ typenavigator::AronTypeNavigatorPtr current_nav = getCurrentAndGoToNext(); \ auto desc = current_nav->getDescriptor(); \ - if (desc != AronTypeDescriptor::eAron##upperType##Type) \ + if (desc != type::Descriptor::eAron##upperType##Type) \ { \ - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorReader", "readStart" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ + throw exception::type::DescriptorNotValidException("NavigatorReader", "readStart" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ return false; \ } \ typenavigator::Aron##upperType##TypeNavigatorPtr current_nav_casted = typenavigator::Aron##upperType##TypeNavigator::DynamicCast(current_nav); \ @@ -92,9 +92,9 @@ namespace armarx { \ AronTypeNavigatorReaderTokenPtr token = stack.top(); \ auto desc = token->getDescriptor(); \ - if (desc != AronTypeDescriptor::eAron##upperType##Type) \ + if (desc != type::Descriptor::eAron##upperType##Type) \ { \ - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ + throw exception::type::DescriptorNotValidException("NavigatorReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType), desc); \ return false; \ } \ \ @@ -118,7 +118,7 @@ namespace armarx return std::make_pair(casted->getDimensions(), casted->getUsedType()); \ } - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO // Read primitives diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReader.h similarity index 50% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReader.h index 1b1fa8dd24f43ae9bab52c97d4da59ebae2f1f36..abfce639925dbef4d79b0a89e5bef85de7270c73 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReader.h @@ -25,54 +25,54 @@ #include <stack> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/reader/Reader.h> // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReaderToken.h> -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriterToken.h> -namespace armarx -{ - namespace aron - { - namespace io +namespace armarx::aron::typeIO::reader { - class AronTypeNavigatorWriter; - typedef std::shared_ptr<AronTypeNavigatorWriter> AronTypeNavigatorWriterPtr; + class NavigatorReader; + typedef std::shared_ptr<NavigatorReader> NavigatorReaderPtr; - class AronTypeNavigatorWriter : - virtual public AronTypeClassWriter<typenavigator::AronTypeNavigatorPtr, AronTypeNavigatorWriterTokenPtr> + class NavigatorReader : + virtual public TokenizedReader<typenavigator::NavigatorPtr, AronTypeNavigatorReaderTokenPtr> { public: - AronTypeNavigatorWriter() = default; + using PointerType = NavigatorReaderPtr; + + public: + // constructors + NavigatorReader() = delete; + NavigatorReader(const typenavigator::NavigatorPtr& n); + NavigatorReader(const type::AronTypePtr& n); #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool writeStart##upperType##Type() override; \ - virtual bool writeEnd##upperType##Type() override; \ + virtual int readStart##upperType() override; \ + virtual bool readEnd##upperType() override; HANDLE_CONTAINER_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type(const std::vector<int>&, const std::string&) override; \ + virtual std::pair<std::vector<int>, std::string> readStart##upperType() override; \ + virtual void readEnd##upperType() override; - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type() override; \ + virtual void read##upperType() override; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO private: - AronPath generateAronPath(); + typenavigator::NavigatorPtr getCurrentAndGoToNext(); + typenavigator::NavigatorPtr getCurrent(); private: }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReaderToken.h new file mode 100644 index 0000000000000000000000000000000000000000..34f166940379c9dafdd548a4f85cd8b4429984ad --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/navigator/NavigatorReaderToken.h @@ -0,0 +1,132 @@ +/* +* This file is part of ArmarX. +* +* 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/>. +* +* @author Fabian Peller (fabian dot peller at kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#pragma once + +// STD/STL +#include <memory> +#include <string> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/reader/ReaderToken.h> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> + +namespace armarx::aron::typeIO::reader + { + // BaseClass + class NavigatorReaderToken; + typedef std::shared_ptr<NavigatorReaderToken> AronTypeNavigatorReaderTokenPtr; + + class NavigatorReaderToken : + virtual public ReaderToken<typenavigator::NavigatorPtr, typenavigator::NavigatorPtr> + { + public: + using PointerType = AronTypeNavigatorReaderTokenPtr; + + public: + // constructors + NavigatorReaderToken() = delete; + NavigatorReaderToken(const type::Descriptor desc, const typenavigator::NavigatorPtr& type) : + io::ReaderToken<type::Descriptor, typenavigator::NavigatorPtr, typenavigator::NavigatorPtr>(desc, type), + ReaderToken<typenavigator::NavigatorPtr, typenavigator::NavigatorPtr>(desc, type) + { + switch (descriptor) + { + case type::Descriptor::eObject: + { + allKeys = typenavigator::ObjectNavigator::DynamicCast(element)->getAllKeys(); + maxIndex = allKeys.size(); + break; + } + case type::Descriptor::eDict: + { + maxIndex = 1; + break; + } + case type::Descriptor::eTuple: + { + maxIndex = typenavigator::TupleNavigator::DynamicCast(element)->childrenSize(); + break; + } + case type::Descriptor::eList: + { + maxIndex = 1; + break; + } + default: + throw exception::DescriptorNotValidException("NavigatorReaderToken", "NavigatorReaderToken", "Received an invalid instance for a reader token.", desc); + } + } + + std::string getObjectName() const override + { + if(descriptor == type::Descriptor::eObject) + { + const typenavigator::ObjectNavigatorPtr next = typenavigator::ObjectNavigator::DynamicCastAndCheck(getCurrentElement()); + return next->getObjectName(); + } + throw exception::DescriptorNotValidException("NavigatorReaderToken", "NavigatorReaderToken", "Could not get object nme of a non-object token", descriptor); + } + + type::Descriptor getTypeOfNextElement() const override + { + const typenavigator::NavigatorPtr next = getCurrentElement(); + return next->getDescriptor(); + } + + typenavigator::NavigatorPtr getCurrentElement() const override + { + switch (descriptor) + { + case type::Descriptor::eObject: + { + typenavigator::ObjectNavigatorPtr casted = typenavigator::ObjectNavigator::DynamicCastAndCheck(element); + typenavigator::NavigatorPtr ret = casted->getAcceptedType(resolveCurrentKey()); + return ret; + } + case type::Descriptor::eDict: + { + typenavigator::DictNavigatorPtr casted = typenavigator::DictNavigator::DynamicCastAndCheck(element); + typenavigator:NavigatorPtr ret = casted->getAcceptedType(); + return ret; + } + case type::Descriptor::eTuple: + { + typenavigator::TupleNavigatorPtr casted = typenavigator::TupleNavigator::DynamicCastAndCheck(element); + typenavigator::NavigatorPtr ret = casted->getAcceptedType(currentIndex); + return ret; + } + case type::Descriptor::eList: + { + typenavigator::ListNavigatorPtr casted = typenavigator::ListNavigator::DynamicCastAndCheck(element); + typenavigator::NavigatorPtr ret = casted->getAcceptedType(); + return ret; + } + default: + throw exception::DescriptorNotValidException("NavigatorReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); + } + } + + private: + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.cpp b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.cpp similarity index 65% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.cpp index 03b525e43be244ff98fa804b4d3955699eeadda7..269ff314e91b63d0346ba5302d4ed5c1d7ef2ede 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.cpp @@ -23,12 +23,12 @@ #include <numeric> // Header -#include "AronTypeNlohmannJSONReader.h" +#include "NlohmannJSONReader.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h> @@ -38,35 +38,35 @@ namespace armarx { namespace io { - AronTypeNlohmannJSONReader::AronTypeNlohmannJSONReader(const nlohmann::json& n) : - AronTypeClassReader<nlohmann::json, AronTypeNlohmannJSONReaderTokenPtr>(n) + NlohmannJSONReader::NlohmannJSONReader(const nlohmann::json& n) : + Reader<nlohmann::json, NlohmannJSONReaderTokenPtr>(n) { } - AronTypeNlohmannJSONReader::AronTypeNlohmannJSONReader(const std::string& n) : - AronTypeClassReader<nlohmann::json, AronTypeNlohmannJSONReaderTokenPtr>(nlohmann::json::parse(n)) + NlohmannJSONReader::NlohmannJSONReader(const std::string& n) : + Reader<nlohmann::json, NlohmannJSONReaderTokenPtr>(nlohmann::json::parse(n)) { } - nlohmann::json AronTypeNlohmannJSONReader::getCurrentAndGoToNext() + nlohmann::json NlohmannJSONReader::getCurrentAndGoToNext() { if (!readInitialStart) { readInitialStart = true; return input; } - AronTypeNlohmannJSONReaderTokenPtr lastToken = stack.top(); + NlohmannJSONReaderTokenPtr lastToken = stack.top(); return lastToken->getCurrentElementAndIncreaseCnt(); } - nlohmann::json AronTypeNlohmannJSONReader::getCurrent() + nlohmann::json NlohmannJSONReader::getCurrent() { if (!readInitialStart) { readInitialStart = true; return input; } - AronTypeNlohmannJSONReaderTokenPtr lastToken = stack.top(); + NlohmannJSONReaderTokenPtr lastToken = stack.top(); return lastToken->getCurrentElement(); } @@ -74,18 +74,18 @@ namespace armarx int AronTypeNlohmannJSONReader::readStart##upperType##Type() \ { \ nlohmann::json current_json = getCurrentAndGoToNext(); \ - AronTypeNlohmannJSONReaderTokenPtr newToken = AronTypeNlohmannJSONReaderTokenPtr(new AronTypeNlohmannJSONReaderToken(eAron##upperType##Type, current_json)); \ + NlohmannJSONReaderTokenPtr newToken = NlohmannJSONReaderTokenPtr(new NlohmannJSONReaderToken(eAron##upperType##Type, current_json)); \ stack.push(newToken); \ return newToken->getChildrenSize(); \ } \ \ bool AronTypeNlohmannJSONReader::readEnd##upperType##Type() \ { \ - AronTypeNlohmannJSONReaderTokenPtr token = stack.top(); \ + NlohmannJSONReaderTokenPtr token = stack.top(); \ auto desc = token->getDescriptor(); \ - if (desc != AronTypeDescriptor::eAron##upperType##Type) \ + if (desc != type::Descriptor::eAron##upperType##Type) \ { \ - throw exception::AronTypeDescriptorNotValidException("AronTypeNlohmannJSONReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType) + "Type", desc); \ + throw exception::type::DescriptorNotValidException("NlohmannJSONReader", "readEnd" + std::string(#upperType), "A token in the stack has the wrong type. Expected " + std::string(#upperType) + "Type", desc); \ return false; \ } \ \ @@ -110,7 +110,7 @@ namespace armarx return std::make_pair(dims, type); \ } - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO // Read primitives diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.h similarity index 55% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.h index ee52d331d6377fa6014eb8d2d2d159d32407e52d..83427c89d5e5370413448f459b08672ed6108fea 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReader.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReader.h @@ -25,47 +25,44 @@ #include <stack> // BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/AronTypeClassReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/reader/Reader.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classReaders/NlohmannJSONReader/AronTypeNlohmannJSONReaderToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h> -namespace armarx -{ - namespace aron - { - namespace io +namespace armarx::aron::typeIO::reader { - class AronTypeNlohmannJSONReader; - typedef std::shared_ptr<AronTypeNlohmannJSONReader> AronTypeNlohmannJSONReaderPtr; + class NlohmannJSONReader; + typedef std::shared_ptr<NlohmannJSONReader> NlohmannJSONReaderPtr; - class AronTypeNlohmannJSONReader : - virtual public AronTypeClassReader<nlohmann::json, AronTypeNlohmannJSONReaderTokenPtr> + class NlohmannJSONReader : + virtual public TokenizedReader<nlohmann::json, NlohmannJSONReaderTokenPtr> { public: - using PointerType = AronTypeNlohmannJSONReaderPtr; + using PointerType = NlohmannJSONReaderPtr; public: // constructors - AronTypeNlohmannJSONReader() = delete; - AronTypeNlohmannJSONReader(const nlohmann::json& n); - AronTypeNlohmannJSONReader(const std::string& n); + NlohmannJSONReader() = delete; + NlohmannJSONReader(const nlohmann::json& n); + NlohmannJSONReader(const std::string& n); #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual int readStart##upperType##Type() override; \ - virtual bool readEnd##upperType##Type() override; \ + virtual int readStart##upperType() override; \ + virtual bool readEnd##upperType() override; HANDLE_CONTAINER_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual std::pair<std::vector<int>, std::string> read##upperType##Type() override; \ + virtual std::pair<std::vector<int>, std::string> readStart##upperType() override; \ + virtual void readEnd##upperType() override; - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual void read##upperType##Type() override; \ + virtual void read##upperType() override; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO @@ -76,6 +73,4 @@ namespace armarx private: }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h new file mode 100644 index 0000000000000000000000000000000000000000..8b748fd6839c1b591af3e2fa3dfd5b87a403a2b3 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/reader/nlohmannJSON/NlohmannJSONReaderToken.h @@ -0,0 +1,190 @@ +/* +* This file is part of ArmarX. +* +* 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/>. +* +* @author Fabian Peller (fabian dot peller at kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#pragma once + +// STD/STL +#include <memory> +#include <string> + +// Simox +#include <SimoxUtility/json.h> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/reader/ReaderToken.h> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/Resolver.h> + +namespace armarx::aron::typeIO::reader + { + // BaseClass + class NlohmannJSONReaderToken; + typedef std::shared_ptr<NlohmannJSONReaderToken> NlohmannJSONReaderTokenPtr; + + class NlohmannJSONReaderToken : + virtual public ReaderToken<nlohmann::json, nlohmann::json> + { + public: + using PointerType = NlohmannJSONReaderTokenPtr; + + public: + // constructors + NlohmannJSONReaderToken() = delete; + NlohmannJSONReaderToken(const type::Descriptor desc, const nlohmann::json& type) : + io::ReaderToken<type::Descriptor, nlohmann::json, nlohmann::json>(desc, type), + ReaderToken<nlohmann::json, nlohmann::json>(desc, type) + { + switch (descriptor) + { + case type::Descriptor::eObject: + { + for (auto it = type.begin(); it != type.end(); ++it) + { + if ( + it.key() == io::Data::READER_WRITER_OBJECT_NAME_SLUG || +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + it.key() == io::Data::READER_WRITER_##capsType##_TYPENAME_SLUG || + + HANDLE_PRIMITIVE_TYPES +#undef RUN_ARON_MACRO + it.key() == io::Data::READER_WRITER_DICT_ACCEPTED_TYPE_SLUG || + it.key() == io::Data::READER_WRITER_LIST_ACCEPTED_TYPE_SLUG || + it.key() == io::Data::READER_WRITER_NDARRAY_NAME_SLUG || + it.key() == io::Data::READER_WRITER_NDARRAY_DIMENSIONS_SLUG || + it.key() == io::Data::READER_WRITER_NDARRAY_TYPE_SLUG + ) + { + continue; + } + + allKeys.push_back(it.key()); + } + maxIndex = allKeys.size(); + break; + } + case type::Descriptor::eDict: + { + maxIndex = 1; + break; + } + case type::Descriptor::eTuple: + { + maxIndex = type.size(); + break; + } + case type::Descriptor::eList: + { + maxIndex = 1; + break; + } + default: + throw exception::DescriptorNotValidException("NlohmannJSONReaderToken", "NlohmannJSONReaderToken", "Received an invalid instance for a reader token.", desc); + } + } + + std::string getObjectName() const override + { + if (descriptor == type::Descriptor::eObject) + { + return element[io::Data::READER_WRITER_OBJECT_NAME_SLUG]; + } + throw exception::DescriptorNotValidException("NavigatorReaderToken", "NavigatorReaderToken", "Could not get object nme of a non-object token", descriptor); + } + + type::Descriptor getTypeOfNextElement() const override + { + const nlohmann::json next = getCurrentElement(); + + if (next.is_object()) + { + if (next.find(io::Data::READER_WRITER_DICT_ACCEPTED_TYPE_SLUG) != next.end()) + { + return type::Descriptor::eDict; + } + if (next.find(io::Data::READER_WRITER_LIST_ACCEPTED_TYPE_SLUG) != next.end()) + { + return type::Descriptor::eList; + } + if (next.find(io::Data::READER_WRITER_NDARRAY_NAME_SLUG) != next.end()) + { +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + if (next[io::Data::READER_WRITER_NDARRAY_NAME_SLUG] == std::string(#upperType)) \ + { \ + return type::Descriptor::e##upperType; \ + } + + HANDLE_NDARRAY_TYPES +#undef RUN_ARON_MACRO + throw exception::AronException("NlohmannJSONReaderToken", "getTypeOfNextElement", "Could not determine the type of an nlohmann::json object. Found indicator of NDArray but could not resolve real type. Found JSON: " + next[io::Data::READER_WRITER_NDARRAY_NAME_SLUG].dump(2)); + } + return type::Descriptor::eObject; + } + if (next.is_array()) + { + return type::Descriptor::eTuple; + } + if (next.is_string()) + { +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + if (next == io::Data::READER_WRITER_##capsType##_TYPENAME_SLUG) \ + { \ + return type::Descriptor::e##upperType; \ + } + + HANDLE_PRIMITIVE_TYPES +#undef RUN_ARON_MACRO + } + throw exception::AronException("NlohmannJSONReaderToken", "getTypeOfNextElement", "Could not determine the type of an nlohmann::json object. Could not convert to type::Descriptor enum. Found JSON: " + next.dump(2)); + } + + nlohmann::json getCurrentElement() const override + { + switch (descriptor) + { + case type::Descriptor::eObject: + { + nlohmann::json ret = element[resolveCurrentKey()]; + return ret; + } + case type::Descriptor::eDict: + { + nlohmann::json ret = element[io::Data::READER_WRITER_DICT_ACCEPTED_TYPE_SLUG]; + return ret; + } + case type::Descriptor::eTuple: + { + nlohmann::json ret = element[currentIndex]; + return ret; + } + case type::Descriptor::eList: + { + nlohmann::json ret = element[io::Data::READER_WRITER_LIST_ACCEPTED_TYPE_SLUG]; + return ret; + } + default: + throw exception::DescriptorNotValidException("NlohmannJSONReaderToken", "getNextElement", "Could not resove a type of a navigator. Allowed are only container types due to performance", descriptor); + } + } + + private: + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.cpp b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.cpp similarity index 75% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.cpp index 3c3d099d8df5c6a67a12c643d91490ddf4412f2f..d2b8fc47130d28252e4755b615ad1b2a2575c413 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriterVisitor/AronTypeWriterVisitor.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.cpp @@ -23,10 +23,10 @@ #include <numeric> // Header -#include "AronTypeWriterVisitor.h" +#include "Visitor.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronResolver.h> +#include <RobotAPI/libraries/aron/aroncore/Resolver.h> @@ -37,14 +37,14 @@ namespace armarx namespace io { - void AronTypeWriterVisitor::SetupWriterFromAronTypePtr(AronTypeWriter& writer, const typenavigator::AronTypeNavigatorPtr& aron) + void Visitor::SetupWriterFromAronTypePtr(Writer& writer, const typenavigator::NavigatorPtr& aron) { SetupWriterFromAronTypePtr(writer, aron->getResult()); } - void AronTypeWriterVisitor::SetupWriterFromAronTypePtr(AronTypeWriter& writer, const type::AronTypePtr& aron) + void Visitor::SetupWriterFromAronTypePtr(Writer& writer, const type::AronTypePtr& aron) { - AronTypeDescriptor desc = AronResolver::GetDescriptorForAronType(aron); + type::Descriptor desc = AronResolver::GetDescriptor(aron); switch (desc) { case eAronObjectType: @@ -55,7 +55,7 @@ namespace armarx for (const auto& [key, value] : casted->elementTypes) { writer.writeKey(key); - AronTypeWriterVisitor::SetupWriterFromAronTypePtr(writer, value); + Visitor::SetupWriterFromAronTypePtr(writer, value); } writer.writeEndObjectType(); break; @@ -64,7 +64,7 @@ namespace armarx { type::AronDictTypePtr casted = type::AronDictTypePtr::dynamicCast(aron); writer.writeStartDictType(); - AronTypeWriterVisitor::SetupWriterFromAronTypePtr(writer, casted->acceptedType); + Visitor::SetupWriterFromAronTypePtr(writer, casted->acceptedType); writer.writeEndDictType(); break; } @@ -74,7 +74,7 @@ namespace armarx writer.writeStartTupleType(); for (const auto& value : casted->elementTypes) { - AronTypeWriterVisitor::SetupWriterFromAronTypePtr(writer, value); + Visitor::SetupWriterFromAronTypePtr(writer, value); } writer.writeEndTupleType(); break; @@ -83,7 +83,7 @@ namespace armarx { type::AronListTypePtr casted = type::AronListTypePtr::dynamicCast(aron); writer.writeStartListType(); - AronTypeWriterVisitor::SetupWriterFromAronTypePtr(writer, casted->acceptedType); + Visitor::SetupWriterFromAronTypePtr(writer, casted->acceptedType); writer.writeEndListType(); break; } @@ -95,7 +95,7 @@ case eAron##upperType##Type: \ break; \ } - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ @@ -111,7 +111,7 @@ case eAron##upperType##Type: \ default: { - throw exception::AronTypeDescriptorNotValidException("LegacyAronTypeWriter", "SetupWriterFromAronTypePtr", "Type-Type could not be resolved. The ice_id of the input was: " + aron->ice_id(), desc); + throw exception::DescriptorNotValidException("LegacyAronTypeWriter", "SetupWriterFromAronTypePtr", "Type-Type could not be resolved. The ice_id of the input was: " + aron->ice_id(), desc); } } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.h similarity index 51% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.h index 902e9c59e7ba6ada4d18325fb1c527b2348cdf6d..33ebbdb028e6d4fe4dd60e124404e155041dd811 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriterVisitor/AronDataWriterVisitor.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/visitor/Visitor.h @@ -24,36 +24,26 @@ #include <memory> #include <string> -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/AronDataWriter.h> - // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/Writer.h> -namespace armarx +namespace armarx::aron::typeIO { - namespace aron + class Visitor; + typedef std::shared_ptr<Visitor> VisitorPtr; + + class Visitor { - namespace io - { - class AronDataWriterVisitor; - typedef std::shared_ptr<AronDataWriterVisitor> AronDataWriterVisitorPtr; - - class AronDataWriterVisitor - { - private: - AronDataWriterVisitor() = delete; - - public: - static void SetupWriterFromAronDataPtr(AronDataWriter&, const datanavigator::AronDataNavigatorPtr&); - static void SetupWriterFromAronDataPtr(AronDataWriter&, const data::AronDataPtr&); - - public: - }; - } - } + private: + Visitor() = delete; + + public: + static void SetupWriterFromAronTypePtr(Writer&, const typenavigator::NavigatorPtr&); + static void SetupWriterFromAronTypePtr(Writer&, const type::AronTypePtr&); + + public: + }; } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/Writer.h similarity index 72% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/Writer.h index 972d0517384ad1a0a3a53903958570a2c409e87f..c35f32d0c94aee745a7f4a98be5b47c112f032f5 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/Writer.h @@ -26,28 +26,24 @@ #include <stack> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/AronTypeWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/Writer.h> -namespace armarx -{ - namespace aron - { - namespace io +namespace armarx::aron::typeIO { template <typename GeneratePtr, typename TokenPtr> - class AronTypeClassWriter; + class TokenizedWriter; template <typename GeneratePtr, typename TokenPtr> - using AronTypeClassWriterPtr = std::shared_ptr<AronTypeClassWriter<GeneratePtr, TokenPtr>>; + using TokenizedWriterPtr = std::shared_ptr<TokenizedWriter<GeneratePtr, TokenPtr>>; template <typename GeneratePtr, typename TokenPtr> - class AronTypeClassWriter : - virtual public AronTypeWriter + class TokenizedWriter : + virtual public Writer { public: - AronTypeClassWriter() = default; + TokenizedWriter() = default; virtual bool writeKey(const std::string& k) override { @@ -75,18 +71,18 @@ namespace armarx { if (lastRemovedToken == nullptr) { - throw exception::AronException("AronTypeClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken is NULL. Perhaps you never called a writeEnd* method?"); + throw exception::AronException("ClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken is NULL. Perhaps you never called a writeEnd* method?"); } if (lastRemovedToken->getElement() == nullptr) { - throw exception::AronException("AronTypeClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken->getElement() is NULL."); + throw exception::AronException("ClassWriter", "assertLastRemovedTokenIsSet", "lastRemovedToken->getElement() is NULL."); } } void assertStackIsEmpty() const { if (stack.size() != 0) { - throw exception::AronException("AronTypeClassWriter", "assertStackIsEmpty", "The Size of the stack is not 0. Perhaps you never called a writeEnd* method?"); + throw exception::AronException("ClassWriter", "assertStackIsEmpty", "The Size of the stack is not 0. Perhaps you never called a writeEnd* method?"); } } @@ -95,6 +91,5 @@ namespace armarx TokenPtr lastRemovedToken; std::stack<TokenPtr> stack; }; - } - } } + diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/WriterToken.h similarity index 55% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriterToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/WriterToken.h index 5b016ca9f3e6245200500feb6d3be97cd6aae53b..fb94b397a2d722e0d762f075b0520b7db31d789f 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriterToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/WriterToken.h @@ -25,35 +25,31 @@ #include <string> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/WriterToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> -namespace armarx +namespace armarx::aron::typeIO { - namespace aron - { - namespace io - { template<typename ElementPtrTypename, typename ElementAddTypename> - class AronTypeClassWriterToken; + class WriterToken; template<typename ElementPtrTypename, typename ElementAddTypename> - using AronTypeClassWriterTokenPtr = std::shared_ptr<AronTypeClassWriterToken<ElementPtrTypename, ElementAddTypename>>; + using WriterTokenPtr = std::shared_ptr<WriterToken<ElementPtrTypename, ElementAddTypename>>; template<typename ElementPtrTypename, typename ElementAddTypename> - class AronTypeClassWriterToken : - virtual public AronWriterToken<AronTypeDescriptor, ElementPtrTypename, ElementAddTypename> + class WriterToken : + virtual public io::WriterToken<type::Descriptor, ElementPtrTypename, ElementAddTypename> { public: - using PointerType = AronTypeClassWriterToken<ElementPtrTypename, ElementAddTypename>; + using PointerType = WriterToken<ElementPtrTypename, ElementAddTypename>; public: // constructor - AronTypeClassWriterToken() = delete; - AronTypeClassWriterToken(const AronTypeDescriptor desc, const ElementPtrTypename& n) : - AronWriterToken<AronTypeDescriptor, ElementPtrTypename, ElementAddTypename>(desc, n) + WriterToken() = delete; + WriterToken(const type::Descriptor desc, const ElementPtrTypename& n) : + io::WriterToken<type::Descriptor, ElementPtrTypename, ElementAddTypename>(desc, n) {} // public member functions @@ -61,25 +57,23 @@ namespace armarx virtual std::string toElementAccessor() const override { - AronTypeDescriptor desc = this->getDescriptor(); + type::Descriptor desc = this->getDescriptor(); switch (desc) { - case eAronDictType: - case eAronListType: + case type::Descriptor::eDict: + case type::Descriptor::eList: return "[ACCEPTED_TYPE]"; - case eAronObjectType: + case type::Descriptor::eObject: return "\"" + this->currentKey + "\""; - case eAronTupleType: + case type::Descriptor::eTuple: return "<" + std::to_string(this->currentIndex) + ">"; default: - throw exception::AronTypeDescriptorNotValidException("AronTypeNavigatorWriterToken", "toElementAccessor", "Could not resove a type of a navigator. Allowed are only containers.", desc); + throw exception::DescriptorNotValidException("NavigatorWriterToken", "toElementAccessor", "Could not resove a type of a navigator. Allowed are only containers.", desc); } } - virtual void setName(const std::string& n) = 0; + virtual void setObjectName(const std::string& n) = 0; private: }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.cpp similarity index 74% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.cpp index 8e05757db32997bedcb40de946bdbdda3ac8431f..6b3b6a5f858c803b89a99663ccdd02ce2da63c7e 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.cpp @@ -23,16 +23,16 @@ #include <numeric> // Header -#include "AronTypeNavigatorWriter.h" +#include "NavigatorWriter.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h> @@ -43,17 +43,17 @@ namespace armarx namespace io { - AronPath AronTypeNavigatorWriter::generateAronPath() + Path NavigatorWriter::generatePath() { - AronPath path; + Path path; if (!wroteInitialStartContainer) { wroteInitialStartContainer = true; } else { - AronTypeNavigatorWriterTokenPtr parent_token = stack.top(); - path = AronPath(parent_token->getElement()->getPath(), parent_token->toElementAccessor()); + NavigatorWriterTokenPtr parent_token = stack.top(); + path = Path(parent_token->getElement()->getPath(), parent_token->toElementAccessor()); } return path; } @@ -61,7 +61,7 @@ namespace armarx #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ bool AronTypeNavigatorWriter::writeStart##upperType##Type() \ { \ - AronPath path = generateAronPath(); \ + Path path = generatePath(); \ typenavigator::Aron##upperType##TypeNavigatorPtr type = typenavigator::Aron##upperType##TypeNavigatorPtr(new typenavigator::Aron##upperType##TypeNavigator(path)); \ AronTypeNavigatorWriterTokenPtr new_token = AronTypeNavigatorWriterTokenPtr(new AronTypeNavigatorWriterToken(type->getDescriptor(), type)); \ stack.push(new_token); \ @@ -86,7 +86,7 @@ namespace armarx #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ bool AronTypeNavigatorWriter::write##upperType##Type(const std::vector<int>& dims, const std::string& t) \ { \ - AronPath path = generateAronPath(); \ + Path path = generatePath(); \ AronTypeNavigatorWriterTokenPtr token = stack.top(); \ typenavigator::Aron##upperType##TypeNavigatorPtr aron(new typenavigator::Aron##upperType##TypeNavigator(path)); \ aron->setUsedType(t); \ @@ -95,13 +95,13 @@ namespace armarx return true; \ } - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ bool AronTypeNavigatorWriter::write##upperType##Type() \ { \ - AronPath path = generateAronPath(); \ + Path path = generatePath(); \ AronTypeNavigatorWriterTokenPtr token = stack.top(); \ typenavigator::Aron##upperType##TypeNavigatorPtr aron(new typenavigator::Aron##upperType##TypeNavigator(path)); \ token->addElement(aron); \ diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.h similarity index 56% rename from source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.h index 480bddb1d1f9bc2f7c857c3cf8b1d846bd294e28..346ab758bcd349c53aae28b966ad1ccfc59007c8 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.h @@ -20,54 +20,52 @@ #pragma once -// STD / STL +// STD/STL #include <memory> #include <stack> -#include <sstream> -// Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/AronDataClassWriter.h> +// BaseClass +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/Writer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriterToken.h> -namespace armarx +namespace armarx::aron::typeIO::writer { - namespace aron - { - namespace io - { - class AronDataRapidXMLWriter; - typedef std::shared_ptr<AronDataRapidXMLWriter> AronDataRapidXMLWriterPtr; + class NavigatorWriter; + typedef std::shared_ptr<NavigatorWriter> NavigatorWriterPtr; - class AronDataRapidXMLWriter : - virtual public AronDataClassWriter<RapidXmlReaderNode, AronDataRapidXMLWriterTokenPtr> + class NavigatorWriter : + virtual public TokenizedWriter<typenavigator::NavigatorPtr, NavigatorWriterTokenPtr> { public: - AronDataRapidXMLWriter() = default; + NavigatorWriter() = default; #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ virtual bool writeStart##upperType() override; \ virtual bool writeEnd##upperType() override; - HANDLE_CONTAINER_DATA + HANDLE_CONTAINER_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType(const std::vector<int>&, const std::string&, const unsigned char*) override; \ + virtual bool writeStart##upperType(const std::vector<int>&, const std::string&) override; \ + virtual bool writeEnd##upperType() override; - HANDLE_COMPLEX_DATA + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool writePrimitive(const lowerType&) override; + virtual bool write##upperType() override; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO + private: + Path generatePath(); + private: }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriterToken.h new file mode 100644 index 0000000000000000000000000000000000000000..76c414e95e8561beae221f5b4cac98a57ba442fb --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriterToken.h @@ -0,0 +1,99 @@ +/* +* This file is part of ArmarX. +* +* 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/>. +* +* @author Fabian Peller (fabian dot peller at kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#pragma once + +// STD/STL +#include <memory> +#include <string> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/WriterToken.h> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/Config.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h> + +namespace armarx::aron::typeIO::writer +{ + class NavigatorWriterToken; + typedef std::shared_ptr<NavigatorWriterToken> NavigatorWriterTokenPtr; + + class NavigatorWriterToken : + virtual public WriterToken<typenavigator::NavigatorPtr, typenavigator::NavigatorPtr> + { + public: + using PointerType = NavigatorWriterTokenPtr; + + public: + // constructor + NavigatorWriterToken() = delete; + NavigatorWriterToken(const type::Descriptor desc, const typenavigator::NavigatorPtr& t) : + io::WriterToken<type::Descriptor, typenavigator::NavigatorPtr, typenavigator::NavigatorPtr>(desc, t), + WriterToken<typenavigator::NavigatorPtr, typenavigator::NavigatorPtr>(desc, t) + { + } + + // virtual member functions + virtual void addElement(const typenavigator::NavigatorPtr& n) override + { + switch (descriptor) + { + case type::Descriptor::eDict: + { + typenavigator::DictNavigatorPtr casted = typenavigator::DictNavigator::DynamicCastAndCheck(element); + casted->setAcceptedType(n); + break; + } + case type::Descriptor::eList: + { + typenavigator::ListNavigatorPtr casted = typenavigator::ListNavigator::DynamicCastAndCheck(element); + casted->setAcceptedType(n); + break; + } + case type::Descriptor::eObject: + { + typenavigator::ObjectNavigatorPtr casted = typenavigator::ObjectNavigator::DynamicCastAndCheck(element); + casted->addAcceptedType(currentKey, n); + break; + } + case type::Descriptor::eTuple: + { + typenavigator::TupleNavigatorPtr casted = typenavigator::TupleNavigator::DynamicCastAndCheck(element); + casted->addAcceptedType(n); + currentIndex++; + break; + } + default: + throw exception::DescriptorNotValidException("NavigatorWriterToken", "addElement", "Could not resove a type of a navigator. Allowed are only containers. The path was: " + getElement()->pathToString(), descriptor); + } + } + + virtual void setObjectName(const std::string& n) override + { + if (descriptor != type::Descriptor::eObject) + { + throw exception::DescriptorNotValidException("NavigatorWriterToken", "setName", "Cant set the name of a non-object token. The path was: " + getElement()->pathToString(), descriptor); + } + typenavigator::ObjectNavigatorPtr casted = typenavigator::ObjectNavigator::DynamicCast(element); + casted->setObjectName(n); + } + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.cpp b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp similarity index 93% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.cpp rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp index f40e1ee6da8ea092e04265373c300ddddb7d016e..ec256871e34224a7f70d1b45ec8a25f6b09db8b2 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriter.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.cpp @@ -21,7 +21,7 @@ * GNU General Public License */ -#include "AronTypeNlohmannJSONWriter.h" +#include "NlohmannJSONWriter.h" namespace armarx { @@ -33,7 +33,7 @@ namespace armarx bool AronTypeNlohmannJSONWriter::writeStart##upperType##Type() \ { \ nlohmann::json data; \ - AronTypeNlohmannJSONWriterTokenPtr new_token = AronTypeNlohmannJSONWriterTokenPtr(new AronTypeNlohmannJSONWriterToken(AronTypeDescriptor::eAron##upperType##Type, data)); \ + AronTypeNlohmannJSONWriterTokenPtr new_token = AronTypeNlohmannJSONWriterTokenPtr(new AronTypeNlohmannJSONWriterToken(type::Descriptor::eAron##upperType##Type, data)); \ stack.push(new_token); \ return true; \ } \ @@ -65,7 +65,7 @@ namespace armarx return true; \ } - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.h similarity index 61% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.h index f449391e69f453b22d906501145ecc49cdc53725..b484af1d30d7db7ce798640223a06892cd7622f0 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriter.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriter.h @@ -26,37 +26,36 @@ #include <sstream> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/Writer.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/RapidXMLWriter/AronTypeRapidXMLWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h> -namespace armarx -{ - namespace aron - { - namespace io +namespace armarx::aron::typeIO::writer { - class AronTypeXMLWriter : - virtual public AronTypeClassWriter<RapidXmlReaderNode, AronTypeRapidXMLWriterTokenPtr> + class NlohmannJSONWriter : + virtual public TokenizedWriter<nlohmann::json, NlohmannJSONWriterTokenPtr> { public: + NlohmannJSONWriter() = default; + #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool writeStart##upperType##Type() override; \ - virtual bool writeEnd##upperType##Type() override; + virtual bool writeStart##upperType() override; \ + virtual bool writeEnd##upperType() override; HANDLE_CONTAINER_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type(const std::vector<int>&, const std::string&) override; \ + virtual bool writeStart##upperType(const std::vector<int>&, const std::string&) override; \ + virtual bool writeEnd##upperType() override; - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - virtual bool write##upperType##Type() override; + virtual bool write##upperType() override; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO @@ -64,6 +63,4 @@ namespace armarx private: }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriterToken.h b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h similarity index 50% rename from source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriterToken.h rename to source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h index 0635697480291309988873a91fe8a3946719bd4a..a8426f8f26ca0df1311631d5175585592d8cfd01 100644 --- a/source/RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NlohmannJSONWriter/AronTypeNlohmannJSONWriterToken.h +++ b/source/RobotAPI/libraries/aron/aroncore/io/typeIO/writer/nlohmannJSON/NlohmannJSONWriterToken.h @@ -28,32 +28,28 @@ #include <SimoxUtility/json.h> // Base Class -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriterToken.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/WriterToken.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConfig.h> +#include <RobotAPI/libraries/aron/aroncore/Config.h> -namespace armarx -{ - namespace aron - { - namespace io +namespace armarx::aron::typeIO::writer { - class AronTypeNlohmannJSONWriterToken; - typedef std::shared_ptr<AronTypeNlohmannJSONWriterToken> AronTypeNlohmannJSONWriterTokenPtr; + class NlohmannJSONWriterToken; + typedef std::shared_ptr<NlohmannJSONWriterToken> NlohmannJSONWriterTokenPtr; - class AronTypeNlohmannJSONWriterToken : - virtual public AronTypeClassWriterToken<nlohmann::json, nlohmann::json> + class NlohmannJSONWriterToken : + virtual public WriterToken<nlohmann::json, nlohmann::json> { public: - using PointerType = AronTypeNlohmannJSONWriterTokenPtr; + using PointerType = NlohmannJSONWriterTokenPtr; public: // constructor - AronTypeNlohmannJSONWriterToken() = delete; - AronTypeNlohmannJSONWriterToken(const AronTypeDescriptor desc, const nlohmann::json& t) : - AronWriterToken<AronTypeDescriptor, nlohmann::json, nlohmann::json>(desc, t), - AronTypeClassWriterToken<nlohmann::json, nlohmann::json>(desc, t) + NlohmannJSONWriterToken() = delete; + NlohmannJSONWriterToken(const type::Descriptor desc, const nlohmann::json& t) : + io::WriterToken<type::Descriptor, nlohmann::json, nlohmann::json>(desc, t), + WriterToken<nlohmann::json, nlohmann::json>(desc, t) { } @@ -63,43 +59,41 @@ namespace armarx auto desc = getDescriptor(); switch (desc) { - case eAronDictType: + case type::Descriptor::eDict: { - element[ARON_READER_WRITER_TOKEN_DICT_ACCEPTED_TYPE_SLUG] = n; + element[io::Data::READER_WRITER_DICT_ACCEPTED_TYPE_SLUG] = n; break; } - case eAronListType: + case type::Descriptor::eList: { - element[ARON_READER_WRITER_TOKEN_LIST_ACCEPTED_TYPE_SLUG] = n; + element[io::Data::READER_WRITER_LIST_ACCEPTED_TYPE_SLUG] = n; break; } - case eAronObjectType: + case type::Descriptor::eObject: { element[currentKey] = n; break; } - case eAronTupleType: + case type::Descriptor::eTuple: { element.push_back(n); break; } default: - throw exception::AronTypeDescriptorNotValidException("AronTypeNlohmannJSONWriterToken", "addElement", "Could not resove a type of a navigator. Allowed are only containers.", desc); + throw exception::DescriptorNotValidException("NlohmannJSONWriterToken", "addElement", "Could not resove a type of a navigator. Allowed are only containers.", desc); } } // name functions - void setName(const std::string& n) override + void setObjectName(const std::string& n) override { auto desc = getDescriptor(); - if (desc != AronTypeDescriptor::eAronObjectType) + if (desc != type::Descriptor::eObject) { - throw exception::AronTypeDescriptorNotValidException("AronTypeNlohmannJSONWriterToken", "setName", "Cant set the name of a non-object token.", desc); + throw exception::DescriptorNotValidException("NlohmannJSONWriterToken", "setName", "Cant set the name of a non-object token.", desc); } - element[ARON_READER_WRITER_TOKEN_OBJECT_NAME_SLUG] = n; + element[io::Data::READER_WRITER_OBJECT_NAME_SLUG] = n; } }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/AronNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/Navigator.h similarity index 71% rename from source/RobotAPI/libraries/aron/aroncore/navigators/AronNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/Navigator.h index bac611dd5f685ebe36736be30f1732501aaa418e..6f2608825b693361153f6d4ace2f73251ec9f9ab 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/AronNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/Navigator.h @@ -29,32 +29,27 @@ #include <unordered_map> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> +#include <RobotAPI/libraries/aron/aroncore/Resolver.h> +#include <RobotAPI/libraries/aron/aroncore/Path.h> -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> -#include <RobotAPI/libraries/aron/aroncore/AronResolver.h> -#include <RobotAPI/libraries/aron/aroncore/AronPath.h> - -namespace armarx +namespace armarx::aron { - namespace aron - { - namespace navigator - { template <typename Descriptor, typename Aron> //requires isAron<Aron>&& isTypeDescriptor<Descriptor> - class AronNavigator; + class Navigator; template <typename Descriptor, typename Aron> //requires isAron<Aron>&& isTypeDescriptor<Descriptor> - using AronNavigatorPtr = std::shared_ptr<AronNavigator<Descriptor, Aron>>; + using NavigatorPtr = std::shared_ptr<Navigator<Descriptor, Aron>>; template <typename Descriptor, typename Aron> //requires isAron<Aron>&& isTypeDescriptor<Descriptor> - class AronNavigator + class Navigator { public: // constructors - AronNavigator() = delete; - AronNavigator(const Descriptor& descriptor, const AronPath& path) : + Navigator() = delete; + Navigator(const Descriptor& descriptor, const Path& path) : descriptor(descriptor), path(path) { @@ -66,7 +61,7 @@ namespace armarx return descriptor; } - AronPath getPath() const + Path getPath() const { return path; } @@ -81,19 +76,17 @@ namespace armarx virtual std::string getName() const = 0; protected: - static void CheckAronPtrForNull(const std::string& c, const std::string& m, const AronPath& p, const typename Aron::PointerType& data) + static void CheckAronPtrForNull(const std::string& c, const std::string& m, const Path& p, const typename Aron::PointerType& data) { if (data.get() == nullptr) { - throw exception::AronExceptionWithPathInfo(c, m, "Could not cast an AronPtr. The Ptr was NULL.", p); + throw exception::AronException(c, m, "Could not cast an AronPtr. The Ptr was NULL.", p); } } private: // members const Descriptor descriptor; - const AronPath path; + const Path path; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/AronNavigatorFactory.h b/source/RobotAPI/libraries/aron/aroncore/navigator/NavigatorFactory.h similarity index 58% rename from source/RobotAPI/libraries/aron/aroncore/navigators/AronNavigatorFactory.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/NavigatorFactory.h index e893a001bf33bd97a091328f7ba874a8ef075124..1e0c7d98098ef796b2f27b717cc61a9e08ed3c84 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/AronNavigatorFactory.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/NavigatorFactory.h @@ -29,31 +29,23 @@ #include <unordered_map> // Base Class -#include <RobotAPI/libraries/aron/aroncore/AronFactory.h> +#include <RobotAPI/libraries/aron/aroncore/Factory.h> // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> - #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> -#include <RobotAPI/libraries/aron/aroncore/AronPath.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> +#include <RobotAPI/libraries/aron/aroncore/Path.h> -namespace armarx +namespace armarx::aron { - namespace aron + template <typename Input, typename Output> // requires ... + class NavigatorFactory : + virtual public Factory<Input, Output> { - namespace navigator - { - template <typename Input, typename Output> // requires ... - class AronNavigatorFactory : - virtual public AronPtrInputPtrOutputFactory<Input, Output> - { - public: - AronNavigatorFactory() = default; + public: + NavigatorFactory() = default; - virtual Output create(const Input&, const AronPath&) const = 0; - virtual Output createSpecific(const Input&, const AronPath&) const = 0; - }; - } - } + virtual Output create(const Input&, const Path&) const = 0; + virtual Output createSpecific(const Input&, const Path&) const = 0; + }; } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h b/source/RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h new file mode 100644 index 0000000000000000000000000000000000000000..9ea0326951e3488d1cbf9870a2a50c475f6708f5 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/AllNavigators.h @@ -0,0 +1,6 @@ +#pragma once + +#include "container/Dict.h" +#include "container/List.h" +#include "complex/NDArray.h" +#include "primitive/Primitive.h" diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.cpp similarity index 60% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.cpp index 60cd87b6092974b5dcbc12d9fd9e683e48099db1..460ee38b8e4f0c8de7655656cb84be1d9c031f69 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.cpp @@ -22,11 +22,11 @@ */ // Header -#include "AronDataNavigator.h" +#include "Navigator.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h> namespace armarx { @@ -35,30 +35,30 @@ namespace armarx namespace datanavigator { // static data members - const AronDataNavigatorFactoryPtr AronDataNavigator::FACTORY = AronDataNavigatorFactoryPtr(new AronDataNavigatorFactory()); + const NavigatorFactoryPtr Navigator::FACTORY = NavigatorFactoryPtr(new NavigatorFactory()); // constructors - AronDataNavigator::AronDataNavigator(const AronDataDescriptor& descriptor, const AronPath& path) : - navigator::AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(descriptor, path) + Navigator::Navigator(const data::Descriptor& descriptor, const Path& path) : + navigator::AronNavigator<data::Descriptor, data::AronData>::AronNavigator(descriptor, path) { } // static methods - AronDataNavigatorPtr AronDataNavigator::FromAronData(const data::AronDataPtr& a, const AronPath& path) + NavigatorPtr Navigator::FromAronData(const data::AronDataPtr& a, const Path& path) { return FACTORY->create(a, path); } - std::vector<AronDataNavigatorPtr> AronDataNavigator::FromAronData(const std::vector<data::AronDataPtr>& a, const AronPath& path) + std::vector<NavigatorPtr> Navigator::FromAronData(const std::vector<data::AronDataPtr>& a, const Path& path) { - std::vector<AronDataNavigatorPtr> ret; + std::vector<NavigatorPtr> ret; for (const auto& aron : a) { - ret.push_back(AronDataNavigator::FromAronData(aron, path)); + ret.push_back(Navigator::FromAronData(aron, path)); } return ret; } - std::vector<data::AronDataPtr> AronDataNavigator::ToAronData(const std::vector<AronDataNavigatorPtr>& a) + std::vector<data::AronDataPtr> Navigator::ToAronData(const std::vector<NavigatorPtr>& a) { std::vector<data::AronDataPtr> ret; for (const auto& aron : a) @@ -68,7 +68,7 @@ namespace armarx return ret; } - void AronDataNavigator::CheckDataNavigatorPtrForNull(const std::string& c, const std::string& m, const AronDataNavigatorPtr& data) + void Navigator::CheckDataNavigatorPtrForNull(const std::string& c, const std::string& m, const NavigatorPtr& data) { if (data.get() == nullptr) { @@ -76,22 +76,22 @@ namespace armarx } } - void AronDataNavigator::CheckDataNavigatorPtrForNull(const std::string& c, const std::string& m, const AronPath& p, const AronDataNavigatorPtr& data) + void Navigator::CheckDataNavigatorPtrForNull(const std::string& c, const std::string& m, const Path& p, const NavigatorPtr& data) { if (data.get() == nullptr) { - throw exception::AronExceptionWithPathInfo(c, m, "Could not make use of an AronDataNavigatorPtr. The Ptr was NULL", p); + throw exception::AronException(c, m, "Could not make use of an AronDataNavigatorPtr. The Ptr was NULL", p); } } - AronContainerDataNavigatorPtr AronContainerDataNavigator::DynamicCast(const AronDataNavigatorPtr& n) + AronContainerDataNavigatorPtr AronContainerDataNavigator::DynamicCast(const NavigatorPtr& n) { AronContainerDataNavigatorPtr casted = std::dynamic_pointer_cast<AronContainerDataNavigator>(n); return casted; } - AronContainerDataNavigatorPtr AronContainerDataNavigator::DynamicCastAndCheck(const AronDataNavigatorPtr& n) + AronContainerDataNavigatorPtr AronContainerDataNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckDataNavigatorPtrForNull("AronContainerDataNavigator", "DynamicCastAndCheck[Before]", n); AronContainerDataNavigatorPtr casted = AronContainerDataNavigator::DynamicCast(n); @@ -99,9 +99,9 @@ namespace armarx return casted; } - AronDataNavigatorPtr AronContainerDataNavigator::navigateRelative(const AronPath& path) const + NavigatorPtr AronContainerDataNavigator::navigateRelative(const Path& path) const { - AronPath absoluteFromHere = path.getWithoutPrefix(getPath()); + Path absoluteFromHere = path.getWithoutPrefix(getPath()); return navigateAbsolute(absoluteFromHere); } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h similarity index 63% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h index 0f23c7137ae3f61f89e5266b0b36e06d4f6b57e8..c1f5ec70089ac03d447f99ae4912492537f8cd7b 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h @@ -30,49 +30,45 @@ // ArmarX #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/AronNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/AronPath.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/Path.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> -namespace armarx +namespace armarx::aron::datanavigator { - namespace aron - { - namespace datanavigator - { - class AronDataNavigatorFactory; - typedef std::shared_ptr<AronDataNavigatorFactory> AronDataNavigatorFactoryPtr; - - class AronDataNavigator; - typedef std::shared_ptr<AronDataNavigator> AronDataNavigatorPtr; - - class AronDataNavigator : - virtual public navigator::AronNavigator<AronDataDescriptor, data::AronData> + class NavigatorFactory; + typedef std::shared_ptr<NavigatorFactory> NavigatorFactoryPtr; + + class Navigator; + typedef std::shared_ptr<Navigator> NavigatorPtr; + + class Navigator : + virtual public aron::Navigator<data::Descriptor, data::AronData> { public: - using PointerType = AronDataNavigatorPtr; + using PointerType = NavigatorPtr; public: // constructors - AronDataNavigator() = delete; - AronDataNavigator(const AronDataDescriptor&, const AronPath& p = AronPath()); + Navigator() = delete; + Navigator(const data::Descriptor&, const Path& p = Path()); // operators - virtual bool equalsDataNavigator(const AronDataNavigatorPtr&) const = 0; + virtual bool equalsDataNavigator(const NavigatorPtr&) const = 0; // static methods - static AronDataNavigatorPtr FromAronData(const data::AronDataPtr&, const AronPath& = AronPath()); - static std::vector<AronDataNavigatorPtr> FromAronData(const std::vector<data::AronDataPtr>&, const AronPath& = AronPath()); - static std::vector<data::AronDataPtr> ToAronData(const std::vector<AronDataNavigatorPtr>&); + static NavigatorPtr FromAronData(const data::AronDataPtr&, const Path& = Path()); + static std::vector<NavigatorPtr> FromAronData(const std::vector<data::AronDataPtr>&, const Path& = Path()); + static std::vector<data::AronDataPtr> ToAronData(const std::vector<NavigatorPtr>&); template<typename AronNavigatorType> - static typename AronNavigatorType::PointerType DynamicCast(const AronDataNavigatorPtr& n) + static typename AronNavigatorType::PointerType DynamicCast(const NavigatorPtr& n) { return AronNavigatorType::DynamicCast(n); } template<typename AronNavigatorType> - static typename AronNavigatorType::PointerType DynamicCastAndCheck(const AronDataNavigatorPtr& n) + static typename AronNavigatorType::PointerType DynamicCastAndCheck(const NavigatorPtr& n) { return AronNavigatorType::DynamicCastAndCheck(n); } @@ -82,50 +78,51 @@ namespace armarx virtual std::string getName() const override = 0; // virtual definitions - virtual std::vector<AronDataNavigatorPtr> getChildren() const = 0; + virtual std::vector<NavigatorPtr> getChildren() const = 0; virtual size_t childrenSize() const = 0; - virtual typenavigator::AronTypeNavigatorPtr recalculateType() const = 0; - virtual bool fullfillsType(const typenavigator::AronTypeNavigatorPtr&) const = 0; + virtual typenavigator::NavigatorPtr recalculateType() const = 0; + virtual bool fullfillsType(const typenavigator::NavigatorPtr&) const = 0; protected: - static void CheckDataNavigatorPtrForNull(const std::string&, const std::string&, const AronDataNavigatorPtr&); - static void CheckDataNavigatorPtrForNull(const std::string&, const std::string&, const AronPath&, const AronDataNavigatorPtr&); + static void CheckDataNavigatorPtrForNull(const std::string&, const std::string&, const NavigatorPtr&); + static void CheckDataNavigatorPtrForNull(const std::string&, const std::string&, const Path&, const NavigatorPtr&); private: - static const AronDataNavigatorFactoryPtr FACTORY; + static const NavigatorFactoryPtr FACTORY; }; + /* class AronContainerDataNavigator; typedef std::shared_ptr<AronContainerDataNavigator> AronContainerDataNavigatorPtr; class AronContainerDataNavigator : - virtual public AronDataNavigator + virtual public Navigator { public: using PointerType = AronContainerDataNavigatorPtr; // virtual definitions - virtual AronDataNavigatorPtr navigateAbsolute(const AronPath& path) const = 0; + virtual NavigatorPtr navigateAbsolute(const Path& path) const = 0; // member functions - AronDataNavigatorPtr navigateRelative(const AronPath& path) const; + NavigatorPtr navigateRelative(const Path& path) const; // static definitions - static AronContainerDataNavigatorPtr DynamicCast(const AronDataNavigatorPtr& n); - static AronContainerDataNavigatorPtr DynamicCastAndCheck(const AronDataNavigatorPtr& n); + static AronContainerDataNavigatorPtr DynamicCast(const NavigatorPtr& n); + static AronContainerDataNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); }; class AronComplexDataNavigator; typedef std::shared_ptr<AronComplexDataNavigator> AronComplexDataNavigatorPtr; class AronComplexDataNavigator : - virtual public AronDataNavigator + virtual public Navigator { public: using PointerType = AronComplexDataNavigatorPtr; - static AronComplexDataNavigatorPtr DynamicCast(const AronDataNavigatorPtr& n) + static AronComplexDataNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronComplexDataNavigatorPtr casted = std::dynamic_pointer_cast<AronComplexDataNavigator>(n); return casted; @@ -136,18 +133,15 @@ namespace armarx typedef std::shared_ptr<AronPrimitiveDataNavigator> AronPrimitiveDataNavigatorPtr; class AronPrimitiveDataNavigator : - virtual public AronDataNavigator + virtual public Navigator { public: using PointerType = AronPrimitiveDataNavigatorPtr; - static AronPrimitiveDataNavigatorPtr DynamicCast(const AronDataNavigatorPtr& n) + static AronPrimitiveDataNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronPrimitiveDataNavigatorPtr casted = std::dynamic_pointer_cast<AronPrimitiveDataNavigator>(n); return casted; } - }; - - } - } + };*/ } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.cpp similarity index 63% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.cpp index a344953d9e79df70031fbeaef172f08e976b725a..a2de3d682d02556739347d2517f0c805abbd6d91 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.cpp @@ -24,7 +24,7 @@ // STD/STL // Header -#include "AronDataNavigatorFactory.h" +#include "NavigatorFactory.h" namespace armarx { @@ -33,40 +33,37 @@ namespace armarx namespace datanavigator { - // Map types to factories - const std::map<AronDataDescriptor, AronDataNavigatorFactoryPtr> AronDataNavigatorFactory::FACTORIES = + // Access method + NavigatorPtr NavigatorFactory::create(const data::AronDataPtr& aron, const Path& path) const { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - {AronResolver::GetDescriptorForAronDataId(typeid(data::Aron##upperType)), AronDataNavigatorFactoryPtr(new Aron##upperType##DataNavigatorFactory())}, \ + {AronResolver::GetDescriptorForAronDataId(typeid(data::Aron##upperType)), AronDataNavigatorFactoryPtr(new Aron##upperType##DataNavigatorFactory())}, - HANDLE_CONTAINER_DATA - HANDLE_COMPLEX_DATA - HANDLE_PRIMITIVE_TYPES + static const std::map<data::Descriptor, NavigatorFactoryPtr> FACTORIES = + { + HANDLE_ALL_ARON_DATA + }; #undef RUN_ARON_MACRO - }; - // Access method - AronDataNavigatorPtr AronDataNavigatorFactory::create(const data::AronDataPtr& aron, const AronPath& path) const - { - CheckIfInputIsNull("AronDataNavigatorFactory", "create", path, aron); + CheckIfPtrIsNull("NavigatorFactory", "create", path, aron); auto typeDescriptor = AronResolver::GetDescriptorForAronData(aron); auto factory_iterator = FACTORIES.find(typeDescriptor); if (factory_iterator == FACTORIES.end()) { - throw exception::AronExceptionWithPathInfo("AronDataNavigatorFactory", "create", "Cannot find the desired factory for input: " + AronDataDescriptorToString.at(typeDescriptor) + ". Cannot create navigator", path); + throw exception::AronException("NavigatorFactory", "create", "Cannot find the desired factory for input: " + data::DescriptorToString.at(typeDescriptor) + ". Cannot create navigator", path); } return factory_iterator->second->createSpecific(aron, path); } - AronDataNavigatorPtr AronDataNavigatorFactory::createSpecific(const data::AronDataPtr&, const AronPath& p) const + NavigatorPtr NavigatorFactory::createSpecific(const data::AronDataPtr&, const Path& p) const { - throw exception::AronExceptionWithPathInfo("AronDataNavigatorFactory", "createSpecific", "Called disallowed method of an AronDataNavigatorFactory. Use child class instead!", p); + throw exception::AronException("NavigatorFactory", "createSpecific", "Called disallowed method of an AronDataNavigatorFactory. Use child class instead!", p); } // Factories #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - AronDataNavigatorPtr Aron##upperType##DataNavigatorFactory::createSpecific(const data::AronDataPtr& aron, const AronPath& path) const \ + AronDataNavigatorPtr Aron##upperType##DataNavigatorFactory::createSpecific(const data::AronDataPtr& aron, const Path& path) const \ { \ CheckIfInputIsNull("Aron"+std::string(#upperType)+"DataNavigatorFactory", "create", path, aron); \ data::Aron##upperType##Ptr aronCasted = data::Aron##upperType##Ptr::dynamicCast(aron); \ @@ -74,9 +71,7 @@ namespace armarx return AronDataNavigatorPtr(new Aron##upperType##DataNavigator(aronCasted, path)); \ } - HANDLE_CONTAINER_DATA - HANDLE_COMPLEX_DATA - HANDLE_PRIMITIVE_TYPES + HANDLE_ALL_ARON_DATA #undef RUN_ARON_MACRO } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h b/source/RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..d26beda124bd3464bee80da6f1dba86df4dd318e --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h @@ -0,0 +1,64 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <memory> +#include <unordered_map> + +// BaseClass +#include <RobotAPI/libraries/aron/aroncore/navigator/NavigatorFactory.h> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> + +namespace armarx::aron::datanavigator +{ + class NavigatorFactory; + typedef std::shared_ptr<NavigatorFactory> NavigatorFactoryPtr; + + class NavigatorFactory : + virtual public Factory<data::AronDataPtr, datanavigator::NavigatorPtr> + { + public: + NavigatorFactory() = default; + virtual NavigatorPtr create(const data::AronDataPtr&, const Path&) const override; + virtual NavigatorPtr createSpecific(const data::AronDataPtr&, const Path&) const override; + }; + + // Factories +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + class upperType##NavigatorFactory : \ + virtual public NavigatorFactory \ + { \ + public: \ + upperType##NavigatorFactory() = default; \ + virtual NavigatorPtr createSpecific(const data::AronDataPtr&, const Path&) const override; \ + }; + + HANDLE_ALL_ARON_DATA +#undef RUN_ARON_MACRO + +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/data/complex/NDArray.cpp similarity index 51% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/complex/NDArray.cpp index 46cf0bbfc6650d260af669c8fd8671c4c87eace1..ce8b5825c03d72442db87c3d932f0a13a7696c53 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/complex/NDArray.cpp @@ -22,18 +22,17 @@ */ // Header -#include "AronNDArrayDataNavigator.h" +#include "NDArray.h" // Simox #include <SimoxUtility/algorithm/string.h> // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.h> namespace armarx { @@ -42,29 +41,29 @@ namespace armarx namespace datanavigator { // constructors - AronNDArrayDataNavigator::AronNDArrayDataNavigator(const AronPath& path) : - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAronNDArray, path), - AronDataNavigator(AronDataDescriptor::eAronNDArray, path), + NDArrayNavigator::NDArrayNavigator(const Path& path) : + Navigator<data::Descriptor, data::AronData>::Navigator(data::Descriptor::eAronNDArray, path), + Navigator(data::Descriptor::eAronNDArray, path), aron(new data::AronNDArray()) { } - AronNDArrayDataNavigator::AronNDArrayDataNavigator(const data::AronNDArrayPtr& o, const AronPath& path) : - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAronNDArray, path), - AronDataNavigator(AronDataDescriptor::eAronNDArray, path), + NDArrayNavigator::NDArrayNavigator(const data::AronNDArrayPtr& o, const Path& path) : + Navigator<data::Descriptor, data::AronData>::Navigator(data::Descriptor::eAronNDArray, path), + Navigator(data::Descriptor::eAronNDArray, path), aron(o) { CheckAronPtrForNull("AronNDArrayDataNavigator", "AronNDArrayDataNavigator", getPath(), aron); } - AronNDArrayDataNavigator::AronNDArrayDataNavigator(const std::vector<int>& dim, const std::string& t, const std::vector<unsigned char>& data, const AronPath& path) : - AronNDArrayDataNavigator(data::AronNDArrayPtr(new data::AronNDArray(dim, t, data)), path) + NDArrayNavigator::NDArrayNavigator(const std::vector<int>& dim, const std::string& t, const std::vector<unsigned char>& data, const Path& path) : + NDArrayNavigator(data::AronNDArrayPtr(new data::AronNDArray(dim, t, data)), path) { } // operators - bool AronNDArrayDataNavigator::operator==(const AronNDArrayDataNavigator& other) const + bool NDArrayNavigator::operator==(const NDArrayNavigator& other) const { const auto otherAron = other.toAronNDArrayPtr(); if (aron->dimensions != otherAron->dimensions) @@ -83,122 +82,122 @@ namespace armarx return true; } - bool AronNDArrayDataNavigator::equalsDataNavigator(const AronDataNavigatorPtr& other) const + bool NDArrayNavigator::equalsDataNavigator(const NavigatorPtr& other) const { if (other == nullptr) { return false; } - AronNDArrayDataNavigatorPtr casted = DynamicCast(other); + NDArrayNavigatorPtr casted = DynamicCast(other); return equalsDeep(casted); } - bool AronNDArrayDataNavigator::equalsDeep(const AronNDArrayDataNavigatorPtr& other) const + bool NDArrayNavigator::equalsDeep(const NDArrayNavigatorPtr& other) const { return *this == *other; } // static methods - AronNDArrayDataNavigatorPtr AronNDArrayDataNavigator::DynamicCast(const AronDataNavigatorPtr& n) + NDArrayNavigatorPtr NDArrayNavigator::DynamicCast(const NavigatorPtr& n) { - AronNDArrayDataNavigatorPtr casted = std::dynamic_pointer_cast<AronNDArrayDataNavigator>(n); + NDArrayNavigatorPtr casted = std::dynamic_pointer_cast<NDArrayNavigator>(n); return casted; } - AronNDArrayDataNavigator AronNDArrayDataNavigator::DynamicCast(AronDataNavigator& n) + NDArrayNavigator NDArrayNavigator::DynamicCast(Navigator& n) { - return dynamic_cast<AronNDArrayDataNavigator&>(n); + return dynamic_cast<NDArrayNavigator&>(n); } - AronNDArrayDataNavigatorPtr AronNDArrayDataNavigator::DynamicCastAndCheck(const AronDataNavigatorPtr& n) + NDArrayNavigatorPtr NDArrayNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckDataNavigatorPtrForNull("AronNDArrayDataNavigator", "DynamicCastAndCheck[Before]", n); - AronNDArrayDataNavigatorPtr casted = AronNDArrayDataNavigator::DynamicCast(n); + NDArrayNavigatorPtr casted = NDArrayNavigator::DynamicCast(n); CheckDataNavigatorPtrForNull("AronNDArrayDataNavigator", "DynamicCastAndCheck[After]", n->getPath(), casted); return casted; } - AronNDArrayDataNavigatorPtr AronNDArrayDataNavigator::FromAronNDArrayPtr(const data::AronNDArrayPtr& aron) + NDArrayNavigatorPtr NDArrayNavigator::FromAronNDArrayPtr(const data::AronNDArrayPtr& aron) { - return std::make_shared<AronNDArrayDataNavigator>(aron); + return std::make_shared<NDArrayNavigator>(aron); } - data::AronNDArrayPtr AronNDArrayDataNavigator::ToAronNDArrayPtr(const AronNDArrayDataNavigatorPtr& navigator) + data::AronNDArrayPtr NDArrayNavigator::ToAronNDArrayPtr(const NDArrayNavigatorPtr& navigator) { return navigator ? navigator->toAronNDArrayPtr() : nullptr; } // public member functions - unsigned char* AronNDArrayDataNavigator::getData() const + unsigned char* NDArrayNavigator::getData() const { return aron->data.data(); } - void AronNDArrayDataNavigator::setData(unsigned int elements, const unsigned char* src) + void NDArrayNavigator::setData(unsigned int elements, const unsigned char* src) { aron->data = std::vector<unsigned char>(elements); memcpy(aron->data.data(), src, elements); } - std::vector<int> AronNDArrayDataNavigator::getDimensions() const + std::vector<int> NDArrayNavigator::getDimensions() const { return aron->dimensions; } - void AronNDArrayDataNavigator::setDimensions(const std::vector<int>& d) + void NDArrayNavigator::setDimensions(const std::vector<int>& d) { aron->dimensions = d; } - void AronNDArrayDataNavigator::addDimension(int i) + void NDArrayNavigator::addDimension(int i) { aron->dimensions.push_back(i); } - std::string AronNDArrayDataNavigator::getType() const + std::string NDArrayNavigator::getType() const { return aron->type; } - void AronNDArrayDataNavigator::setType(const std::string& t) + void NDArrayNavigator::setType(const std::string& t) { if (t.empty()) { - throw exception::AronExceptionWithPathInfo("AronNDArrayDataNavigator", "setType", "The type cannot be empty", getPath()); + throw exception::AronException("AronNDArrayDataNavigator", "setType", "The type cannot be empty", getPath()); } aron->type = t; } - data::AronNDArrayPtr AronNDArrayDataNavigator::toAronNDArrayPtr() const + data::AronNDArrayPtr NDArrayNavigator::toAronNDArrayPtr() const { return aron; } // virtual implementations - data::AronDataPtr AronNDArrayDataNavigator::getResult() const + data::AronDataPtr NDArrayNavigator::getResult() const { return toAronNDArrayPtr(); } - std::string AronNDArrayDataNavigator::getName() const + std::string NDArrayNavigator::getName() const { return "AronNDArray<" + simox::alg::to_string(aron->dimensions, ", ") + ", " + aron->type + ">"; } - typenavigator::AronTypeNavigatorPtr AronNDArrayDataNavigator::recalculateType() const + typenavigator::NavigatorPtr NDArrayNavigator::recalculateType() const { // We set all to openCVMat because it accepts n-dimensional types - typenavigator::AronOpenCVMatTypeNavigatorPtr typenav = typenavigator::AronOpenCVMatTypeNavigatorPtr(new typenavigator::AronOpenCVMatTypeNavigator(getPath())); + typenavigator::OpenCVMatNavigatorPtr typenav = typenavigator::OpenCVMatNavigatorPtr(new typenavigator::OpenCVMatNavigator(getPath())); typenav->setDimensions(std::vector<int>(aron->dimensions.begin(), std::prev(aron->dimensions.end()))); - typenav->setUsedType(aron->type); + typenav->setTypename(aron->type); return typenav; } - bool AronNDArrayDataNavigator::fullfillsType(const typenavigator::AronTypeNavigatorPtr& type) const + bool NDArrayNavigator::fullfillsType(const typenavigator::NavigatorPtr& type) const { - if (!AronResolver::TypesAreCorresponding(type->getDescriptor(), getDescriptor())) + if (!AronResolver::Correspond(type->getDescriptor(), getDescriptor())) { return false; } @@ -209,34 +208,34 @@ namespace armarx case eAron##upperType##Type: \ { \ typenavigator::Aron##upperType##TypeNavigatorPtr casted = typenavigator::Aron##upperType##TypeNavigator::DynamicCast(type); \ - if (std::vector<int>(aron->dimensions.begin(), std::prev(aron->dimensions.end())) != casted->getDimensions() || aron->type != casted->getUsedType()) \ + if (std::vector<int>(aron->dimensions.begin(), std::prev(aron->dimensions.end())) != casted->getDimensions() || aron->type != casted->getTypename()) \ { \ return false; \ } \ break; \ } - HANDLE_COMPLEX_TYPES + HANDLE_NDARRAY_TYPES #undef RUN_ARON_MACRO default: - throw exception::AronExceptionWithPathInfo("AronNDArrayDataNavigator", "fullfillsType", "Could not cast a type to an NDArray-Type", getPath()); + throw exception::AronException("AronNDArrayDataNavigator", "fullfillsType", "Could not cast a type to an NDArray-Type", getPath()); } return true; } - std::string AronNDArrayDataNavigator::DimensionsToString(const std::vector<int>& dimensions) + std::string NDArrayNavigator::DimensionsToString(const std::vector<int>& dimensions) { std::stringstream ss; ss << "(" << simox::alg::join(simox::alg::multi_to_string(dimensions), ", ") << ")"; return ss.str(); } - std::vector<AronDataNavigatorPtr> AronNDArrayDataNavigator::getChildren() const + std::vector<NavigatorPtr> NDArrayNavigator::getChildren() const { return {}; } - size_t AronNDArrayDataNavigator::childrenSize() const + size_t NDArrayNavigator::childrenSize() const { return 0; } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/data/complex/NDArray.h similarity index 56% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/complex/NDArray.h index df7fb6885aaba66339a339096d8b7c95ef3f983e..007a5ba127579e09c280551f473099a2d33edac4 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronNDArrayDataNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/complex/NDArray.h @@ -28,42 +28,37 @@ #include <map> // ArmarX -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> -namespace armarx +namespace armarx::aron::datanavigator { - namespace aron - { - namespace datanavigator - { - class AronNDArrayDataNavigator; - typedef std::shared_ptr<AronNDArrayDataNavigator> AronNDArrayDataNavigatorPtr; - - class AronNDArrayDataNavigator : - virtual public AronComplexDataNavigator + class NDArrayNavigator; + typedef std::shared_ptr<NDArrayNavigator> NDArrayNavigatorPtr; + + class NDArrayNavigator : + virtual public Navigator { public: - using PointerType = AronNDArrayDataNavigatorPtr; + using PointerType = NDArrayNavigatorPtr; public: // constructors - AronNDArrayDataNavigator(const AronPath& path = AronPath()); - AronNDArrayDataNavigator(const data::AronNDArrayPtr&, const AronPath& path = AronPath()); - AronNDArrayDataNavigator(const std::vector<int>&, const std::string&, const std::vector<unsigned char>&, const AronPath& path = AronPath()); + NDArrayNavigator(const Path& path = Path()); + NDArrayNavigator(const data::AronNDArrayPtr&, const Path& path = Path()); + NDArrayNavigator(const std::vector<int>&, const std::string&, const std::vector<unsigned char>&, const Path& path = Path()); // operators - bool operator==(const AronNDArrayDataNavigator&) const; - virtual bool equalsDataNavigator(const AronDataNavigatorPtr&) const override; - bool equalsDeep(const AronNDArrayDataNavigatorPtr&) const; + bool operator==(const NDArrayNavigator&) const; + virtual bool equalsDataNavigator(const NavigatorPtr&) const override; + bool equalsDeep(const NDArrayNavigatorPtr&) const; // static methods - static AronNDArrayDataNavigatorPtr DynamicCast(const AronDataNavigatorPtr& n); - static AronNDArrayDataNavigator DynamicCast(AronDataNavigator& n); - static AronNDArrayDataNavigatorPtr DynamicCastAndCheck(const AronDataNavigatorPtr& n); + static NDArrayNavigatorPtr DynamicCast(const NavigatorPtr& n); + static NDArrayNavigator DynamicCast(Navigator& n); + static NDArrayNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); - static AronNDArrayDataNavigatorPtr FromAronNDArrayPtr(const data::AronNDArrayPtr& aron); - static data::AronNDArrayPtr ToAronNDArrayPtr(const AronNDArrayDataNavigatorPtr& navigator); + static NDArrayNavigatorPtr FromAronNDArrayPtr(const data::AronNDArrayPtr& aron); + static data::AronNDArrayPtr ToAronNDArrayPtr(const NDArrayNavigatorPtr& navigator); /// Return dimensions in a readable string such as "(2, 3, 4)". static std::string DimensionsToString(const std::vector<int>& dimensions); @@ -85,15 +80,13 @@ namespace armarx // virtual implementations virtual data::AronDataPtr getResult() const override; virtual std::string getName() const override; - virtual std::vector<AronDataNavigatorPtr> getChildren() const override; + virtual std::vector<NavigatorPtr> getChildren() const override; virtual size_t childrenSize() const override; - virtual typenavigator::AronTypeNavigatorPtr recalculateType() const override; - virtual bool fullfillsType(const typenavigator::AronTypeNavigatorPtr&) const override; + virtual typenavigator::NavigatorPtr recalculateType() const override; + virtual bool fullfillsType(const typenavigator::NavigatorPtr&) const override; private: data::AronNDArrayPtr aron; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/Dict.cpp similarity index 60% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/container/Dict.cpp index c7cc7fcaae5fb57a3173374f077b9a9069dae54e..0208f545d5cbfef487040c0c05c62acf9b8d2c5c 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/Dict.cpp @@ -22,12 +22,11 @@ */ // Header -#include "AronDictDataNavigator.h" +#include "Dict.h" // ArmarX -#include <ArmarXCore/core/exceptions/Exception.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.h> namespace armarx { @@ -37,33 +36,33 @@ namespace armarx { // constructors - AronDictDataNavigator::AronDictDataNavigator(const AronPath& path) : - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAronDict, path), - AronDataNavigator(AronDataDescriptor::eAronDict, path), + DictNavigator::DictNavigator(const Path& path) : + Navigator<data::Descriptor, data::AronData>::Navigator(data::Descriptor::eAronDict, path), + Navigator(data::Descriptor::eAronDict, path), aron(new data::AronDict()) { } - AronDictDataNavigator::AronDictDataNavigator(const data::AronDictPtr& o, const AronPath& path) : - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAronDict, path), - AronDataNavigator(AronDataDescriptor::eAronDict, path), + DictNavigator::DictNavigator(const data::AronDictPtr& o, const Path& path) : + Navigator<data::Descriptor, data::AronData>::Navigator(data::Descriptor::eAronDict, path), + Navigator(data::Descriptor::eAronDict, path), aron(o) { CheckAronPtrForNull("AronDictDataNavigator", "AronDictDataNavigator", getPath(), aron); for (const auto& [key, dataPtr] : aron->elements) { - childrenNavigators[key] = AronDataNavigator::FromAronData(dataPtr, AronPath(path, key)); + childrenNavigators[key] = Navigator::FromAronData(dataPtr, Path(path, key)); } } - AronDictDataNavigator::AronDictDataNavigator(const data::AronDataDict& d, const AronPath& path) : - AronDictDataNavigator(data::AronDictPtr(new data::AronDict(d)), path) + DictNavigator::DictNavigator(const data::AronDataDict& d, const Path& path) : + DictNavigator(data::AronDictPtr(new data::AronDict(d)), path) { } - AronDictDataNavigator::AronDictDataNavigator(const std::map<std::string, AronDataNavigatorPtr>& m, const AronPath& path) : - AronDictDataNavigator(path) + DictNavigator::DictNavigator(const std::map<std::string, NavigatorPtr>& m, const Path& path) : + DictNavigator(path) { for (const auto& [key, dataPtr] : m) { @@ -72,7 +71,7 @@ namespace armarx } // operators - bool AronDictDataNavigator::operator==(const AronDictDataNavigator& other) const + bool DictNavigator::operator==(const DictNavigator& other) const { for (const auto& [key, nav] : childrenNavigators) { @@ -88,57 +87,57 @@ namespace armarx return true; } - bool AronDictDataNavigator::equalsDataNavigator(const AronDataNavigatorPtr& other) const + bool DictNavigator::equalsDataNavigator(const NavigatorPtr& other) const { if (other == nullptr) { return false; } - AronDictDataNavigatorPtr casted = DynamicCast(other); + DictNavigatorPtr casted = DynamicCast(other); return equalsDeep(casted); } - bool AronDictDataNavigator::equalsDeep(const AronDictDataNavigatorPtr& other) const + bool DictNavigator::equalsDeep(const DictNavigatorPtr& other) const { return *this == *other; } // static methods - AronDictDataNavigatorPtr AronDictDataNavigator::DynamicCast(const AronDataNavigatorPtr& n) + DictNavigatorPtr DictNavigator::DynamicCast(const NavigatorPtr& n) { - return std::dynamic_pointer_cast<AronDictDataNavigator>(n); + return std::dynamic_pointer_cast<DictNavigator>(n); } - AronDictDataNavigator AronDictDataNavigator::DynamicCast(AronDataNavigator& n) + DictNavigator DictNavigator::DynamicCast(Navigator& n) { - return dynamic_cast<AronDictDataNavigator&>(n); + return dynamic_cast<DictNavigator&>(n); } - AronDictDataNavigatorPtr AronDictDataNavigator::DynamicCastAndCheck(const AronDataNavigatorPtr& n) + DictNavigatorPtr DictNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckDataNavigatorPtrForNull("AronDictDataNavigator", "DynamicCastAndCheck[Before]", n); - AronDictDataNavigatorPtr casted = AronDictDataNavigator::DynamicCast(n); + DictNavigatorPtr casted = DictNavigator::DynamicCast(n); CheckDataNavigatorPtrForNull("AronDictDataNavigator", "DynamicCastAndCheck[After]", n->getPath(), casted); return casted; } - AronDictDataNavigatorPtr AronDictDataNavigator::FromAronDictPtr(const data::AronDictPtr& aron) + DictNavigatorPtr DictNavigator::FromAronDictPtr(const data::AronDictPtr& aron) { - return std::make_shared<AronDictDataNavigator>(aron); + return std::make_shared<DictNavigator>(aron); } - data::AronDictPtr AronDictDataNavigator::ToAronDictPtr(const AronDictDataNavigatorPtr& navigator) + data::AronDictPtr DictNavigator::ToAronDictPtr(const DictNavigatorPtr& navigator) { return navigator ? navigator->toAronDictPtr() : nullptr; } - data::AronDictPtr AronDictDataNavigator::toAronDictPtr() const + data::AronDictPtr DictNavigator::toAronDictPtr() const { return aron; } // public member functions - std::vector<std::string> AronDictDataNavigator::getAllKeys() const + std::vector<std::string> DictNavigator::getAllKeys() const { std::vector<std::string> ret; for (const auto& [key, _] : childrenNavigators) @@ -148,18 +147,18 @@ namespace armarx return ret; } - void AronDictDataNavigator::addElement(const std::string& key, const AronDataNavigatorPtr& data) + void DictNavigator::addElement(const std::string& key, const NavigatorPtr& data) { this->childrenNavigators[key] = data; this->aron->elements[key] = data->getResult(); } - bool AronDictDataNavigator::hasElement(const std::string& key) const + bool DictNavigator::hasElement(const std::string& key) const { return childrenNavigators.count(key) > 0; } - AronDataNavigatorPtr AronDictDataNavigator::getElement(const std::string& key) const + NavigatorPtr DictNavigator::getElement(const std::string& key) const { auto it = childrenNavigators.find(key); if (it == childrenNavigators.end()) @@ -169,36 +168,36 @@ namespace armarx { all_keys += child + ", "; } - throw exception::AronExceptionWithPathInfo("AronDictDataNavigator", "getElement", "Could not find key '" + key + "'. But I found the following keys: [" + all_keys + "]", getPath()); + throw exception::AronException("AronDictDataNavigator", "getElement", "Could not find key '" + key + "'. But I found the following keys: [" + all_keys + "]", getPath()); } return it->second; } - std::map<std::string, AronDataNavigatorPtr> AronDictDataNavigator::getElements() const + std::map<std::string, NavigatorPtr> DictNavigator::getElements() const { return childrenNavigators; } - void AronDictDataNavigator::clear() + void DictNavigator::clear() { childrenNavigators.clear(); aron->elements.clear(); } // virtual implementations - data::AronDataPtr AronDictDataNavigator::getResult() const + data::AronDataPtr DictNavigator::getResult() const { return toAronDictPtr(); } - std::string AronDictDataNavigator::getName() const + std::string DictNavigator::getName() const { return "AronDict"; } - typenavigator::AronTypeNavigatorPtr AronDictDataNavigator::recalculateType() const + typenavigator::NavigatorPtr DictNavigator::recalculateType() const { - typenavigator::AronDictTypeNavigatorPtr typenav = typenavigator::AronDictTypeNavigatorPtr(new typenavigator::AronDictTypeNavigator(getPath())); + typenavigator::DictNavigatorPtr typenav = typenavigator::DictNavigatorPtr(new typenavigator::DictNavigator(getPath())); for (const auto& [key, nav] : childrenNavigators) { if (typenav->getAcceptedType() == nullptr) @@ -209,15 +208,15 @@ namespace armarx if (!nav->fullfillsType(typenav->getAcceptedType())) { - throw exception::AronExceptionWithPathInfo("AronDictDataNavigator", "recalculateType", "Cannot recalculate the aronType. Inconsistency found for key: " + key, getPath()); + throw exception::AronException("AronDictDataNavigator", "recalculateType", "Cannot recalculate the aronType. Inconsistency found for key: " + key, getPath()); } } return typenav->getAcceptedType(); } - bool AronDictDataNavigator::fullfillsType(const typenavigator::AronTypeNavigatorPtr& type) const + bool DictNavigator::fullfillsType(const typenavigator::NavigatorPtr& type) const { - if (!AronResolver::TypesAreCorresponding(type->getDescriptor(), getDescriptor())) + if (!AronResolver::Correspond(type->getDescriptor(), getDescriptor())) { return false; } @@ -254,9 +253,9 @@ namespace armarx return false; } - std::vector<AronDataNavigatorPtr> AronDictDataNavigator::getChildren() const + std::vector<NavigatorPtr> DictNavigator::getChildren() const { - std::vector<AronDataNavigatorPtr> ret(childrenNavigators.size()); + std::vector<NavigatorPtr> ret(childrenNavigators.size()); for (const auto& [key, nav] : childrenNavigators) { ret.push_back(nav); @@ -264,12 +263,12 @@ namespace armarx return ret; } - size_t AronDictDataNavigator::childrenSize() const + size_t DictNavigator::childrenSize() const { return childrenNavigators.size(); } - AronDataNavigatorPtr AronDictDataNavigator::navigateAbsolute(const AronPath& path) const + NavigatorPtr DictNavigator::navigateAbsolute(const Path& path) const { if (!path.hasElement()) { @@ -278,7 +277,7 @@ namespace armarx std::string el = path.getFirstElement(); if (!hasElement(el)) { - throw exception::AronStringNotValidException("AronDictDataNavigator", "navigate", "Could not find an element of a path.", el); + throw exception::StringNotValidException("AronDictDataNavigator", "navigate", "Could not find an element of a path.", el); } if (path.size() == 1) @@ -287,7 +286,7 @@ namespace armarx } else { - AronPath next = path.withDetachedFirstElement(); + Path next = path.withDetachedFirstElement(); AronContainerDataNavigatorPtr c = AronContainerDataNavigator::DynamicCastAndCheck(childrenNavigators.at(el)); return c->navigateAbsolute(next); } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/Dict.h b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/Dict.h new file mode 100644 index 0000000000000000000000000000000000000000..4c30f8d0fe0ae0ff4033719ba467a7d87cc0793e --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/Dict.h @@ -0,0 +1,92 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <memory> +#include <map> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.h> + +namespace armarx::aron::datanavigator +{ + class DictNavigator; + typedef std::shared_ptr<DictNavigator> DictNavigatorPtr; + + class DictNavigator : + virtual public Navigator + { + public: + using PointerType = DictNavigatorPtr; + + public: + // constructors + DictNavigator(const Path& path = Path()); + DictNavigator(const data::AronDictPtr&, const Path& path = Path()); + DictNavigator(const data::AronDataDict&, const Path& path = Path()); + DictNavigator(const std::map<std::string, NavigatorPtr>&, const Path& path = Path()); + + // operators + bool operator==(const DictNavigator&) const; + virtual bool equalsDataNavigator(const NavigatorPtr&) const override; + bool equalsDeep(const DictNavigatorPtr&) const; + + // static methods + static DictNavigatorPtr DynamicCast(const NavigatorPtr& n); + static DictNavigator DynamicCast(Navigator& n); + static DictNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + static DictNavigatorPtr FromAronDictPtr(const data::AronDictPtr& aron); + static data::AronDictPtr ToAronDictPtr(const DictNavigatorPtr& navigator); + + // public member functions + data::AronDictPtr toAronDictPtr() const; + std::vector<std::string> getAllKeys() const; + + void addElement(const std::string& key, const NavigatorPtr&); + bool hasElement(const std::string&) const; + NavigatorPtr getElement(const std::string&) const; + std::map<std::string, NavigatorPtr> getElements() const; + + void clear(); + + NavigatorPtr navigateAbsolute(const Path& path) const; + + // virtual implementations + virtual data::AronDataPtr getResult() const override; + virtual std::string getName() const override; + virtual std::vector<NavigatorPtr> getChildren() const override; + virtual size_t childrenSize() const override; + + virtual typenavigator::NavigatorPtr recalculateType() const override; + virtual bool fullfillsType(const typenavigator::NavigatorPtr&) const override; + + private: + // members + std::map<std::string, NavigatorPtr> childrenNavigators; + data::AronDictPtr aron; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/List.cpp similarity index 60% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/container/List.cpp index a393b26ac23023c789c61af94abb6d4fe10f72cd..9278b26ac6963d64f15cf506e84e3d8dba65c5dd 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/List.cpp @@ -22,12 +22,12 @@ */ // Header -#include "AronListDataNavigator.h" +#include "List.h" // ArmarX #include <ArmarXCore/core/exceptions/Exception.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> namespace armarx { @@ -36,16 +36,16 @@ namespace armarx namespace datanavigator { // constructors - AronListDataNavigator::AronListDataNavigator(const AronPath& path) : - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAronList, path), - AronDataNavigator(AronDataDescriptor::eAronList, path), + ListNavigator::ListNavigator(const Path& path) : + Navigator<data::Descriptor, data::AronData>::Navigator(data::Descriptor::eAronList, path), + Navigator(data::Descriptor::eAronList, path), aron(new data::AronList()) { } - AronListDataNavigator::AronListDataNavigator(const data::AronListPtr& l, const AronPath& path) : - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAronList, path), - AronDataNavigator(AronDataDescriptor::eAronList, path), + ListNavigator::ListNavigator(const data::AronListPtr& l, const Path& path) : + Navigator<data::Descriptor, data::AronData>::Navigator(data::Descriptor::eAronList, path), + Navigator(data::Descriptor::eAronList, path), aron(l) { CheckAronPtrForNull("AronListDataNavigator", "AronListDataNavigator", getPath(), aron); @@ -53,17 +53,17 @@ namespace armarx unsigned int i = 0; for (const auto& dataPtr : l->elements) { - childrenNavigators.push_back(FromAronData(dataPtr, AronPath(path, std::to_string(i++)))); + childrenNavigators.push_back(FromAronData(dataPtr, Path(path, std::to_string(i++)))); } } - AronListDataNavigator::AronListDataNavigator(const data::AronDataList& d, const AronPath& path) : - AronListDataNavigator(data::AronListPtr(new data::AronList(d)), path) + ListNavigator::ListNavigator(const data::AronDataList& d, const Path& path) : + ListNavigator(data::AronListPtr(new data::AronList(d)), path) { } - AronListDataNavigator::AronListDataNavigator(const std::vector<AronDataNavigatorPtr>& n, const AronPath& path) : - AronListDataNavigator(path) + ListNavigator::ListNavigator(const std::vector<NavigatorPtr>& n, const Path& path) : + ListNavigator(path) { for (const auto& dataPtr : n) { @@ -72,7 +72,7 @@ namespace armarx } // operators - bool AronListDataNavigator::operator==(const AronListDataNavigator& other) const + bool ListNavigator::operator==(const ListNavigator& other) const { unsigned int i = 0; for (const auto& nav : childrenNavigators) @@ -90,102 +90,102 @@ namespace armarx return true; } - bool AronListDataNavigator::equalsDataNavigator(const AronDataNavigatorPtr& other) const + bool ListNavigator::equalsDataNavigator(const NavigatorPtr& other) const { if (other == nullptr) { return false; } - AronListDataNavigatorPtr casted = DynamicCast(other); + ListNavigatorPtr casted = DynamicCast(other); return equalsDeep(casted); } - bool AronListDataNavigator::equalsDeep(const AronListDataNavigatorPtr& other) const + bool ListNavigator::equalsDeep(const ListNavigatorPtr& other) const { return *this == *other; } // static methods - AronListDataNavigatorPtr AronListDataNavigator::DynamicCast(const AronDataNavigatorPtr& n) + ListNavigatorPtr ListNavigator::DynamicCast(const NavigatorPtr& n) { - AronListDataNavigatorPtr casted = std::dynamic_pointer_cast<AronListDataNavigator>(n); + ListNavigatorPtr casted = std::dynamic_pointer_cast<ListNavigator>(n); return casted; } - AronListDataNavigator AronListDataNavigator::DynamicCast(AronDataNavigator& n) + ListNavigator ListNavigator::DynamicCast(Navigator& n) { - return dynamic_cast<AronListDataNavigator&>(n); + return dynamic_cast<ListNavigator&>(n); } - AronListDataNavigatorPtr AronListDataNavigator::DynamicCastAndCheck(const AronDataNavigatorPtr& n) + ListNavigatorPtr ListNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckDataNavigatorPtrForNull("AronListDataNavigator", "DynamicCastAndCheck[Before]", n); - AronListDataNavigatorPtr casted = AronListDataNavigator::DynamicCast(n); + ListNavigatorPtr casted = ListNavigator::DynamicCast(n); CheckDataNavigatorPtrForNull("AronListDataNavigator", "DynamicCastAndCheck[After]", n->getPath(), casted); return casted; } - AronListDataNavigatorPtr AronListDataNavigator::FromAronListPtr(const data::AronListPtr& aron) + ListNavigatorPtr ListNavigator::FromAronListPtr(const data::AronListPtr& aron) { - return std::make_shared<AronListDataNavigator>(aron); + return std::make_shared<ListNavigator>(aron); } - data::AronListPtr AronListDataNavigator::ToAronListPtr(const AronListDataNavigatorPtr& navigator) + data::AronListPtr ListNavigator::ToAronListPtr(const ListNavigatorPtr& navigator) { return navigator ? navigator->toAronListPtr() : nullptr; } // public member functions - void AronListDataNavigator::addElement(const AronDataNavigatorPtr& n) + void ListNavigator::addElement(const NavigatorPtr& n) { childrenNavigators.push_back(n); aron->elements.push_back(n->getResult()); } - bool AronListDataNavigator::hasElement(unsigned int i) const + bool ListNavigator::hasElement(unsigned int i) const { return i < childrenNavigators.size(); } - AronDataNavigatorPtr AronListDataNavigator::getElement(unsigned int i) const + NavigatorPtr ListNavigator::getElement(unsigned int i) const { if (i >= childrenNavigators.size()) { - throw exception::AronExceptionWithPathInfo("AronListDataNavigator", "getElement", "The index i = " + std::to_string(i) + " is out of bounds (size = " + std::to_string(childrenNavigators.size()) + ")", getPath()); + throw exception::AronException("AronListDataNavigator", "getElement", "The index i = " + std::to_string(i) + " is out of bounds (size = " + std::to_string(childrenNavigators.size()) + ")", getPath()); } return childrenNavigators[i]; } - std::vector<AronDataNavigatorPtr> AronListDataNavigator::getElements() const + std::vector<NavigatorPtr> ListNavigator::getElements() const { return childrenNavigators; } - void AronListDataNavigator::clear() + void ListNavigator::clear() { childrenNavigators.clear(); aron->elements.clear(); } - data::AronListPtr AronListDataNavigator::toAronListPtr() const + data::AronListPtr ListNavigator::toAronListPtr() const { return aron; } // virtual implementations - data::AronDataPtr AronListDataNavigator::getResult() const + data::AronDataPtr ListNavigator::getResult() const { return toAronListPtr(); } - std::string AronListDataNavigator::getName() const + std::string ListNavigator::getName() const { return "AronList"; } - typenavigator::AronTypeNavigatorPtr AronListDataNavigator::recalculateType() const + typenavigator::NavigatorPtr ListNavigator::recalculateType() const { - typenavigator::AronListTypeNavigatorPtr typenav = typenavigator::AronListTypeNavigatorPtr(new typenavigator::AronListTypeNavigator(getPath())); + typenavigator::ListNavigatorPtr typenav = typenavigator::ListNavigatorPtr(new typenavigator::ListNavigator(getPath())); unsigned int i = 0; for (const auto& nav : childrenNavigators) { @@ -197,16 +197,16 @@ namespace armarx if (!nav->fullfillsType(typenav->getAcceptedType())) { - throw exception::AronExceptionWithPathInfo("AronListDataNavigator", "recalculateType", "Cannot recalculate the aronType. Inconsistency found for index: " + std::to_string(i), getPath()); + throw exception::AronException("AronListDataNavigator", "recalculateType", "Cannot recalculate the aronType. Inconsistency found for index: " + std::to_string(i), getPath()); } ++i; } return typenav->getAcceptedType(); } - bool AronListDataNavigator::fullfillsType(const typenavigator::AronTypeNavigatorPtr& type) const + bool ListNavigator::fullfillsType(const typenavigator::NavigatorPtr& type) const { - if (!AronResolver::TypesAreCorresponding(type->getDescriptor(), getDescriptor())) + if (!AronResolver::Correspond(type->getDescriptor(), getDescriptor())) { return false; } @@ -245,17 +245,17 @@ namespace armarx return false; } - std::vector<AronDataNavigatorPtr> AronListDataNavigator::getChildren() const + std::vector<NavigatorPtr> ListNavigator::getChildren() const { return childrenNavigators; } - size_t AronListDataNavigator::childrenSize() const + size_t ListNavigator::childrenSize() const { return childrenNavigators.size(); } - AronDataNavigatorPtr AronListDataNavigator::navigateAbsolute(const AronPath& path) const + NavigatorPtr ListNavigator::navigateAbsolute(const Path& path) const { if (!path.hasElement()) { @@ -264,7 +264,7 @@ namespace armarx unsigned int i = std::stoi(path.getFirstElement()); if (!hasElement(i)) { - throw exception::AronIndexNotValidException("AronListDataNavigator", "navigate", "Could not find an element of a path.", i, childrenSize()); + throw exception::IndexNotValidException("AronListDataNavigator", "navigate", "Could not find an element of a path.", i, childrenSize()); } if (path.size() == 1) @@ -273,7 +273,7 @@ namespace armarx } else { - AronPath next = path.withDetachedFirstElement(); + Path next = path.withDetachedFirstElement(); AronContainerDataNavigatorPtr c = AronContainerDataNavigator::DynamicCastAndCheck(childrenNavigators.at(i)); return c->navigateAbsolute(next); } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/List.h b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/List.h new file mode 100644 index 0000000000000000000000000000000000000000..f210151ce103bb94b0fa120d1b50c71680d7d17a --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/container/List.h @@ -0,0 +1,90 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <memory> + +// ArmarX +#include <RobotAPI/interface/aron.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h> + +namespace armarx::aron::datanavigator +{ + class ListNavigator; + typedef std::shared_ptr<ListNavigator> ListNavigatorPtr; + + class ListNavigator : + virtual public Navigator + { + public: + using PointerType = ListNavigatorPtr; + + public: + // constructors + ListNavigator(const Path& path = Path()); + ListNavigator(const data::AronListPtr&, const Path& path = Path()); + ListNavigator(const data::AronDataList&, const Path& path = Path()); + ListNavigator(const std::vector<NavigatorPtr>&, const Path& path = Path()); + + // operators + bool operator==(const ListNavigator&) const; + virtual bool equalsDataNavigator(const NavigatorPtr&) const override; + bool equalsDeep(const ListNavigatorPtr&) const; + + // static methods + static ListNavigatorPtr DynamicCast(const NavigatorPtr& n); + static ListNavigator DynamicCast(Navigator& n); + static ListNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + static ListNavigatorPtr FromAronListPtr(const data::AronListPtr& aron); + static data::AronListPtr ToAronListPtr(const ListNavigatorPtr& navigator); + + // public member functions + data::AronListPtr toAronListPtr() const; + + void addElement(const NavigatorPtr&); + NavigatorPtr getElement(unsigned int) const; + bool hasElement(unsigned int) const; + std::vector<NavigatorPtr> getElements() const; + + void clear(); + + NavigatorPtr navigateAbsolute(const Path& path) const; + + // virtual implementations + virtual data::AronDataPtr getResult() const override; + virtual std::string getName() const override; + virtual std::vector<NavigatorPtr> getChildren() const override; + virtual size_t childrenSize() const override; + + virtual typenavigator::NavigatorPtr recalculateType() const override; + virtual bool fullfillsType(const typenavigator::NavigatorPtr&) const override; + + private: + std::vector<NavigatorPtr> childrenNavigators; + data::AronListPtr aron; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.cpp similarity index 86% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.cpp index eb71b578dd1801a30f0c5e2817041bc7f1132ed4..897791ce34371545c20d05631b294ee40624b79d 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.cpp @@ -21,11 +21,10 @@ * GNU General Public License */ -#include "AronPrimitiveDataNavigator.h" +#include "Primitive.h" -#include <ArmarXCore/core/exceptions/Exception.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/NavigatorFactory.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h> namespace armarx { @@ -35,21 +34,21 @@ namespace armarx { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ /* constructors */ \ - Aron##upperType##DataNavigator::Aron##upperType##DataNavigator(const data::Aron##upperType##Ptr& o, const AronPath& path) : \ - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAron##upperType, path), \ - AronDataNavigator(AronDataDescriptor::eAron##upperType, path), \ + Aron##upperType##DataNavigator::Aron##upperType##DataNavigator(const data::Aron##upperType##Ptr& o, const Path& path) : \ + AronNavigator<data::Descriptor, data::AronData>::AronNavigator(data::Descriptor::eAron##upperType, path), \ + AronDataNavigator(data::Descriptor::eAron##upperType, path), \ aron(o) \ { \ } \ \ - Aron##upperType##DataNavigator::Aron##upperType##DataNavigator(const AronPath& path) : \ - AronNavigator<AronDataDescriptor, data::AronData>::AronNavigator(AronDataDescriptor::eAron##upperType, path), \ - AronDataNavigator(AronDataDescriptor::eAron##upperType, path), \ + Aron##upperType##DataNavigator::Aron##upperType##DataNavigator(const Path& path) : \ + AronNavigator<data::Descriptor, data::AronData>::AronNavigator(data::Descriptor::eAron##upperType, path), \ + AronDataNavigator(data::Descriptor::eAron##upperType, path), \ aron(new data::Aron##upperType()) \ { \ } \ \ - Aron##upperType##DataNavigator::Aron##upperType##DataNavigator(const lowerType& d, const AronPath& path) : \ + Aron##upperType##DataNavigator::Aron##upperType##DataNavigator(const lowerType& d, const Path& path) : \ Aron##upperType##DataNavigator(data::Aron##upperType##Ptr(new data::Aron##upperType(d)), path) \ { \ } \ @@ -156,7 +155,7 @@ namespace armarx return 0; \ } \ - HANDLE_PRIMITIVE_TYPES + HANDLE_PRIMITIVE_DATA #undef RUN_ARON_MACRO } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.h similarity index 53% rename from source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.h index 5f74de20505f749c204a594a163601c2ea1835db..45ac0dc1f1cfb4a2411909fe28854a581495e5f6 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronPrimitiveDataNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/data/primitive/Primitive.h @@ -28,47 +28,43 @@ // ArmarX #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/data/Navigator.h> -namespace armarx +namespace armarx::aron::datanavigator { - namespace aron - { - namespace datanavigator - { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##DataNavigator; \ - typedef std::shared_ptr<Aron##upperType##DataNavigator> Aron##upperType##DataNavigatorPtr; + class upperType##Navigator; \ + typedef std::shared_ptr<upperType##Navigator> upperType##NavigatorPtr; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##DataNavigator : \ - virtual public AronPrimitiveDataNavigator \ + class upperType##Navigator : \ + virtual public Navigator \ { \ public: \ - using PointerType = Aron##upperType##DataNavigatorPtr; \ + using PointerType = upperType##NavigatorPtr; \ \ /* constructors */ \ - Aron##upperType##DataNavigator(const AronPath& = AronPath()); \ - Aron##upperType##DataNavigator(const data::Aron##upperType##Ptr&, const AronPath& = AronPath()); \ - Aron##upperType##DataNavigator(const lowerType&, const AronPath& = AronPath()); \ + upperType##Navigator(const Path& = Path()); \ + upperType##Navigator(const data::Aron##upperType##Ptr&, const Path& = Path()); \ + upperType##Navigator(const lowerType&, const Path& = Path()); \ \ /* operators */ \ - bool operator==(const Aron##upperType##DataNavigator&) const; \ - virtual bool equalsDataNavigator(const AronDataNavigatorPtr&) const override; \ - bool equalsDeep(const Aron##upperType##DataNavigatorPtr&) const; \ + bool operator==(const upperType##Navigator&) const; \ + virtual bool equalsDataNavigator(const NavigatorPtr&) const override; \ + bool equalsDeep(const upperType##NavigatorPtr&) const; \ \ /* static methods */ \ - static Aron##upperType##DataNavigatorPtr DynamicCast(const AronDataNavigatorPtr& n); \ - static Aron##upperType##DataNavigator DynamicCast(AronDataNavigator& n); \ - static Aron##upperType##DataNavigatorPtr DynamicCastAndCheck(const AronDataNavigatorPtr& n); \ + static upperType##NavigatorPtr DynamicCast(const NavigatorPtr& n); \ + static upperType##Navigator DynamicCast(Navigator& n); \ + static upperType##NavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); \ \ - static Aron##upperType##DataNavigatorPtr FromAron##upperType##Ptr(const data::Aron##upperType##Ptr& aron); \ - static data::Aron##upperType##Ptr ToAron##upperType##Ptr(const Aron##upperType##DataNavigatorPtr& navigator); \ + static upperType##NavigatorPtr FromAron##upperType##Ptr(const data::Aron##upperType##Ptr& aron); \ + static data::Aron##upperType##Ptr ToAron##upperType##Ptr(const upperType##NavigatorPtr& navigator); \ \ /* public member functions */ \ void setValue(const lowerType& x); \ @@ -79,19 +75,17 @@ namespace armarx /* virtual implementations */ \ virtual data::AronDataPtr getResult() const override; \ virtual std::string getName() const override; \ - virtual std::vector<AronDataNavigatorPtr> getChildren() const override; \ + virtual std::vector<NavigatorPtr> getChildren() const override; \ virtual size_t childrenSize() const override; \ \ - virtual typenavigator::AronTypeNavigatorPtr recalculateType() const override; \ - virtual bool fullfillsType(const typenavigator::AronTypeNavigatorPtr&) const override; \ + virtual typenavigator::NavigatorPtr recalculateType() const override; \ + virtual bool fullfillsType(const typenavigator::NavigatorPtr&) const override; \ \ private: \ /* members */ \ data::Aron##upperType##Ptr aron; \ }; - HANDLE_PRIMITIVE_TYPES + HANDLE_PRIMITIVE_DATA #undef RUN_ARON_MACRO - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h new file mode 100644 index 0000000000000000000000000000000000000000..d1b5b03a26dd0ac3784223887c43fd54ecddcd7b --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/AllNavigators.h @@ -0,0 +1,18 @@ +#pragma once + +#include "container/Dict.h" +#include "container/List.h" +#include "container/Object.h" +#include "container/Pair.h" +#include "container/Tuple.h" +#include "ndarray/EigenMatrix.h" +#include "ndarray/EigenQuaternion.h" +#include "ndarray/IVTCByteImage.h" +#include "ndarray/OpenCVMat.h" +#include "ndarray/Orientation.h" +#include "ndarray/PCLPointCloud.h" +#include "ndarray/PCLPointCloud.h" +#include "ndarray/Pose.h" +#include "ndarray/Position.h" +#include "enum/IntEnum.h" +#include "primitive/Primitive.h" diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.cpp similarity index 68% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.cpp index b4476ab539fefa604b2ab737bb97e0ac7bfc3516..12cc9e7ba4a0c1534944dd667974fd02cbe1491c 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.cpp @@ -24,11 +24,11 @@ // STD/STL // Header -#include "AronTypeNavigator.h" +#include "Navigator.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h> namespace armarx { @@ -38,20 +38,20 @@ namespace armarx { /* AronTypeNavigator */ // static data members - const AronTypeNavigatorFactoryPtr AronTypeNavigator::FACTORY = AronTypeNavigatorFactoryPtr(new AronTypeNavigatorFactory()); + const NavigatorFactoryPtr Navigator::FACTORY = NavigatorFactoryPtr(new NavigatorFactory()); // constructors - AronTypeNavigator::AronTypeNavigator(const AronTypeDescriptor& d, const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(d, path) + Navigator::Navigator(const type::Descriptor& d, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(d, path) { } - AronTypeNavigatorPtr AronTypeNavigator::FromAronType(const type::AronTypePtr& a, const AronPath& path) + NavigatorPtr Navigator::FromAronType(const type::AronTypePtr& a, const Path& path) { return FACTORY->create(a, path); } - void AronTypeNavigator::CheckTypeNavigatorPtrForNull(const std::string& c, const std::string& m, const AronTypeNavigatorPtr& data) + void Navigator::CheckTypeNavigatorPtrForNull(const std::string& c, const std::string& m, const NavigatorPtr& data) { if (data.get() == nullptr) { @@ -59,16 +59,16 @@ namespace armarx } } - void AronTypeNavigator::CheckTypeNavigatorPtrForNull(const std::string& c, const std::string& m, const AronPath& p, const AronTypeNavigatorPtr& data) + void Navigator::CheckTypeNavigatorPtrForNull(const std::string& c, const std::string& m, const Path& p, const NavigatorPtr& data) { if (data.get() == nullptr) { - throw exception::AronExceptionWithPathInfo(c, m, "Could not cast an AronTypeNavigatorPtr. The Ptr was NULL.", p); + throw exception::AronException(c, m, "Could not cast an AronTypeNavigatorPtr. The Ptr was NULL.", p); } } /* AronSingleAcceptedTypeHavingTypeNavigator */ - AronTypeNavigatorPtr AronSingleAcceptedTypeHavingTypeNavigator::getAcceptedType() const + NavigatorPtr AronSingleAcceptedTypeHavingTypeNavigator::getAcceptedType() const { return acceptedTypeNavigator; } @@ -79,12 +79,12 @@ namespace armarx } /* AronMultipleListAcceptedTypeHavingTypeNavigator */ - std::vector<AronTypeNavigatorPtr> AronMultipleListAcceptedTypeHavingTypeNavigator::getAcceptedTypes() const + std::vector<NavigatorPtr> AronMultipleListAcceptedTypeHavingTypeNavigator::getAcceptedTypes() const { return acceptedTypeNavigators; } - AronTypeNavigatorPtr AronMultipleListAcceptedTypeHavingTypeNavigator::getAcceptedType(unsigned int i) const + NavigatorPtr AronMultipleListAcceptedTypeHavingTypeNavigator::getAcceptedType(unsigned int i) const { if (i >= acceptedTypeNavigators.size()) { @@ -99,12 +99,12 @@ namespace armarx } /* AronMultipleDictAcceptedTypeHavingTypeNavigator */ - std::map<std::string, AronTypeNavigatorPtr> AronMultipleDictAcceptedTypeHavingTypeNavigator::getAcceptedTypes() const + std::map<std::string, NavigatorPtr> AronMultipleDictAcceptedTypeHavingTypeNavigator::getAcceptedTypes() const { return acceptedTypeNavigators; } - AronTypeNavigatorPtr AronMultipleDictAcceptedTypeHavingTypeNavigator::getAcceptedType(const std::string& s) const + NavigatorPtr AronMultipleDictAcceptedTypeHavingTypeNavigator::getAcceptedType(const std::string& s) const { if (acceptedTypeNavigators.find(s) == acceptedTypeNavigators.end()) { diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h similarity index 77% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h index cd16a8f86387f67771366161140864af083aa6e4..f0574fe94a17a8a136134f5239d1c66bb332d7ac 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h @@ -33,32 +33,28 @@ #include <SimoxUtility/algorithm/string.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronException.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> #include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/AronNavigator.h> +#include <RobotAPI/libraries/aron/aroncore/navigator/Navigator.h> -namespace armarx +namespace armarx::aron::typenavigator { - namespace aron - { - namespace typenavigator - { - class AronTypeNavigatorFactory; - typedef std::shared_ptr<AronTypeNavigatorFactory> AronTypeNavigatorFactoryPtr; - - class AronTypeNavigator; - typedef std::shared_ptr<AronTypeNavigator> AronTypeNavigatorPtr; - - class AronTypeNavigator : - virtual public navigator::AronNavigator<AronTypeDescriptor, type::AronType> + class NavigatorFactory; + typedef std::shared_ptr<NavigatorFactory> NavigatorFactoryPtr; + + class Navigator; + typedef std::shared_ptr<Navigator> NavigatorPtr; + + class Navigator : + virtual public aron::Navigator<type::Descriptor, type::AronType> { public: - using PointerType = AronTypeNavigatorPtr; + using PointerType = NavigatorPtr; public: // constructors - AronTypeNavigator() = delete; - AronTypeNavigator(const AronTypeDescriptor&, const AronPath&); + Navigator() = delete; + Navigator(const type::Descriptor&, const Path&); // virtual methods virtual type::AronTypePtr getResult() const override = 0; @@ -66,42 +62,42 @@ namespace armarx virtual size_t childrenSize() const = 0; // static methods - static AronTypeNavigatorPtr FromAronType(const type::AronTypePtr&, const AronPath& = AronPath()); + static NavigatorPtr FromAronType(const type::AronTypePtr&, const Path& = Path()); template<typename AronNavigatorType> - static typename AronNavigatorType::PointerType DynamicCast(const AronTypeNavigatorPtr& n) + static typename AronNavigatorType::PointerType DynamicCast(const NavigatorPtr& n) { return AronNavigatorType::DynamicCast(n); } template<typename AronNavigatorType> - static typename AronNavigatorType::PointerType DynamicCastAndCheck(const AronTypeNavigatorPtr& n) + static typename AronNavigatorType::PointerType DynamicCastAndCheck(const NavigatorPtr& n) { return AronNavigatorType::DynamicCastAndCheck(n); } protected: - static void CheckTypeNavigatorPtrForNull(const std::string&, const std::string&, const AronTypeNavigatorPtr& data); - static void CheckTypeNavigatorPtrForNull(const std::string&, const std::string&, const AronPath&, const AronTypeNavigatorPtr& data); + static void CheckTypeNavigatorPtrForNull(const std::string&, const std::string&, const NavigatorPtr& data); + static void CheckTypeNavigatorPtrForNull(const std::string&, const std::string&, const Path&, const NavigatorPtr& data); private: - static const AronTypeNavigatorFactoryPtr FACTORY; + static const NavigatorFactoryPtr FACTORY; }; - /* More hierarchy */ + /* class AronContainerTypeNavigator; typedef std::shared_ptr<AronContainerTypeNavigator> AronContainerTypeNavigatorPtr; class AronContainerTypeNavigator : - virtual public AronTypeNavigator + virtual public Navigator { public: using PointerType = AronContainerTypeNavigatorPtr; public: // static methods - static AronContainerTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronContainerTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronContainerTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronContainerTypeNavigator>(n); return casted; @@ -121,20 +117,20 @@ namespace armarx public: // virtual methods - virtual void setAcceptedType(const AronTypeNavigatorPtr&) = 0; - virtual AronTypeNavigatorPtr getAcceptedType() const; + virtual void setAcceptedType(const NavigatorPtr&) = 0; + virtual NavigatorPtr getAcceptedType() const; virtual size_t childrenSize() const override; // static methods - static AronSingleAcceptedTypeHavingTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronSingleAcceptedTypeHavingTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronSingleAcceptedTypeHavingTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronSingleAcceptedTypeHavingTypeNavigator>(n); return casted; } protected: - AronTypeNavigatorPtr acceptedTypeNavigator; + NavigatorPtr acceptedTypeNavigator; }; @@ -149,21 +145,21 @@ namespace armarx using PointerType = AronMultipleListAcceptedTypeHavingTypeNavigatorPtr; public: - virtual void addAcceptedType(const AronTypeNavigatorPtr&) = 0; - virtual std::vector<AronTypeNavigatorPtr> getAcceptedTypes() const; - virtual AronTypeNavigatorPtr getAcceptedType(unsigned int) const; + virtual void addAcceptedType(const NavigatorPtr&) = 0; + virtual std::vector<NavigatorPtr> getAcceptedTypes() const; + virtual NavigatorPtr getAcceptedType(unsigned int) const; virtual size_t childrenSize() const override; // static methods - static AronMultipleListAcceptedTypeHavingTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronMultipleListAcceptedTypeHavingTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronMultipleListAcceptedTypeHavingTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronMultipleListAcceptedTypeHavingTypeNavigator>(n); return casted; } protected: // members - std::vector<AronTypeNavigatorPtr> acceptedTypeNavigators; + std::vector<NavigatorPtr> acceptedTypeNavigators; }; @@ -178,23 +174,23 @@ namespace armarx using PointerType = AronMultipleDictAcceptedTypeHavingTypeNavigatorPtr; public: - virtual void addAcceptedType(const std::string&, const AronTypeNavigatorPtr&) = 0; - virtual std::map<std::string, AronTypeNavigatorPtr> getAcceptedTypes() const; - virtual AronTypeNavigatorPtr getAcceptedType(const std::string&) const; + virtual void addAcceptedType(const std::string&, const NavigatorPtr&) = 0; + virtual std::map<std::string, NavigatorPtr> getAcceptedTypes() const; + virtual NavigatorPtr getAcceptedType(const std::string&) const; virtual size_t childrenSize() const override; std::vector<std::string> getAllKeys() const; // static methods - static AronMultipleDictAcceptedTypeHavingTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronMultipleDictAcceptedTypeHavingTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronMultipleDictAcceptedTypeHavingTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronMultipleDictAcceptedTypeHavingTypeNavigator>(n); return casted; } protected: // members - std::map<std::string, AronTypeNavigatorPtr> acceptedTypeNavigators; + std::map<std::string, NavigatorPtr> acceptedTypeNavigators; }; @@ -210,7 +206,7 @@ namespace armarx public: // static methods - static AronDictSerializerTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronDictSerializerTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronDictSerializerTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronDictSerializerTypeNavigator>(n); return casted; @@ -230,7 +226,7 @@ namespace armarx public: // static methods - static AronListSerializerTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronListSerializerTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronListSerializerTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronListSerializerTypeNavigator>(n); return casted; @@ -243,7 +239,7 @@ namespace armarx typedef std::shared_ptr<AronComplexTypeNavigator> AronComplexTypeNavigatorPtr; class AronComplexTypeNavigator : - virtual public AronTypeNavigator + virtual public Navigator { public: using PointerType = AronComplexTypeNavigatorPtr; @@ -251,7 +247,7 @@ namespace armarx virtual size_t childrenSize() const override; // static methods - static AronComplexTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronComplexTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronComplexTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronComplexTypeNavigator>(n); return casted; @@ -272,13 +268,13 @@ namespace armarx public: // virtual methods virtual void setDimensions(const std::vector<int>&) = 0; - virtual void setUsedType(const std::string&) = 0; + virtual void setTypename(const std::string&) = 0; - virtual std::string getUsedType() const = 0; + virtual std::string getTypename() const = 0; virtual std::vector<int> getDimensions() const = 0; // static methods - static AronNDArraySerializerTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronNDArraySerializerTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronNDArraySerializerTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronNDArraySerializerTypeNavigator>(n); return casted; @@ -291,7 +287,7 @@ namespace armarx typedef std::shared_ptr<AronPrimitiveTypeNavigator> AronPrimitiveTypeNavigatorPtr; class AronPrimitiveTypeNavigator : - virtual public AronTypeNavigator + virtual public Navigator { public: using PointerType = AronPrimitiveTypeNavigatorPtr; @@ -299,12 +295,10 @@ namespace armarx virtual size_t childrenSize() const override; // static methods - static AronPrimitiveTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n) + static AronPrimitiveTypeNavigatorPtr DynamicCast(const NavigatorPtr& n) { AronPrimitiveTypeNavigatorPtr casted = std::dynamic_pointer_cast<AronPrimitiveTypeNavigator>(n); return casted; } - }; - } - } + };*/ } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.cpp similarity index 63% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.cpp index 139a9e146429c4c1362371d65c2e3cabf8385172..1c2f997cf7440df3bf38d45b2cd82a9ccb5a9cb2 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.cpp @@ -24,7 +24,7 @@ // STD/STL // Header -#include "AronTypeNavigatorFactory.h" +#include "NavigatorFactory.h" namespace armarx { @@ -32,41 +32,38 @@ namespace armarx { namespace typenavigator { - - // Map types to factories - const std::map<AronTypeDescriptor, AronTypeNavigatorFactoryPtr> AronTypeNavigatorFactory::FACTORIES = + // Access method + AronTypeNavigatorPtr NavigatorFactory::create(const type::AronTypePtr& aron, const Path& path) const { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - {AronResolver::GetDescriptorForAronTypeId(typeid(type::Aron##upperType##Type)), AronTypeNavigatorFactoryPtr(new Aron##upperType##TypeNavigatorFactory())}, \ + {AronResolver::GetDescriptorForAronTypeId(typeid(type::Aron##upperType##Type)), AronTypeNavigatorFactoryPtr(new Aron##upperType##TypeNavigatorFactory())}, - HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES - HANDLE_PRIMITIVE_TYPES + static const std::map<type::Descriptor, NavigatorFactoryPtr> FACTORIES = + { + HANDLE_ALL_ARON_TYPES + }; #undef RUN_ARON_MACRO - }; - // Access method - AronTypeNavigatorPtr AronTypeNavigatorFactory::create(const type::AronTypePtr& aron, const AronPath& path) const - { - CheckIfInputIsNull("AronTypeNavigatorFactory", "create", path, aron); + + CheckIfPtrIsNull("NavigatorFactory", "create", path, aron); auto typeDescriptor = AronResolver::GetDescriptorForAronType(aron); auto factory_iterator = FACTORIES.find(typeDescriptor); if (factory_iterator == FACTORIES.end()) { - throw exception::AronExceptionWithPathInfo("AronTypeNavigatorFactory", "create", "Cannot find the desired factory for input: " + AronTypeDescriptorToString.at(typeDescriptor) + ". Cannot create navigator", path); + throw exception::AronException("NavigatorFactory", "create", "Cannot find the desired factory for input: " + type::DescriptorToString.at(typeDescriptor) + ". Cannot create navigator", path); } return factory_iterator->second->createSpecific(aron, path); } - AronTypeNavigatorPtr AronTypeNavigatorFactory::createSpecific(const type::AronTypePtr&, const AronPath& p) const + AronTypeNavigatorPtr NavigatorFactory::createSpecific(const type::AronTypePtr&, const Path& p) const { - throw exception::AronExceptionWithPathInfo("AronTypeNavigatorFactory", "createSpecific", "Called disallowed method of an AronTypeNavigatorFactory. Use child class instead!", p); + throw exception::AronException("NavigatorFactory", "createSpecific", "Called disallowed method of an AronTypeNavigatorFactory. Use child class instead!", p); } // Factories #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - AronTypeNavigatorPtr Aron##upperType##TypeNavigatorFactory::createSpecific(const type::AronTypePtr& aron, const AronPath& path) const \ + AronTypeNavigatorPtr Aron##upperType##TypeNavigatorFactory::createSpecific(const type::AronTypePtr& aron, const Path& path) const \ { \ CheckIfInputIsNull("Aron"+std::string(#upperType)+"TypeNavigatorFactory", "create", path, aron); \ type::Aron##upperType##TypePtr aronCasted = type::Aron##upperType##TypePtr::dynamicCast(aron); \ @@ -74,9 +71,7 @@ namespace armarx return AronTypeNavigatorPtr(new Aron##upperType##TypeNavigator(aronCasted, path)); \ } - HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES - HANDLE_PRIMITIVE_TYPES + HANDLE_ALL_ARON_TYPES #undef RUN_ARON_MACRO } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..c246dcfadb478178c7711d29983ef59168087967 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/NavigatorFactory.h @@ -0,0 +1,64 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <memory> +#include <unordered_map> + +// BaseClass +#include <RobotAPI/libraries/aron/aroncore/navigator/NavigatorFactory.h> + +// ArmarX +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> +#include <RobotAPI/libraries/aron/aroncore/Descriptor.h> + +namespace armarx::aron::typenavigator +{ + class NavigatorFactory; + typedef std::shared_ptr<NavigatorFactory> NavigatorFactoryPtr; + + class NavigatorFactory : + virtual public armarx::aron::NavigatorFactory<type::AronTypePtr, typenavigator::NavigatorPtr> + { + public: + NavigatorFactory() = default; + virtual typenavigator::NavigatorPtr create(const type::AronTypePtr&, const Path&) const override; + virtual typenavigator::NavigatorPtr createSpecific(const type::AronTypePtr&, const Path&) const override; + }; + + // Factories +#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ + class upperType##NavigatorFactory : \ + virtual public NavigatorFactory \ + { \ + public: \ + upperType##NavigatorFactory() = default; \ + virtual typenavigator::NavigatorPtr createSpecific(const type::AronTypePtr&, const Path&) const override; \ + }; + + HANDLE_ALL_ARON_TYPES +#undef RUN_ARON_MACRO + +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.cpp similarity index 63% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.cpp index 6cb665fd736af4fb3b6aa6e28541d4f796ed11fe..b13558c9ef7b9a73bdf3c9e3bd28b4d7fd5e19eb 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronDictTypeNavigator.h" +#include "Dict.h" namespace armarx @@ -32,52 +32,51 @@ namespace armarx namespace typenavigator { // constructors - AronDictTypeNavigator::AronDictTypeNavigator(const AronPath& path) : - AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronDictType, path), - AronTypeNavigator(AronTypeDescriptor::eAronDictType, path), + DictNavigator::DictNavigator(const Path& path) : + Navigator<type::Descriptor, type::AronType>::Navigator(type::Descriptor::eAronDictType, path), + Navigator(type::Descriptor::eAronDictType, path), type(new type::AronDictType()) { } - AronDictTypeNavigator::AronDictTypeNavigator(const type::AronDictTypePtr& o, const AronPath& path) : - AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronDictType, path), - AronTypeNavigator(AronTypeDescriptor::eAronDictType, path), + DictNavigator::DictNavigator(const type::AronDictTypePtr& o, const Path& path) : + Navigator<type::Descriptor, type::AronType>::Navigator(type::Descriptor::eAronDictType, path), + Navigator(type::Descriptor::eAronDictType, path), type(o) { CheckAronPtrForNull("AronDictTypeNavigator", "AronDictTypeNavigator", getPath(), o); - acceptedTypeNavigator = FromAronType(o->acceptedType); } - void AronDictTypeNavigator::setAcceptedType(const AronTypeNavigatorPtr& a) + void DictNavigator::setAcceptedType(const NavigatorPtr& a) { type->acceptedType = a->getResult(); acceptedTypeNavigator = a; } // static methods - AronDictTypeNavigatorPtr AronDictTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) + DictNavigatorPtr DictNavigator::DynamicCast(const NavigatorPtr& n) { - return std::dynamic_pointer_cast<AronDictTypeNavigator>(n); + return std::dynamic_pointer_cast<DictNavigator>(n); } - AronDictTypeNavigatorPtr AronDictTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) + DictNavigatorPtr DictNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckTypeNavigatorPtrForNull("AronDictTypeNavigator", "DynamicCastAndCheck[Before]", n); - AronDictTypeNavigatorPtr casted = AronDictTypeNavigator::DynamicCast(n); + DictNavigatorPtr casted = DictNavigator::DynamicCast(n); CheckTypeNavigatorPtrForNull("AronDictTypeNavigator", "DynamicCastAndCheck[After]", n->getPath(), casted); return casted; } // virtual implementations - type::AronTypePtr AronDictTypeNavigator::getResult() const + type::AronTypePtr DictNavigator::getResult() const { CheckAronPtrForNull("AronDictTypeNavigator", "getResult", getPath(), type->acceptedType); return type; } - std::string AronDictTypeNavigator::getName() const + std::string DictNavigator::getName() const { return "AronDictType<" + acceptedTypeNavigator->getName() + ">"; } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.h similarity index 54% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.h index 785438e1d7ca42c659460cf3508495498f54360a..967660b55dd9857f2e34527e5df2387eab7d02f9 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Dict.h @@ -28,46 +28,40 @@ #include <map> // Base Class -#include "AronTypeNavigator.h" +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> -namespace armarx +namespace armarx::aron::typenavigator { - namespace aron - { - namespace typenavigator - { + class DictNavigator; + typedef std::shared_ptr<DictNavigator> DictNavigatorPtr; - class AronTupleTypeNavigator; - typedef std::shared_ptr<AronTupleTypeNavigator> AronTupleTypeNavigatorPtr; - - class AronTupleTypeNavigator : - virtual public AronMultipleListAcceptedTypeHavingTypeNavigator, - virtual public AronListSerializerTypeNavigator + class DictNavigator : + virtual public Navigator { public: - using PointerType = AronTupleTypeNavigatorPtr; + using PointerType = DictNavigatorPtr; public: // constructors - AronTupleTypeNavigator() = delete; - AronTupleTypeNavigator(const AronPath& path); - AronTupleTypeNavigator(const type::AronTupleTypePtr&, const AronPath& path); + DictNavigator() = delete; + DictNavigator(const Path& path); + DictNavigator(const type::AronDictPtr&, const Path& path); + + void setAcceptedType(const NavigatorPtr&); - type::AronTupleTypePtr toAronTupleTypePtr() const; + type::AronDictPtr toAronDictPtr() const; // static methods - static AronTupleTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronTupleTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); + static DictNavigatorPtr DynamicCast(const NavigatorPtr& n); + static DictNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); // virtual implementations - virtual void addAcceptedType(const AronTypeNavigatorPtr&) override; - virtual type::AronTypePtr getResult() const override; virtual std::string getName() const override; private: - type::AronTupleTypePtr type; + // members + type::AronDictPtr type; + }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/List.cpp similarity index 63% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/List.cpp index 98f6f7364a94546b21afebad5c3fc86c04189af0..c04f3671aaa41eabf7e5749f896bfcd63e1904be 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/List.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronListTypeNavigator.h" +#include "List.h" namespace armarx { @@ -31,55 +31,54 @@ namespace armarx namespace typenavigator { // constructors - AronListTypeNavigator::AronListTypeNavigator(const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronListType, path), - AronTypeNavigator(AronTypeDescriptor::eAronListType, path), + ListNavigator::ListNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronListType, path), + Navigator(type::Descriptor::eAronListType, path), type(new type::AronListType()) { } - AronListTypeNavigator::AronListTypeNavigator(const type::AronListTypePtr& o, const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronListType, path), - AronTypeNavigator(AronTypeDescriptor::eAronListType, path), + ListNavigator::ListNavigator(const type::AronListTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronListType, path), + Navigator(type::Descriptor::eAronListType, path), type(o) { CheckAronPtrForNull("AronListTypeNavigator", "AronListTypeNavigator", getPath(), o); - acceptedTypeNavigator = FromAronType(o->acceptedType); } // static methods - AronListTypeNavigatorPtr AronListTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) + ListNavigatorPtr ListNavigator::DynamicCast(const NavigatorPtr& n) { - return std::dynamic_pointer_cast<AronListTypeNavigator>(n); + return std::dynamic_pointer_cast<ListNavigator>(n); } - AronListTypeNavigatorPtr AronListTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) + ListNavigatorPtr ListNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckTypeNavigatorPtrForNull("AronListTypeNavigator", "DynamicCast[Before]", n); - AronListTypeNavigatorPtr casted = AronListTypeNavigator::DynamicCast(n); + ListNavigatorPtr casted = ListNavigator::DynamicCast(n); CheckTypeNavigatorPtrForNull("AronListTypeNavigator", "DynamicCast[After]", n->getPath(), casted); return casted; } - type::AronListTypePtr AronListTypeNavigator::toAronListTypePtr() const + type::AronListTypePtr ListNavigator::toAronListTypePtr() const { CheckAronPtrForNull("AronListTypeNavigator", "getCastedResult", getPath(), type->acceptedType); return type; } // virtual implementations - type::AronTypePtr AronListTypeNavigator::getResult() const + type::AronTypePtr ListNavigator::getResult() const { return toAronListTypePtr(); } - std::string AronListTypeNavigator::getName() const + std::string ListNavigator::getName() const { return "AronListType<" + acceptedTypeNavigator->getName() + ">"; } - void AronListTypeNavigator::setAcceptedType(const AronTypeNavigatorPtr& a) + void ListNavigator::setAcceptedType(const NavigatorPtr& a) { CheckTypeNavigatorPtrForNull("AronListTypeNavigator", "setAcceptedType", a); type->acceptedType = a->getResult(); diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h similarity index 55% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h index 2bb8fe8c3847c7f8c9d723c6a97ce7340d9ac782..f0508053a6b2cf6bb397fe707374e04a4f7ee49c 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/List.h @@ -28,46 +28,39 @@ #include <vector> // Base Class -#include "AronTypeNavigator.h" +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> -namespace armarx +namespace armarx::aron::typenavigator { - namespace aron - { - namespace typenavigator - { - class AronListTypeNavigator; - typedef std::shared_ptr<AronListTypeNavigator> AronListTypeNavigatorPtr; + class ListNavigator; + typedef std::shared_ptr<ListNavigator> ListNavigatorPtr; - class AronListTypeNavigator : - virtual public AronSingleAcceptedTypeHavingTypeNavigator, - virtual public AronListSerializerTypeNavigator + class ListNavigator : + virtual public Navigator { public: - using PointerType = AronListTypeNavigatorPtr; + using PointerType = ListNavigatorPtr; public: // constructors - AronListTypeNavigator() = delete; - AronListTypeNavigator(const AronPath& path); - AronListTypeNavigator(const type::AronListTypePtr&, const AronPath& path); + ListNavigator() = delete; + ListNavigator(const Path& path); + ListNavigator(const type::AronListPtr&, const Path& path); - type::AronListTypePtr toAronListTypePtr() const; + void setAcceptedType(const NavigatorPtr&); + + type::AronListPtr toAronListPtr() const; // static methods - static AronListTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronListTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); + static ListNavigatorPtr DynamicCast(const NavigatorPtr& n); + static ListNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); // virtual implementations - virtual void setAcceptedType(const AronTypeNavigatorPtr&) override; - virtual type::AronTypePtr getResult() const override; virtual std::string getName() const override; private: // members - type::AronListTypePtr type; + type::AronListPtr type; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.cpp similarity index 58% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.cpp index 9d483dd69ab02a49a1a8ea95bfe93a6010ee6807..3be51b39f6a112e1179d86e030cd033787a1d331 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronObjectTypeNavigator.h" +#include "Object.h" namespace armarx @@ -33,82 +33,90 @@ namespace armarx { // constructors - AronObjectTypeNavigator::AronObjectTypeNavigator(const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronObjectType, path), - AronTypeNavigator(AronTypeDescriptor::eAronObjectType, path), + ObjectNavigator::ObjectNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronObjectType, path), + Navigator(type::Descriptor::eAronObjectType, path), type((new type::AronObjectType())) { } - AronObjectTypeNavigator::AronObjectTypeNavigator(const type::AronObjectTypePtr& o, const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronObjectType, path), - AronTypeNavigator(AronTypeDescriptor::eAronObjectType, path), + ObjectNavigator::ObjectNavigator(const type::AronObjectTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronObjectType, path), + Navigator(type::Descriptor::eAronObjectType, path), type(o) { CheckAronPtrForNull("AronObjectTypeNavigator", "AronObjectTypeNavigator", getPath(), o); - for(const auto& [key, t] : o->elementTypes) + for (const auto& [key, t] : o->elementTypes) { acceptedTypeNavigators[key] = FromAronType(t); } } + bool ObjectNavigator::checkObjectName(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronObjectTypeNavigator", "getResult", "The object name is empty.", getPath()); + } + return true; + } + // static methods - AronObjectTypeNavigatorPtr AronObjectTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) + ObjectNavigatorPtr ObjectNavigator::DynamicCast(const NavigatorPtr& n) { - return std::dynamic_pointer_cast<AronObjectTypeNavigator>(n); + return std::dynamic_pointer_cast<ObjectNavigator>(n); } - AronObjectTypeNavigatorPtr AronObjectTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) + ObjectNavigatorPtr ObjectNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckTypeNavigatorPtrForNull("AronObjectTypeNavigator", "DynamicCast[Before]", n); - AronObjectTypeNavigatorPtr casted = AronObjectTypeNavigator::DynamicCast(n); + ObjectNavigatorPtr casted = ObjectNavigator::DynamicCast(n); CheckTypeNavigatorPtrForNull("AronObjectTypeNavigator", "DynamicCast[After]", n->getPath(), casted); return casted; } // public member functions - void AronObjectTypeNavigator::addAcceptedType(const std::string& k, const AronTypeNavigatorPtr& v) + void ObjectNavigator::addAcceptedType(const std::string& k, const NavigatorPtr& v) { if (k.empty()) { - throw exception::AronExceptionWithPathInfo("AronObjectTypeNavigator", "addAcceptedType", "Cannot set an element with an empty key.", getPath()); + throw exception::AronException("AronObjectTypeNavigator", "addAcceptedType", "Cannot set an element with an empty key.", getPath()); } CheckTypeNavigatorPtrForNull("AronObjectTypeNavigator", "addAcceptedType", v); type->elementTypes[k] = v->getResult(); acceptedTypeNavigators[k] = v; } - void AronObjectTypeNavigator::setObjectName(const std::string& n) + void ObjectNavigator::setObjectName(const std::string& n) { //path.setRootIdentifier(n); type->objectName = n; } - void AronObjectTypeNavigator::setExtends(const AronObjectTypeNavigatorPtr& p) + void ObjectNavigator::setExtends(const ObjectNavigatorPtr& p) { CheckTypeNavigatorPtrForNull("AronObjectTypeNavigator", "setExtends", p); - type::AronObjectTypePtr ex = type::AronObjectTypePtr::dynamicCast(p->getResult()); + type::AronObjectTypePtr ex = p->toAronObjectTypePtr(); CheckAronPtrForNull("AronObjectTypeNavigator", "setExtends", getPath(), ex); extends = p; } - std::string AronObjectTypeNavigator::getObjectName() const + std::string ObjectNavigator::getObjectName() const { return type->objectName; } - AronObjectTypeNavigatorPtr AronObjectTypeNavigator::getExtends() const + ObjectNavigatorPtr ObjectNavigator::getExtends() const { return extends; } - type::AronObjectTypePtr AronObjectTypeNavigator::toAronObjectTypePtr() const + type::AronObjectTypePtr ObjectNavigator::toAronObjectTypePtr() const { - if (type->objectName.empty()) - { - throw exception::AronExceptionWithPathInfo("AronObjectTypeNavigator", "getResult", "The object name is empty.", getPath()); - } + checkObjectName(type->objectName); + + // TODO: Shall we allow empty objects? //if(acceptedTypeNavigators.empty()) //{ // throw exception::AronExceptionWithPathInfo("AronObjectTypeNavigator", "getResult", "No accepted types set", getPath()); @@ -117,12 +125,12 @@ namespace armarx } // virtual implementations - type::AronTypePtr AronObjectTypeNavigator::getResult() const + type::AronTypePtr ObjectNavigator::getResult() const { return toAronObjectTypePtr(); } - std::string AronObjectTypeNavigator::getName() const + std::string ObjectNavigator::getName() const { return "AronObjectType<" + type->objectName + ">"; } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h similarity index 54% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h index 4ce10c46896a1b7c597cdbac8142a2fa875d9720..a359e3c58654736d7ff19c07fd7b1800f317c56b 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Object.h @@ -28,56 +28,48 @@ #include <map> // Base Class -#include "AronTypeNavigator.h" +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> -namespace armarx +namespace armarx::aron::typenavigator { - namespace aron - { - namespace typenavigator - { + class ObjectNavigator; + typedef std::shared_ptr<ObjectNavigator> ObjectNavigatorPtr; - class AronObjectTypeNavigator; - typedef std::shared_ptr<AronObjectTypeNavigator> AronObjectTypeNavigatorPtr; - - class AronObjectTypeNavigator : - virtual public AronMultipleDictAcceptedTypeHavingTypeNavigator, - virtual public AronDictSerializerTypeNavigator + class ObjectNavigator : + virtual public Navigator { public: - using PointerType = AronObjectTypeNavigatorPtr; + using PointerType = ObjectNavigatorPtr; public: // constructors - AronObjectTypeNavigator(const AronPath& = AronPath()); - AronObjectTypeNavigator(const type::AronObjectTypePtr&, const AronPath& = AronPath()); + ObjectNavigator(const Path& = Path()); + ObjectNavigator(const type::AronObjectPtr&, const Path& = Path()); // public member functions + bool checkObjectName(const std::string&) const; + std::string getObjectName() const; - AronObjectTypeNavigatorPtr getExtends() const; + ObjectNavigatorPtr getExtends() const; void setObjectName(const std::string&); - void setExtends(const AronObjectTypeNavigatorPtr&); + void setExtends(const ObjectNavigatorPtr&); + void addAcceptedType(const std::string&, const NavigatorPtr&); - type::AronObjectTypePtr toAronObjectTypePtr() const; + type::AronObjectPtr toAronObjectT´Ptr() const; // static methods - static AronObjectTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronObjectTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); + static ObjectNavigatorPtr DynamicCast(const NavigatorPtr& n); + static ObjectNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); // virtual implementations - virtual void addAcceptedType(const std::string&, const AronTypeNavigatorPtr&) override; - virtual type::AronTypePtr getResult() const override; virtual std::string getName() const override; private: // members - AronObjectTypeNavigatorPtr extends; - type::AronObjectTypePtr type; - + ObjectNavigatorPtr extends; + type::AronObjectPtr type; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Pair.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Pair.cpp new file mode 100644 index 0000000000000000000000000000000000000000..93af6d1d883dd8884ef3b3ea9d5284abfb96c909 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Pair.cpp @@ -0,0 +1,117 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "Pair.h" + + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + PairNavigator::PairNavigator(const Path& path) : + Navigator<type::Descriptor, type::AronType>::Navigator(type::Descriptor::eAronPairType, path), + Navigator(type::Descriptor::eAronPairType, path), + type(new type::AronPairType()) + { + + } + + PairNavigator::PairNavigator(const type::AronPairTypePtr& o, const Path& path) : + Navigator<type::Descriptor, type::AronType>::Navigator(type::Descriptor::eAronPairType, path), + Navigator(type::Descriptor::eAronPairType, path), + type(o) + { + CheckAronPtrForNull("AronPairTypeNavigator", "AronPairTypeNavigator", getPath(), o); + + for (const auto& t : o->elementTypes) + { + acceptedTypeNavigators.push_back(FromAronType(t)); + } + + checkAcceptedTypes(acceptedTypeNavigators); + } + + bool PairNavigator::checkAcceptedTypes(const std::vector<NavigatorPtr>& v) const + { + if (v.size() != 2) + { + throw exception::AronException("AronPairTypeNavigator", "checkAcceptedTypes", "A pair must have exactly two types", getPath()); + } + return true; + } + + type::AronPairTypePtr PairNavigator::toAronPairTypePtr() const + { + checkAcceptedTypes(acceptedTypeNavigators); + return type; + } + + void PairNavigator::addAcceptedType(const NavigatorPtr& a) + { + CheckTypeNavigatorPtrForNull("AronPairTypeNavigator", "addAcceptedType", a); + if (acceptedTypeNavigators.size() > 1) + { + throw exception::AronException("AronPairTypeNavigator", "checkAcceptedTypes", "Could not add another accepted type to a pair", getPath()); + } + type->elementTypes.push_back(a->getResult()); + acceptedTypeNavigators.push_back(a); + } + + // static methods + PairNavigatorPtr PairNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<PairNavigator>(n); + } + + PairNavigatorPtr PairNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronPairTypeNavigator", "DynamicCastAndCheck[Before]", n); + PairNavigatorPtr casted = PairNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronPairTypeNavigator", "DynamicCastAndCheck[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr PairNavigator::getResult() const + { + CheckAronPtrForNull("AronPairTypeNavigator", "getResult", getPath(), type->acceptedType); + return type; + } + + std::string PairNavigator::getName() const + { + std::vector<std::string> names; + for (const auto& n : acceptedTypeNavigators) + { + names.push_back(n->getName()); + } + return "AronPairType<" + simox::alg::to_string(names, ", ") + ">"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Pair.h similarity index 55% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Pair.h index b1de1358f8205c823ab05915e1ce82f046ba468f..6c02ce746040a99845025f84b8665d94a516192f 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Pair.h @@ -28,47 +28,42 @@ #include <map> // Base Class -#include "AronTypeNavigator.h" +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> -namespace armarx +namespace armarx::aron::typenavigator { - namespace aron - { - namespace typenavigator - { - class AronDictTypeNavigator; - typedef std::shared_ptr<AronDictTypeNavigator> AronDictTypeNavigatorPtr; + class PairNavigator; + typedef std::shared_ptr<PairNavigator> PairNavigatorPtr; - class AronDictTypeNavigator : - virtual public AronSingleAcceptedTypeHavingTypeNavigator, - virtual public AronDictSerializerTypeNavigator + class PairNavigator : + virtual public Navigator { public: - using PointerType = AronDictTypeNavigatorPtr; + using PointerType = PairNavigatorPtr; public: // constructors - AronDictTypeNavigator() = delete; - AronDictTypeNavigator(const AronPath& path); - AronDictTypeNavigator(const type::AronDictTypePtr&, const AronPath& path); + PairNavigator() = delete; + PairNavigator(const Path& path); + PairNavigator(const type::AronPairPtr&, const Path& path); - type::AronDictTypePtr toAronDictTypePtr() const; + bool checkAcceptedTypes(const std::vector<NavigatorPtr>&) const; + + void addAcceptedType(const NavigatorPtr&); + + type::AronPairPtr toAronPairPtr() const; // static methods - static AronDictTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronDictTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); + static PairNavigatorPtr DynamicCast(const NavigatorPtr& n); + static PairNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); // virtual implementations - virtual void setAcceptedType(const AronTypeNavigatorPtr&) override; - virtual type::AronTypePtr getResult() const override; virtual std::string getName() const override; private: // members - type::AronDictTypePtr type; + type::AronPairPtr type; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.cpp similarity index 62% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.cpp index 9f9d44403a7159ecc4746e027cee37ac1cd9cb6c..0edbb8a4a40b8e1f105d46b42e344295bdacc5af 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.cpp @@ -22,7 +22,7 @@ */ // Header -#include "AronTupleTypeNavigator.h" +#include "Tuple.h" namespace armarx @@ -32,16 +32,16 @@ namespace armarx namespace typenavigator { // constructors - AronTupleTypeNavigator::AronTupleTypeNavigator(const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronTupleType, path), - AronTypeNavigator(AronTypeDescriptor::eAronTupleType, path), + TupleNavigator::TupleNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronTupleType, path), + Navigator(type::Descriptor::eAronTupleType, path), type(new type::AronTupleType()) { } - AronTupleTypeNavigator::AronTupleTypeNavigator(const type::AronTupleTypePtr& o, const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronTupleType, path), - AronTypeNavigator(AronTypeDescriptor::eAronTupleType, path), + TupleNavigator::TupleNavigator(const type::AronTupleTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronTupleType, path), + Navigator(type::Descriptor::eAronTupleType, path), type(o) { CheckAronPtrForNull("AronTupleTypeNavigator", "AronTupleTypeNavigator", getPath(), o); @@ -52,31 +52,31 @@ namespace armarx } } - type::AronTupleTypePtr AronTupleTypeNavigator::toAronTupleTypePtr() const + type::AronTupleTypePtr TupleNavigator::toAronTupleTypePtr() const { if (acceptedTypeNavigators.empty()) { - throw exception::AronExceptionWithPathInfo("AronTupleTypeNavigator", "getCastedResult", "No accepted types set", getPath()); + throw exception::AronException("AronTupleTypeNavigator", "getCastedResult", "No accepted types set", getPath()); } return type; } // static methods - AronTupleTypeNavigatorPtr AronTupleTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) + TupleNavigatorPtr TupleNavigator::DynamicCast(const NavigatorPtr& n) { - return std::dynamic_pointer_cast<AronTupleTypeNavigator>(n); + return std::dynamic_pointer_cast<TupleNavigator>(n); } - AronTupleTypeNavigatorPtr AronTupleTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) + TupleNavigatorPtr TupleNavigator::DynamicCastAndCheck(const NavigatorPtr& n) { CheckTypeNavigatorPtrForNull("AronTupleTypeNavigator", "DynamicCast[Before]", n); - AronTupleTypeNavigatorPtr casted = AronTupleTypeNavigator::DynamicCast(n); + TupleNavigatorPtr casted = TupleNavigator::DynamicCast(n); CheckTypeNavigatorPtrForNull("AronTupleTypeNavigator", "DynamicCast[After]", n->getPath(), casted); return casted; } // public member functions - void AronTupleTypeNavigator::addAcceptedType(const AronTypeNavigatorPtr& v) + void TupleNavigator::addAcceptedType(const NavigatorPtr& v) { CheckTypeNavigatorPtrForNull("AronTupleTypeNavigator", "addAcceptedType", getPath(), v); type->elementTypes.push_back(v->getResult()); @@ -84,15 +84,15 @@ namespace armarx } // virtual implementations - type::AronTypePtr AronTupleTypeNavigator::getResult() const + type::AronTypePtr TupleNavigator::getResult() const { return toAronTupleTypePtr(); } - std::string AronTupleTypeNavigator::getName() const + std::string TupleNavigator::getName() const { std::vector<std::string> names; - for (const auto n : acceptedTypeNavigators) + for (const auto& n : acceptedTypeNavigators) { names.push_back(n->getName()); } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.h new file mode 100644 index 0000000000000000000000000000000000000000..aa4529db4a89c50f4c5b7e119a91f0437bebaa5e --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/container/Tuple.h @@ -0,0 +1,65 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class TupleNavigator; + typedef std::shared_ptr<TupleNavigator> TupleNavigatorPtr; + + class TupleNavigator : + virtual public Navigator + { + public: + using PointerType = TupleNavigatorPtr; + + public: + // constructors + TupleNavigator() = delete; + TupleNavigator(const Path& path); + TupleNavigator(const type::AronTuplePtr&, const Path& path); + + void addAcceptedType(const NavigatorPtr&); + + type::AronTuplePtr toAronTuplePtr() const; + + // static methods + static TupleNavigatorPtr DynamicCast(const NavigatorPtr& n); + static TupleNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + private: + type::AronTuplePtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/enum/IntEnum.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/enum/IntEnum.cpp new file mode 100644 index 0000000000000000000000000000000000000000..429a32eb47c5646f58864704c6703c1d03cf1de8 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/enum/IntEnum.cpp @@ -0,0 +1,163 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "IntEnum.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + IntEnumNavigator::IntEnumNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronEnumType, path), + Navigator(type::Descriptor::eAronEnumType, path), + type(new type::AronEnumType({0, 0}, "")) + { + } + + IntEnumNavigator::IntEnumNavigator(const type::AronEnumTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronEnumType, path), + Navigator(type::Descriptor::eAronEnumType, path), + type(o) + { + CheckAronPtrForNull("AronEnumTypeNavigator", "AronEnumTypeNavigator", getPath(), o); + if (type->dimensions.size() != 2) + { + throw exception::SizeNotValidException("AronEnumTypeNavigator", "AronEnumTypeNavigator", "The size of the AronPtr is too small", type->dimensions.size(), 2); + } + } + + bool IntEnumNavigator::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE || d.size() > ACCEPTED_DIMENSION_MAX_SIZE) + { + throw exception::AronException("AronEnumTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + return true; + } + + bool IntEnumNavigator::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronEnumTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronEnumTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronEnumTypePtr IntEnumNavigator::toAronEnumTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::vector<int> IntEnumNavigator::getDimensions() const + { + return type->dimensions; + } + + void IntEnumNavigator::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + unsigned int IntEnumNavigator::getWidth() const + { + return type->dimensions[0]; + } + + unsigned int IntEnumNavigator::getHeight() const + { + return type->dimensions[1]; + } + + std::string IntEnumNavigator::getTypename() const + { + return type->typeName; + } + + void IntEnumNavigator::setWidth(const unsigned int& w) + { + if (w == 0) + { + throw exception::AronException("AronEnumTypeNavigator", "setWidth", "The width of an image cannot be 0", getPath()); + } + type->dimensions[0] = w; + } + + void IntEnumNavigator::setHeight(const unsigned int& h) + { + if (h == 0) + { + throw exception::AronException("AronEnumTypeNavigator", "setHeight", "The height of an image cannot be 0", getPath()); + } + type->dimensions[1] = h; + } + + void IntEnumNavigator::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + // static methods + IntEnumNavigatorPtr IntEnumNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<IntEnumNavigator>(n); + } + + IntEnumNavigatorPtr IntEnumNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronEnumTypeNavigator", "DynamicCast[Before]", n); + IntEnumNavigatorPtr casted = IntEnumNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronEnumTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr IntEnumNavigator::getResult() const + { + return toAronEnumTypePtr(); + } + + std::string IntEnumNavigator::getName() const + { + return "AronEnumType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/enum/IntEnum.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/enum/IntEnum.h new file mode 100644 index 0000000000000000000000000000000000000000..f645a309b8516286985dcf21b2519b0e6772787b --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/enum/IntEnum.h @@ -0,0 +1,66 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class IntEnumNavigator; + typedef std::shared_ptr<IntEnumNavigator> IntEnumNavigatorPtr; + + class IntEnumNavigator : + virtual public Navigator + { + public: + using PointerType = IntEnumNavigatorPtr; + + public: + // constructors + IntEnumNavigator() = delete; + IntEnumNavigator(const Path& path); + IntEnumNavigator(const type::AronIntEnumPtr&, const Path& path); + + type::AronIntEnumPtr toAronIntEnumPtr() const; + + // static methods + static IntEnumNavigatorPtr DynamicCast(const NavigatorPtr& n); + static IntEnumNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + public: + + private: + // members + type::AronIntEnumPtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..918ecd28a982c856b5bf0eb83f46274bc19bdda4 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.cpp @@ -0,0 +1,169 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "EigenMatrix.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + EigenMatrixNavigator::EigenMatrixNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronEigenMatrixType, path), + Navigator(type::Descriptor::eAronEigenMatrixType, path), + type(new type::AronEigenMatrixType({1, 1}, "")) + { + } + + EigenMatrixNavigator::EigenMatrixNavigator(const type::AronEigenMatrixTypePtr& o, const Path& path) : + Navigator<type::Descriptor, type::AronType>::Navigator(type::Descriptor::eAronDictType, path), + Navigator(type::Descriptor::eAronEigenMatrixType, path), + type(o) + { + CheckAronPtrForNull("AronEigenMatrixTypeNavigator", "AronEigenMatrixTypeNavigator", getPath(), o); + checkDimensions(type->dimensions); + checkTypename(type->typeName); + } + + bool EigenMatrixNavigator::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE) + { + throw exception::AronException("AronEigenMatrixTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + + if (std::any_of(d.begin(), d.end(), [](int i) + { + return i < -1 || i == 0; + })) + { + throw exception::AronException("AronEigenMatrixTypeNavigator", "checkDimensions", "The dimension size is wrong. At least one empty is < -1 or 0. Got as dimension: " + simox::alg::to_string(d, ", "), getPath()); + } + return true; + } + + bool EigenMatrixNavigator::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronEigenMatrixTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronEigenMatrixTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + unsigned int EigenMatrixNavigator::getRows() const + { + return type->dimensions[0]; + } + + unsigned int EigenMatrixNavigator::getCols() const + { + return type->dimensions[1]; + } + + void EigenMatrixNavigator::setRows(const unsigned int& w) + { + if (w == 0) + { + throw exception::AronException("AronEigenMatrixTypeNavigator", "setRows", "The rows cannot be 0", getPath()); + } + type->dimensions[0] = w; + } + + void EigenMatrixNavigator::setCols(const unsigned int& h) + { + if (h == 0) + { + throw exception::AronException("AronEigenMatrixTypeNavigator", "setCols", "The cols cannot be 0", getPath()); + } + type->dimensions[1] = h; + } + + type::AronEigenMatrixTypePtr EigenMatrixNavigator::toAronEigenMatrixTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::string EigenMatrixNavigator::getTypename() const + { + return type->typeName; + } + + std::vector<int> EigenMatrixNavigator::getDimensions() const + { + return type->dimensions; + } + + void EigenMatrixNavigator::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + void EigenMatrixNavigator::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + // static methods + EigenMatrixNavigatorPtr EigenMatrixNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<EigenMatrixNavigator>(n); + } + + EigenMatrixNavigatorPtr EigenMatrixNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronEigenMatrixTypeNavigator", "DynamicCast[Before]", n); + EigenMatrixNavigatorPtr casted = EigenMatrixNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronEigenMatrixTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr EigenMatrixNavigator::getResult() const + { + return toAronEigenMatrixTypePtr(); + } + + std::string EigenMatrixNavigator::getName() const + { + return "AronEigenMatrixType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.h new file mode 100644 index 0000000000000000000000000000000000000000..d20511d6df8d754597fcb190fdf18043de8e5124 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenMatrix.h @@ -0,0 +1,88 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class EigenMatrixNavigator; + typedef std::shared_ptr<EigenMatrixNavigator> EigenMatrixNavigatorPtr; + + class EigenMatrixNavigator : + virtual public Navigator + { + public: + using PointerType = EigenMatrixNavigatorPtr; + + public: + // constructors + EigenMatrixNavigator() = delete; + EigenMatrixNavigator(const Path& path); + EigenMatrixNavigator(const type::AronEigenMatrixPtr&, const Path& path); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; + + unsigned int getRows() const; + unsigned int getCols() const; + std::string getTypename() const; + + void setRows(const unsigned int&); + void setCols(const unsigned int&); + void setTypename(const std::string&); + + type::AronEigenMatrixPtr toAronEigenMatrixPtr() const; + + // static methods + static EigenMatrixNavigatorPtr DynamicCast(const NavigatorPtr& n); + static EigenMatrixNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + public: + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"short", {}}, + {"int", {}}, + {"long", {}}, + {"float", {}}, + {"double", {}}, + //{"complex float", {"std::complex<float>"}}, + //{"complex double", {"std::complex<double>"}}, + }; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + + private: + // members + type::AronEigenMatrixPtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenQuaternion.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenQuaternion.cpp new file mode 100644 index 0000000000000000000000000000000000000000..758366cc6063c153b86be9652973b7a9782df832 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenQuaternion.cpp @@ -0,0 +1,149 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "EigenQuaternion.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + const std::map<std::string, std::vector<std::string>> EigenQuaternion::ACCEPTED_TYPES = + { + {"float", {}}, + {"double", {}} + }; + + // constructors + EigenQuaternion::EigenQuaternion(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronEigenQuaternionType, path), + Navigator(type::Descriptor::eAronEigenQuaternionType, path), + type(new type::AronEigenQuaternionType({1, 4}, "")) + { + } + + EigenQuaternion::EigenQuaternion(const type::AronEigenQuaternionTypePtr& o, const Path& path) : + Navigator<type::Descriptor, type::AronType>::Navigator(type::Descriptor::eAronDictType, path), + Navigator(type::Descriptor::eAronEigenQuaternionType, path), + type(o) + { + CheckAronPtrForNull("AronEigenQuaternionTypeNavigator", "AronEigenQuaternionTypeNavigator", getPath(), o); + if (type->dimensions.size() != 2) + { + throw exception::SizeNotValidException("AronEigenQuaternionTypeNavigator", "AronEigenQuaternionTypeNavigator", "The size of the AronPtr is too small", type->dimensions.size(), 2); + } + } + + bool EigenQuaternion::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE) + { + throw exception::AronException("AronEigenQuaternionTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + + if (std::any_of(d.begin(), d.end(), [](int i) + { + return i < -1 || i == 0; + })) + { + throw exception::AronException("AronEigenQuaternionTypeNavigator", "checkDimensions", "The dimension size is wrong. At least one empty is < -1 or 0. Got as dimension: " + simox::alg::to_string(d, ", "), getPath()); + } + return true; + } + + bool EigenQuaternion::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronEigenQuaternionTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronEigenQuaternionTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronEigenQuaternionTypePtr EigenQuaternion::toAronEigenQuaternionTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::string EigenQuaternion::getTypename() const + { + return type->typeName; + } + + std::vector<int> EigenQuaternion::getDimensions() const + { + return type->dimensions; + } + + void EigenQuaternion::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + void EigenQuaternion::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + // static methods + EigenQuaternionPtr EigenQuaternion::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<EigenQuaternion>(n); + } + + EigenQuaternionPtr EigenQuaternion::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronEigenQuaternionTypeNavigator", "DynamicCast[Before]", n); + EigenQuaternionPtr casted = EigenQuaternion::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronEigenQuaternionTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr EigenQuaternion::getResult() const + { + return toAronEigenQuaternionTypePtr(); + } + + std::string EigenQuaternion::getName() const + { + return "AronEigenQuaternionType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenQuaternion.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenQuaternion.h new file mode 100644 index 0000000000000000000000000000000000000000..6a6c0f1e6f6a8e9731790499f361c1185233fd09 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/EigenQuaternion.h @@ -0,0 +1,81 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class EigenQuaternionNavigator; + typedef std::shared_ptr<EigenQuaternionNavigator> EigenQuaternionNavigatorPtr; + + class EigenQuaternionNavigator : + virtual public Navigator + { + public: + using PointerType = EigenQuaternionNavigatorPtr; + + public: + // constructors + EigenQuaternionNavigator() = delete; + EigenQuaternionNavigator(const Path& path); + EigenQuaternionNavigator(const type::AronEigenQuaternionPtr&, const Path& path); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; + + std::string getTypename() const; + void setTypename(const std::string&); + + type::AronEigenQuaternionPtr toAronEigenQuaternionPtr() const; + + // static methods + static EigenQuaternionNavigatorPtr DynamicCast(const NavigatorPtr& n); + static EigenQuaternionNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + public: + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"float", {}}, + {"double", {}} + }; + const std::vector<std::vector<int>> ACCEPTED_DIMENSIONS = + {{1, 4}}; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + const unsigned int ACCEPTED_DIMENSION_MAX_SIZE = 2; + + private: + // members + type::AronEigenQuaternionPtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..94b83d8532300045baea4c5a699b4f52b77c411d --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.cpp @@ -0,0 +1,163 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "IVTCByteImage.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + IVTCByteImage::IVTCByteImage(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronIVTCByteImageType, path), + Navigator(type::Descriptor::eAronIVTCByteImageType, path), + type(new type::AronIVTCByteImageType({0, 0}, "")) + { + } + + IVTCByteImage::IVTCByteImage(const type::AronIVTCByteImageTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronIVTCByteImageType, path), + Navigator(type::Descriptor::eAronIVTCByteImageType, path), + type(o) + { + CheckAronPtrForNull("AronIVTCByteImageTypeNavigator", "AronIVTCByteImageTypeNavigator", getPath(), o); + if (type->dimensions.size() != 2) + { + throw exception::SizeNotValidException("AronIVTCByteImageTypeNavigator", "AronIVTCByteImageTypeNavigator", "The size of the AronPtr is too small", type->dimensions.size(), 2); + } + } + + bool IVTCByteImage::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE || d.size() > ACCEPTED_DIMENSION_MAX_SIZE) + { + throw exception::AronException("AronIVTCByteImageTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + return true; + } + + bool IVTCByteImage::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronIVTCByteImageTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronIVTCByteImageTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronIVTCByteImageTypePtr IVTCByteImage::toAronIVTCByteImageTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::vector<int> IVTCByteImage::getDimensions() const + { + return type->dimensions; + } + + void IVTCByteImage::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + unsigned int IVTCByteImage::getWidth() const + { + return type->dimensions[0]; + } + + unsigned int IVTCByteImage::getHeight() const + { + return type->dimensions[1]; + } + + std::string IVTCByteImage::getTypename() const + { + return type->typeName; + } + + void IVTCByteImage::setWidth(const unsigned int& w) + { + if (w == 0) + { + throw exception::AronException("AronIVTCByteImageTypeNavigator", "setWidth", "The width of an image cannot be 0", getPath()); + } + type->dimensions[0] = w; + } + + void IVTCByteImage::setHeight(const unsigned int& h) + { + if (h == 0) + { + throw exception::AronException("AronIVTCByteImageTypeNavigator", "setHeight", "The height of an image cannot be 0", getPath()); + } + type->dimensions[1] = h; + } + + void IVTCByteImage::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + // static methods + IVTCByteImageNavigatorPtr IVTCByteImage::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<IVTCByteImage>(n); + } + + IVTCByteImageNavigatorPtr IVTCByteImage::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronIVTCByteImageTypeNavigator", "DynamicCast[Before]", n); + IVTCByteImageNavigatorPtr casted = IVTCByteImage::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronIVTCByteImageTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr IVTCByteImage::getResult() const + { + return toAronIVTCByteImageTypePtr(); + } + + std::string IVTCByteImage::getName() const + { + return "AronIVTCByteImageType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.h new file mode 100644 index 0000000000000000000000000000000000000000..d13b81c83752b99b2d6036ee7ddb33058833bcfb --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/IVTCByteImage.h @@ -0,0 +1,85 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class IVTCByteImageNavigator; + typedef std::shared_ptr<IVTCByteImageNavigator> IVTCByteImageNavigatorPtr; + + class IVTCByteImageNavigator : + virtual public Navigator + { + public: + using PointerType = IVTCByteImageNavigatorPtr; + + public: + // constructors + IVTCByteImageNavigator() = delete; + IVTCByteImageNavigator(const Path& path); + IVTCByteImageNavigator(const type::AronIVTCByteImagePtr&, const Path& path); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; + + unsigned int getWidth() const; + unsigned int getHeight() const; + std::string getTypename() const; + + void setWidth(const unsigned int&); + void setHeight(const unsigned int&); + void setTypename(const std::string&); + + type::AronIVTCByteImagePtr toAronIVTCByteImagePtr() const; + + // static methods + static IVTCByteImageNavigatorPtr DynamicCast(const NavigatorPtr& n); + static IVTCByteImageNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + public: + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"GrayScale", {"CByteImage::ImageType::eGrayScale"}}, + {"RGB24", {"CByteImage::ImageType::eRGB24"}}, + {"RGB24Split", {"CByteImage::ImageType::eRGB24Split"}} + }; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + const unsigned int ACCEPTED_DIMENSION_MAX_SIZE = 2; + + private: + // members + type::AronIVTCByteImagePtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.cpp new file mode 100644 index 0000000000000000000000000000000000000000..13a09b744e5990c8218fee672e2663f01c1db1bb --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.cpp @@ -0,0 +1,142 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "OpenCVMat.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + OpenCVMatNavigator::OpenCVMatNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronOpenCVMatType, path), + Navigator(type::Descriptor::eAronOpenCVMatType, path), + type(new type::AronOpenCVMatType({}, "")) + { + } + + OpenCVMatNavigator::OpenCVMatNavigator(const type::AronOpenCVMatTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronOpenCVMatType, path), + Navigator(type::Descriptor::eAronOpenCVMatType, path), + type(o) + { + CheckAronPtrForNull("AronOpenCVMatTypeNavigator", "AronOpenCVMatTypeNavigator", getPath(), o); + checkDimensions(type->dimensions); + checkTypename(type->typeName); + } + + bool OpenCVMatNavigator::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE) + { + throw exception::AronException("AronOpenCVMatTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + + if (std::any_of(d.begin(), d.end(), [](int i) + { + return i < -1 || i == 0; + })) + { + throw exception::AronException("AronOpenCVMatTypeNavigator", "checkDimensions", "The dimension size is wrong. At least one empty is < -1 or 0. Got as dimension: " + simox::alg::to_string(d, ", "), getPath()); + } + return true; + } + + bool OpenCVMatNavigator::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronOpenCVMatTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronOpenCVMatTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronOpenCVMatTypePtr OpenCVMatNavigator::toAronOpenCVMatTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::string OpenCVMatNavigator::getTypename() const + { + return type->typeName; + } + + std::vector<int> OpenCVMatNavigator::getDimensions() const + { + return type->dimensions; + } + + void OpenCVMatNavigator::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + void OpenCVMatNavigator::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + + // static methods + OpenCVMatNavigatorPtr OpenCVMatNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<OpenCVMatNavigator>(n); + } + + OpenCVMatNavigatorPtr OpenCVMatNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronOpenCVMatTypeNavigator", "DynamicCast[Before]", n); + OpenCVMatNavigatorPtr casted = OpenCVMatNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronOpenCVMatTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr OpenCVMatNavigator::getResult() const + { + return toAronOpenCVMatTypePtr(); + } + + std::string OpenCVMatNavigator::getName() const + { + return "AronOpenCVMatType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.h new file mode 100644 index 0000000000000000000000000000000000000000..dd6f06aa8d20d09e7268486f4545009243eda37f --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/OpenCVMat.h @@ -0,0 +1,86 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class OpenCVMatNavigator; + typedef std::shared_ptr<OpenCVMatNavigator> OpenCVMatNavigatorPtr; + + class OpenCVMatNavigator : + virtual public Navigator + { + public: + using PointerType = OpenCVMatNavigatorPtr; + + public: + // constructors + OpenCVMatNavigator() = delete; + OpenCVMatNavigator(const Path& path); + OpenCVMatNavigator(const type::AronOpenCVMatPtr&, const Path& path); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; + + void setDimensions(const std::vector<int>&); + void setTypename(const std::string&); + + std::vector<int> getDimensions() const; + std::string getTypename() const; + + type::AronOpenCVMatPtr toAronOpenCVMatPtr() const; + + // static methods + static OpenCVMatNavigatorPtr DynamicCast(const NavigatorPtr& n); + static OpenCVMatNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + public: + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"CV_8U", {"8U"}}, + {"CV_8S", {"8S"}}, + {"CV_16U", {"16U"}}, + {"CV_16S", {"16S"}}, + {"CV_32S", {"32S"}}, + {"CV_32F", {"32F"}}, + {"CV_64F", {"64F"}} + }; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + + private: + // members + type::AronOpenCVMatPtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Orientation.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Orientation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dd4960d4c3741f610c3733cec9128dcb30e0671f --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Orientation.cpp @@ -0,0 +1,142 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "Orientation.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + OrientationNavigator::OrientationNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronOrientationType, path), + Navigator(type::Descriptor::eAronOrientationType, path), + type(new type::AronOrientationType({1, 4}, "float")) + { + } + + OrientationNavigator::OrientationNavigator(const type::AronOrientationTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronOrientationType, path), + Navigator(type::Descriptor::eAronOrientationType, path), + type(o) + { + CheckAronPtrForNull("AronOrientationTypeNavigator", "AronOrientationTypeNavigator", getPath(), o); + checkDimensions(type->dimensions); + checkTypename(type->typeName); + } + + bool OrientationNavigator::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE || d.size() > ACCEPTED_DIMENSION_MAX_SIZE) + { + throw exception::AronException("AronOrientationTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + + if (!std::any_of(ACCEPTED_DIMENSIONS.begin(), ACCEPTED_DIMENSIONS.end(), [d](const auto & el) + { + return d == el; + })) + { + throw exception::AronException("AronOrientationTypeNavigator", "checkDimensions", "The dimension is wrong. Got " + simox::alg::to_string(d, ", "), getPath()); + } + return true; + } + + bool OrientationNavigator::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronOrientationTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronOrientationTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronOrientationTypePtr OrientationNavigator::toAronOrientationTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::vector<int> OrientationNavigator::getDimensions() const + { + return type->dimensions; + } + + void OrientationNavigator::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + std::string OrientationNavigator::getTypename() const + { + return type->typeName; + } + + void OrientationNavigator::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + + // static methods + OrientationNavigatorPtr OrientationNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<OrientationNavigator>(n); + } + + OrientationNavigatorPtr OrientationNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronOrientationTypeNavigator", "DynamicCast[Before]", n); + OrientationNavigatorPtr casted = OrientationNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronOrientationTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr OrientationNavigator::getResult() const + { + return toAronOrientationTypePtr(); + } + + std::string OrientationNavigator::getName() const + { + return "AronOrientationType"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Orientation.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Orientation.h new file mode 100644 index 0000000000000000000000000000000000000000..c4eaecc632553d9ffde26fbbe6a77876542439ed --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Orientation.h @@ -0,0 +1,77 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class OrientationNavigator; + typedef std::shared_ptr<OrientationNavigator> OrientationNavigatorPtr; + + class OrientationNavigator : + virtual public Navigator + { + public: + using PointerType = OrientationNavigatorPtr; + + public: + // constructors + OrientationNavigator() = delete; + OrientationNavigator(const Path& path); + OrientationNavigator(const type::AronOrientationPtr&, const Path& path); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; + + type::AronOrientationPtr toAronOrientationPtr() const; + + // static methods + static OrientationNavigatorPtr DynamicCast(const NavigatorPtr& n); + static OrientationNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + public: + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"float", {}} + }; + const std::vector<std::vector<int>> ACCEPTED_DIMENSIONS = + {{1, 4}}; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + const unsigned int ACCEPTED_DIMENSION_MAX_SIZE = 2; + + private: + // members + type::AronOrientationPtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24baa8cf4d4c831a0af78323254a671e73459832 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.cpp @@ -0,0 +1,162 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "PCLPointCloud.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + PCLPointCloudNavigator::PCLPointCloudNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronPCLPointCloudType, path), + Navigator(type::Descriptor::eAronPCLPointCloudType, path), + type(new type::AronPCLPointCloudType({0, 0}, "")) + { + } + + PCLPointCloudNavigator::PCLPointCloudNavigator(const type::AronPCLPointCloudTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronPCLPointCloudType, path), + Navigator(type::Descriptor::eAronPCLPointCloudType, path), + type(o) + { + CheckAronPtrForNull("AronPCLPointCloudTypeNavigator", "AronPCLPointCloudTypeNavigator", getPath(), o); + checkDimensions(type->dimensions); + checkTypename(type->typeName); + } + + bool PCLPointCloudNavigator::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE || d.size() > ACCEPTED_DIMENSION_MAX_SIZE) + { + throw exception::AronException("AronPCLPointCloudTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + return true; + } + + bool PCLPointCloudNavigator::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronPCLPointCloudTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronPCLPointCloudTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronPCLPointCloudTypePtr PCLPointCloudNavigator::toAronPCLPointCloudTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::vector<int> PCLPointCloudNavigator::getDimensions() const + { + return type->dimensions; + } + + void PCLPointCloudNavigator::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + unsigned int PCLPointCloudNavigator::getWidth() const + { + return type->dimensions[0]; + } + + unsigned int PCLPointCloudNavigator::getHeight() const + { + return type->dimensions[1]; + } + + std::string PCLPointCloudNavigator::getTypename() const + { + return type->typeName; + } + + void PCLPointCloudNavigator::setWidth(const unsigned int& w) + { + if (w == 0) + { + throw exception::AronException("AronPCLPointCloudTypeNavigator", "setWidth", "The width of aa pointcloud cannot be 0", getPath()); + } + type->dimensions[0] = w; + } + + void PCLPointCloudNavigator::setHeight(const unsigned int& h) + { + if (h == 0) + { + throw exception::AronException("AronPCLPointCloudTypeNavigator", "setHeight", "The height of aa pointcloud cannot be 0", getPath()); + } + type->dimensions[1] = h; + } + + void PCLPointCloudNavigator::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + + // static methods + PCLPointCloudNavigatorPtr PCLPointCloudNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<PCLPointCloudNavigator>(n); + } + + PCLPointCloudNavigatorPtr PCLPointCloudNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronPCLPointCloudTypeNavigator", "DynamicCast[Before]", n); + PCLPointCloudNavigatorPtr casted = PCLPointCloudNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronPCLPointCloudTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr PCLPointCloudNavigator::getResult() const + { + return toAronPCLPointCloudTypePtr(); + } + + std::string PCLPointCloudNavigator::getName() const + { + return "AronPCLPointCloudType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.h new file mode 100644 index 0000000000000000000000000000000000000000..26c687c57603f7da7464ac8ee0d2e36ed8b9528f --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/PCLPointCloud.h @@ -0,0 +1,89 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class PCLPointCloudNavigator; + typedef std::shared_ptr<PCLPointCloudNavigator> PCLPointCloudNavigatorPtr; + + class PCLPointCloudNavigator : + virtual public Navigator + { + public: + using PointerType = PCLPointCloudNavigatorPtr; + + public: + // constructors + PCLPointCloudNavigator() = delete; + PCLPointCloudNavigator(const Path& path); + PCLPointCloudNavigator(const type::AronPCLPointCloudPtr&, const Path& path); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; + + unsigned int getWidth() const; + unsigned int getHeight() const; + std::string getTypename() const; + + void setWidth(const unsigned int&); + void setHeight(const unsigned int&); + void setTypename(const std::string&); + + type::AronPCLPointCloudPtr toAronPCLPointCloudPtr() const; + + // static methods + static PCLPointCloudNavigatorPtr DynamicCast(const NavigatorPtr& n); + static PCLPointCloudNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); + + // virtual implementations + virtual type::AronTypePtr getResult() const override; + virtual std::string getName() const override; + + public: + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"PointXYZ", {"pcl::PointXYZ"}}, + {"PointXYZI", {"pcl::PointXYZI"}}, + {"PointXYZL", {"pcl::PointXYZL"}}, + {"PointXYZRGB", {"pcl::PointXYZRGB"}}, + {"PointXYZRGBL", {"pcl::PointXYZRGBL"}}, + {"PointXYZRGBA", {"pcl::PointXYZRGBA"}}, + {"PointXYZHSV", {"pcl::PointXYZHSV"}} + }; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + const unsigned int ACCEPTED_DIMENSION_MAX_SIZE = 2; + + private: + // members + type::AronPCLPointCloudPtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Pose.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Pose.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2aa46e40a7a9354798fc96f093ec33dacbe36eba --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Pose.cpp @@ -0,0 +1,139 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "Pose.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + PoseNavigator::PoseNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronPoseType, path), + Navigator(type::Descriptor::eAronPoseType, path), + type(new type::AronPoseType({4, 4}, "float")) + { + } + + PoseNavigator::PoseNavigator(const type::AronPoseTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronPoseType, path), + Navigator(type::Descriptor::eAronPoseType, path), + type(o) + { + CheckAronPtrForNull("AronPoseTypeNavigator", "AronPoseTypeNavigator", getPath(), o); + } + + bool PoseNavigator::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE || d.size() > ACCEPTED_DIMENSION_MAX_SIZE) + { + throw exception::AronException("AronPoseTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + + if (!std::any_of(ACCEPTED_DIMENSIONS.begin(), ACCEPTED_DIMENSIONS.end(), [d](const auto & el) + { + return d == el; + })) + { + throw exception::AronException("AronPoseTypeNavigator", "checkDimensions", "The dimension is wrong. Got " + simox::alg::to_string(d, ", "), getPath()); + } + return true; + } + + bool PoseNavigator::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronPoseTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronPoseTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronPoseTypePtr PoseNavigator::toAronPoseTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::vector<int> PoseNavigator::getDimensions() const + { + return type->dimensions; + } + + void PoseNavigator::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + std::string PoseNavigator::getTypename() const + { + return type->typeName; + } + + void PoseNavigator::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + // static methods + PoseNavigatorPtr PoseNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<PoseNavigator>(n); + } + + PoseNavigatorPtr PoseNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronPoseTypeNavigator", "DynamicCast[Before]", n); + PoseNavigatorPtr casted = PoseNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronPoseTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr PoseNavigator::getResult() const + { + return toAronPoseTypePtr(); + } + + std::string PoseNavigator::getName() const + { + return "AronPoseType"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Pose.h similarity index 50% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Pose.h index 5aca82d138a4fb445b4cfb1595824dba5aea7d8b..e7211f44b1dbeb4b939b44b134c1cf93c5a4d35a 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Pose.h @@ -28,53 +28,49 @@ #include <map> // Base Class -#include "AronTypeNavigator.h" +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> -namespace armarx +namespace armarx::aron::typenavigator { - namespace aron - { - namespace typenavigator - { + class PoseNavigator; + typedef std::shared_ptr<PoseNavigator> PoseNavigatorPtr; - class AronOpenCVMatTypeNavigator; - typedef std::shared_ptr<AronOpenCVMatTypeNavigator> AronOpenCVMatTypeNavigatorPtr; - - class AronOpenCVMatTypeNavigator : - virtual public AronNDArraySerializerTypeNavigator + class PoseNavigator : + virtual public Navigator { public: - using PointerType = AronOpenCVMatTypeNavigatorPtr; + using PointerType = PoseNavigatorPtr; public: // constructors - AronOpenCVMatTypeNavigator() = delete; - AronOpenCVMatTypeNavigator(const AronPath& path); - AronOpenCVMatTypeNavigator(const type::AronOpenCVMatTypePtr&, const AronPath& path); + PoseNavigator(const Path& path = Path()); + PoseNavigator(const type::AronPosePtr&, const Path& path = Path()); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; - type::AronOpenCVMatTypePtr toAronOpenCVMatTypePtr() const; + type::AronPosePtr toAronPosePtr() const; // static methods - static AronOpenCVMatTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronOpenCVMatTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); + static PoseNavigatorPtr DynamicCast(const NavigatorPtr& n); + static PoseNavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); // virtual implementations - virtual void setDimensions(const std::vector<int>&) override; - virtual void setUsedType(const std::string&) override; - - virtual std::vector<int> getDimensions() const override; - virtual std::string getUsedType() const override; - virtual type::AronTypePtr getResult() const override; virtual std::string getName() const override; public: - static const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES; + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"float", {}} + }; + const std::vector<std::vector<int>> ACCEPTED_DIMENSIONS = + {{4, 4}}; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + const unsigned int ACCEPTED_DIMENSION_MAX_SIZE = 2; private: // members - type::AronOpenCVMatTypePtr type; + type::AronPosePtr type; }; - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Position.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Position.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fe5138a09005d14c00189e8cbd1f5b5a03734b05 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Position.cpp @@ -0,0 +1,142 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +// Header +#include "Position.h" + +namespace armarx +{ + namespace aron + { + namespace typenavigator + { + // constructors + PositionNavigator::PositionNavigator(const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronPositionType, path), + Navigator(type::Descriptor::eAronPositionType, path), + type(new type::AronPositionType({3, 1}, "float")) + { + } + + PositionNavigator::PositionNavigator(const type::AronPositionTypePtr& o, const Path& path) : + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAronPositionType, path), + Navigator(type::Descriptor::eAronPositionType, path), + type(o) + { + CheckAronPtrForNull("AronPositionTypeNavigator", "AronPositionTypeNavigator", getPath(), o); + checkDimensions(o->dimensions); + checkTypename(o->typeName); + } + + bool PositionNavigator::checkDimensions(const std::vector<int>& d) const + { + if (d.size() < ACCEPTED_DIMENSION_MIN_SIZE || d.size() > ACCEPTED_DIMENSION_MAX_SIZE) + { + throw exception::AronException("AronPositionTypeNavigator", "checkDimensions", "The dimension size is wrong. Got size: " + std::to_string(d.size()), getPath()); + } + + if (!std::any_of(ACCEPTED_DIMENSIONS.begin(), ACCEPTED_DIMENSIONS.end(), [d](const auto & el) + { + return d == el; + })) + { + throw exception::AronException("AronPoseTypeNavigator", "checkDimensions", "The dimension is wrong. Got " + simox::alg::to_string(d, ", "), getPath()); + } + return true; + } + + bool PositionNavigator::checkTypename(const std::string& s) const + { + if (s.empty()) + { + throw exception::AronException("AronPositionTypeNavigator", "checkTypename", "The typename is empty.", getPath()); + } + + if (!std::any_of(ACCEPTED_TYPES.begin(), ACCEPTED_TYPES.end(), [s](const auto & el) + { + return s == el.first || std::find(el.second.begin(), el.second.end(), s) != el.second.end(); + })) + { + throw exception::AronException("AronPositionTypeNavigator", "checkTypename", "The typename is wrong. Got " + s, getPath()); + } + return true; + } + + type::AronPositionTypePtr PositionNavigator::toAronPositionTypePtr() const + { + checkDimensions(type->dimensions); + checkTypename(type->typeName); + return type; + } + + std::vector<int> PositionNavigator::getDimensions() const + { + return type->dimensions; + } + + void PositionNavigator::setDimensions(const std::vector<int>& d) + { + checkDimensions(d); + type->dimensions = d; + } + + std::string PositionNavigator::getTypename() const + { + return type->typeName; + } + + void PositionNavigator::setTypename(const std::string& u) + { + checkTypename(u); + type->typeName = u; + } + + + // static methods + PositionNavigatorPtr PositionNavigator::DynamicCast(const NavigatorPtr& n) + { + return std::dynamic_pointer_cast<PositionNavigator>(n); + } + + PositionNavigatorPtr PositionNavigator::DynamicCastAndCheck(const NavigatorPtr& n) + { + CheckTypeNavigatorPtrForNull("AronPositionTypeNavigator", "DynamicCast[Before]", n); + PositionNavigatorPtr casted = PositionNavigator::DynamicCast(n); + CheckTypeNavigatorPtrForNull("AronPositionTypeNavigator", "DynamicCast[After]", n->getPath(), casted); + return casted; + } + + // virtual implementations + type::AronTypePtr PositionNavigator::getResult() const + { + return toAronPositionTypePtr(); + } + + std::string PositionNavigator::getName() const + { + return "AronPositionType"; + } + } + } +} + diff --git a/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Position.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Position.h new file mode 100644 index 0000000000000000000000000000000000000000..c3698449178ef371247aa025911f451a90922d61 --- /dev/null +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/ndarray/Position.h @@ -0,0 +1,76 @@ +/* + * 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/>. + * + * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +// STD/STL +#include <string> +#include <map> + +// Base Class +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> + +namespace armarx::aron::typenavigator +{ + class PositionNavigator; + typedef std::shared_ptr<PositionNavigator> PositionNavigatorPtr; + + class PositionNavigator : + virtual public Navigator + { + public: + using PointerType = PositionNavigatorPtr; + + public: + // constructors + PositionNavigator(const Path& path = Path()); + PositionNavigator(const type::AronPositionPtr&, const Path& path = Path()); + + bool checkDimensions(const std::vector<int>&) const; + bool checkTypename(const std::string&) const; + + type::AronPositionPtr toAronPositionPtr() const; + + // static methods + static PositionNavigatorPtr DynamicCast(const NavigatorPtr&); + static PositionNavigatorPtr DynamicCastAndCheck(const NavigatorPtr&); + + // virtual implementations + type::AronTypePtr getResult() const override; + std::string getName() const override; + + public: + const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES = + { + {"float", {}} + }; + const std::vector<std::vector<int>> ACCEPTED_DIMENSIONS = + {{3, 1}}; + const unsigned int ACCEPTED_DIMENSION_MIN_SIZE = 2; + const unsigned int ACCEPTED_DIMENSION_MAX_SIZE = 2; + + private: + // members + type::AronPositionPtr type; + }; +} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.cpp similarity index 81% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.cpp index 559af3fcc77bcaf15a0dab1718d165f597b03198..e02739c6e3e94f3ed2017a5cf397c7677791209b 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.cpp @@ -27,10 +27,10 @@ #include <map> // Header -#include "AronPrimitiveTypeNavigator.h" +#include "Primitive.h" // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> namespace armarx { @@ -40,16 +40,16 @@ namespace armarx { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ /* constructors */ \ - Aron##upperType##TypeNavigator::Aron##upperType##TypeNavigator(const AronPath& path) : \ - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAron##upperType##Type, path), \ - AronTypeNavigator(AronTypeDescriptor::eAron##upperType##Type, path), \ + Aron##upperType##TypeNavigator::Aron##upperType##TypeNavigator(const Path& path) : \ + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAron##upperType##Type, path), \ + AronTypeNavigator(type::Descriptor::eAron##upperType##Type, path), \ type(new type::Aron##upperType##Type()) \ { \ } \ \ - Aron##upperType##TypeNavigator::Aron##upperType##TypeNavigator(const type::Aron##upperType##TypePtr&o, const AronPath& path) : \ - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAron##upperType##Type, path), \ - AronTypeNavigator(AronTypeDescriptor::eAron##upperType##Type, path), \ + Aron##upperType##TypeNavigator::Aron##upperType##TypeNavigator(const type::Aron##upperType##TypePtr&o, const Path& path) : \ + navigator::AronNavigator<type::Descriptor, type::AronType>::AronNavigator(type::Descriptor::eAron##upperType##Type, path), \ + AronTypeNavigator(type::Descriptor::eAron##upperType##Type, path), \ type(o) \ { \ CheckAronPtrForNull("Aron" + std::string(#upperType) + "TypeNavigator", "Aron" + std::string(#upperType) + "TypeNavigator", getPath(), o); \ diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h similarity index 59% rename from source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h index 5b6090ed54db95331a2e3962b073fc71506086f4..90b0d4b0e95eb1fdd3d5fbcc802efe5cd679b785 100644 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h +++ b/source/RobotAPI/libraries/aron/aroncore/navigator/type/primitive/Primitive.h @@ -27,48 +27,42 @@ #include <string> // Base Class -#include "AronTypeNavigator.h" +#include <RobotAPI/libraries/aron/aroncore/navigator/type/Navigator.h> // ArmarX -#include <RobotAPI/libraries/aron/aroncore/AronConcepts.h> +#include <RobotAPI/libraries/aron/aroncore/Concepts.h> -namespace armarx +namespace armarx::aron::typenavigator { - namespace aron - { - namespace typenavigator - { #define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##TypeNavigator; \ - typedef std::shared_ptr<Aron##upperType##TypeNavigator> Aron##upperType##TypeNavigatorPtr; \ + class upperType##Navigator; \ + typedef std::shared_ptr<upperType##Navigator> upperType##NavigatorPtr; \ \ - class Aron##upperType##TypeNavigator : \ - virtual public AronPrimitiveTypeNavigator \ + class upperType##Navigator : \ + virtual public Navigator \ { \ public: \ - using PointerType = Aron##upperType##TypeNavigatorPtr; \ + using PointerType = upperType##NavigatorPtr; \ \ /* constructors */ \ - Aron##upperType##TypeNavigator(const AronPath& = AronPath()); \ - Aron##upperType##TypeNavigator(const type::Aron##upperType##TypePtr&, const AronPath& = AronPath()); \ + upperType##Navigator(const Path& = Path()); \ + upperType##Navigator(const type::Aron##upperType##Ptr&, const Path& = Path()); \ \ - type::Aron##upperType##TypePtr toAron##upperType##TypePtr() const; \ + type::Aron##upperType##Ptr toAron##upperType##Ptr() const; \ \ /* static methods */ \ - static Aron##upperType##TypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr&); \ - static Aron##upperType##TypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); \ + static upperType##NavigatorPtr DynamicCast(const NavigatorPtr&); \ + static upperType##NavigatorPtr DynamicCastAndCheck(const NavigatorPtr& n); \ \ /* virtual implementations */ \ virtual type::AronTypePtr getResult() const override; \ virtual std::string getName() const override; \ \ private: \ - type::Aron##upperType##TypePtr type; \ + type::Aron##upperType##Ptr type; \ }; HANDLE_PRIMITIVE_TYPES #undef RUN_ARON_MACRO - } - } } diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.cpp similarity index 100% rename from source/RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.cpp diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.h b/source/RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.h similarity index 100% rename from source/RobotAPI/libraries/aron/aroncore/navigators/visitors/DataVisitor.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/visitors/DataVisitor.h diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/visitors/TypedDataVisitor.cpp b/source/RobotAPI/libraries/aron/aroncore/navigator/visitors/TypedDataVisitor.cpp similarity index 100% rename from source/RobotAPI/libraries/aron/aroncore/navigators/visitors/TypedDataVisitor.cpp rename to source/RobotAPI/libraries/aron/aroncore/navigator/visitors/TypedDataVisitor.cpp diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/visitors/TypedDataVisitor.h b/source/RobotAPI/libraries/aron/aroncore/navigator/visitors/TypedDataVisitor.h similarity index 100% rename from source/RobotAPI/libraries/aron/aroncore/navigators/visitors/TypedDataVisitor.h rename to source/RobotAPI/libraries/aron/aroncore/navigator/visitors/TypedDataVisitor.h diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h b/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h deleted file mode 100644 index 28ec1e39285ed6a450782b84dedc10311f0c9b27..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigatorFactory.h +++ /dev/null @@ -1,74 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> -#include <unordered_map> - -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/navigators/AronNavigatorFactory.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> - -namespace armarx -{ - namespace aron - { - namespace datanavigator - { - class AronDataNavigatorFactory; - typedef std::shared_ptr<AronDataNavigatorFactory> AronDataNavigatorFactoryPtr; - - class AronDataNavigatorFactory : - virtual public navigator::AronNavigatorFactory<data::AronDataPtr, AronDataNavigatorPtr> - { - public: - AronDataNavigatorFactory() = default; - virtual AronDataNavigatorPtr create(const data::AronDataPtr&, const AronPath&) const override; - virtual AronDataNavigatorPtr createSpecific(const data::AronDataPtr&, const AronPath&) const override; - - private: - static const std::map<AronDataDescriptor, AronDataNavigatorFactoryPtr> FACTORIES; - }; - - // Factories -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##DataNavigatorFactory : \ - virtual public AronDataNavigatorFactory \ - { \ - public: \ - Aron##upperType##DataNavigatorFactory() = default; \ - virtual AronDataNavigatorPtr createSpecific(const data::AronDataPtr&, const AronPath&) const override; \ - }; - - HANDLE_CONTAINER_DATA - HANDLE_COMPLEX_DATA - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h deleted file mode 100644 index c68bd3324423dc366eb89a883eb956c231476a90..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDictDataNavigator.h +++ /dev/null @@ -1,99 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> -#include <map> - -// ArmarX -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.h> - -namespace armarx -{ - namespace aron - { - namespace datanavigator - { - class AronDictDataNavigator; - typedef std::shared_ptr<AronDictDataNavigator> AronDictDataNavigatorPtr; - - class AronDictDataNavigator : - virtual public AronContainerDataNavigator - { - public: - using PointerType = AronDictDataNavigatorPtr; - - public: - // constructors - AronDictDataNavigator(const AronPath& path = AronPath()); - AronDictDataNavigator(const data::AronDictPtr&, const AronPath& path = AronPath()); - AronDictDataNavigator(const data::AronDataDict&, const AronPath& path = AronPath()); - AronDictDataNavigator(const std::map<std::string, AronDataNavigatorPtr>&, const AronPath& path = AronPath()); - - // operators - bool operator==(const AronDictDataNavigator&) const; - virtual bool equalsDataNavigator(const AronDataNavigatorPtr&) const override; - bool equalsDeep(const AronDictDataNavigatorPtr&) const; - - // static methods - static AronDictDataNavigatorPtr DynamicCast(const AronDataNavigatorPtr& n); - static AronDictDataNavigator DynamicCast(AronDataNavigator& n); - static AronDictDataNavigatorPtr DynamicCastAndCheck(const AronDataNavigatorPtr& n); - - static AronDictDataNavigatorPtr FromAronDictPtr(const data::AronDictPtr& aron); - static data::AronDictPtr ToAronDictPtr(const AronDictDataNavigatorPtr& navigator); - - // public member functions - data::AronDictPtr toAronDictPtr() const; - std::vector<std::string> getAllKeys() const; - - void addElement(const std::string& key, const AronDataNavigatorPtr&); - bool hasElement(const std::string&) const; - AronDataNavigatorPtr getElement(const std::string&) const; - std::map<std::string, AronDataNavigatorPtr> getElements() const; - - void clear(); - - // virtual implementations - virtual data::AronDataPtr getResult() const override; - virtual std::string getName() const override; - virtual std::vector<AronDataNavigatorPtr> getChildren() const override; - virtual size_t childrenSize() const override; - - virtual typenavigator::AronTypeNavigatorPtr recalculateType() const override; - virtual bool fullfillsType(const typenavigator::AronTypeNavigatorPtr&) const override; - - virtual AronDataNavigatorPtr navigateAbsolute(const AronPath& path) const override; - - private: - // members - std::map<std::string, AronDataNavigatorPtr> childrenNavigators; - data::AronDictPtr aron; - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.h deleted file mode 100644 index fd7e9c0fb61f26d073a23cfe5b577cfdd4dcf2ae..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronListDataNavigator.h +++ /dev/null @@ -1,96 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> - -// ArmarX -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronDataNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> - -namespace armarx -{ - namespace aron - { - namespace datanavigator - { - class AronListDataNavigator; - typedef std::shared_ptr<AronListDataNavigator> AronListDataNavigatorPtr; - - class AronListDataNavigator : - virtual public AronContainerDataNavigator - { - public: - using PointerType = AronListDataNavigatorPtr; - - public: - // constructors - AronListDataNavigator(const AronPath& path = AronPath()); - AronListDataNavigator(const data::AronListPtr&, const AronPath& path = AronPath()); - AronListDataNavigator(const data::AronDataList&, const AronPath& path = AronPath()); - AronListDataNavigator(const std::vector<AronDataNavigatorPtr>&, const AronPath& path = AronPath()); - - // operators - bool operator==(const AronListDataNavigator&) const; - virtual bool equalsDataNavigator(const AronDataNavigatorPtr&) const override; - bool equalsDeep(const AronListDataNavigatorPtr&) const; - - // static methods - static AronListDataNavigatorPtr DynamicCast(const AronDataNavigatorPtr& n); - static AronListDataNavigator DynamicCast(AronDataNavigator& n); - static AronListDataNavigatorPtr DynamicCastAndCheck(const AronDataNavigatorPtr& n); - - static AronListDataNavigatorPtr FromAronListPtr(const data::AronListPtr& aron); - static data::AronListPtr ToAronListPtr(const AronListDataNavigatorPtr& navigator); - - // public member functions - data::AronListPtr toAronListPtr() const; - - void addElement(const AronDataNavigatorPtr&); - AronDataNavigatorPtr getElement(unsigned int) const; - bool hasElement(unsigned int) const; - std::vector<AronDataNavigatorPtr> getElements() const; - - void clear(); - - // virtual implementations - virtual data::AronDataPtr getResult() const override; - virtual std::string getName() const override; - virtual std::vector<AronDataNavigatorPtr> getChildren() const override; - virtual size_t childrenSize() const override; - - virtual typenavigator::AronTypeNavigatorPtr recalculateType() const override; - virtual bool fullfillsType(const typenavigator::AronTypeNavigatorPtr&) const override; - - virtual AronDataNavigatorPtr navigateAbsolute(const AronPath& path) const override; - - private: - std::vector<AronDataNavigatorPtr> childrenNavigators; - data::AronListPtr aron; - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h deleted file mode 100644 index a84afbd35bff491e9c381d3c77c79ee33f173e21..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h +++ /dev/null @@ -1,41 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <string> -#include <map> - -// ArmarX -#include <RobotAPI/interface/aron.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronDictTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronListTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronObjectTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTupleTypeNavigator.h> -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPrimitiveTypeNavigator.h> diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.cpp deleted file mode 100644 index 4d5923c044eab1d309be1c9a5b8ffd97c5d0af02..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.cpp +++ /dev/null @@ -1,183 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -// Header -#include "AronEigenMatrixTypeNavigator.h" - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - const std::map<std::string, std::vector<std::string>> AronEigenMatrixTypeNavigator::ACCEPTED_TYPES = - { - {"short", {}}, - {"int", {}}, - {"long", {}}, - {"float", {}}, - {"double", {}}, - //{"complex float", {"std::complex<float>"}}, - //{"complex double", {"std::complex<double>"}}, - }; - - // constructors - AronEigenMatrixTypeNavigator::AronEigenMatrixTypeNavigator(const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronEigenMatrixType, path), - AronTypeNavigator(AronTypeDescriptor::eAronEigenMatrixType, path), - type(new type::AronEigenMatrixType({1, 1}, "")) - { - } - - AronEigenMatrixTypeNavigator::AronEigenMatrixTypeNavigator(const type::AronEigenMatrixTypePtr& o, const AronPath& path) : - AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronDictType, path), - AronTypeNavigator(AronTypeDescriptor::eAronEigenMatrixType, path), - type(o) - { - CheckAronPtrForNull("AronEigenMatrixTypeNavigator", "AronEigenMatrixTypeNavigator", getPath(), o); - if (type->dimensions.size() != 2) - { - throw exception::AronSizeNotValidException("AronEigenMatrixTypeNavigator", "AronEigenMatrixTypeNavigator", "The size of the AronPtr is too small", type->dimensions.size(), 2); - } - } - - unsigned int AronEigenMatrixTypeNavigator::getRows() const - { - return type->dimensions[0]; - } - - unsigned int AronEigenMatrixTypeNavigator::getCols() const - { - return type->dimensions[1]; - } - - void AronEigenMatrixTypeNavigator::setRows(const unsigned int& w) - { - if (w == 0) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "setRows", "The rows of cannot be 0", getPath()); - } - type->dimensions[0] = w; - } - - void AronEigenMatrixTypeNavigator::setCols(const unsigned int& h) - { - if (h == 0) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "setCols", "The cols cannot be 0", getPath()); - } - type->dimensions[1] = h; - } - - type::AronEigenMatrixTypePtr AronEigenMatrixTypeNavigator::toAronEigenMatrixTypePtr() const - { - if (type->dimensions.empty()) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "getCastedResult", "The dimension eigen matrix is empty", getPath()); - } - if (std::any_of(type->dimensions.begin(), type->dimensions.end(), [](int i) - { - return i < -1; - })) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "getCastedResult", "The dimension size is wrong. At least one empty is <-1", getPath()); - } - if (type->typeName.empty()) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "getCastedResult", "The useType of eigen matrix is empty.", getPath()); - } - return type; - } - - std::string AronEigenMatrixTypeNavigator::getUsedType() const - { - return type->typeName; - } - - std::vector<int> AronEigenMatrixTypeNavigator::getDimensions() const - { - return type->dimensions; - } - - void AronEigenMatrixTypeNavigator::setUsedType(const std::string& u) - { - if (u.empty()) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "setUsedType", "The useType cannot be empty", getPath()); - } - - for (const auto& [key, vec] : ACCEPTED_TYPES) - { - if (u == key || std::find(vec.begin(), vec.end(), key) != vec.end()) - { - type->typeName = key; - return; - } - } - throw exception::AronStringNotValidException("AronEigenMatrixTypeNavigator", "setUsedType", "The type was not found in the ACCEPTED_TYPES", u); - } - - void AronEigenMatrixTypeNavigator::setDimensions(const std::vector<int>& d) - { - if (d.empty()) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "setDimensions", "The dimensions of an eigen matrix cannot be empty", getPath()); - } - if (std::any_of(d.begin(), d.end(), [](int i) - { - return i < -1; - })) - { - throw exception::AronExceptionWithPathInfo("AronEigenMatrixTypeNavigator", "setDimensions", "The dimension size is wrong. At least one empty is <-1", getPath()); - } - type->dimensions = d; - } - - // static methods - AronEigenMatrixTypeNavigatorPtr AronEigenMatrixTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) - { - return std::dynamic_pointer_cast<AronEigenMatrixTypeNavigator>(n); - } - - AronEigenMatrixTypeNavigatorPtr AronEigenMatrixTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) - { - CheckTypeNavigatorPtrForNull("AronEigenMatrixTypeNavigator", "DynamicCast[Before]", n); - AronEigenMatrixTypeNavigatorPtr casted = AronEigenMatrixTypeNavigator::DynamicCast(n); - CheckTypeNavigatorPtrForNull("AronEigenMatrixTypeNavigator", "DynamicCast[After]", n->getPath(), casted); - return casted; - } - - // virtual implementations - type::AronTypePtr AronEigenMatrixTypeNavigator::getResult() const - { - return toAronEigenMatrixTypePtr(); - } - - std::string AronEigenMatrixTypeNavigator::getName() const - { - return "AronEigenMatrixType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; - } - } - } -} - diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.h deleted file mode 100644 index 2409b97ae583ffcfa5bc0eadc25b07d33c58eb1d..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronEigenMatrixTypeNavigator.h +++ /dev/null @@ -1,86 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <string> -#include <map> - -// Base Class -#include "AronTypeNavigator.h" - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - - class AronEigenMatrixTypeNavigator; - typedef std::shared_ptr<AronEigenMatrixTypeNavigator> AronEigenMatrixTypeNavigatorPtr; - - class AronEigenMatrixTypeNavigator : - virtual public AronNDArraySerializerTypeNavigator - { - public: - using PointerType = AronEigenMatrixTypeNavigatorPtr; - - public: - // constructors - AronEigenMatrixTypeNavigator() = delete; - AronEigenMatrixTypeNavigator(const AronPath& path); - AronEigenMatrixTypeNavigator(const type::AronEigenMatrixTypePtr&, const AronPath& path); - - unsigned int getRows() const; - unsigned int getCols() const; - - void setRows(const unsigned int&); - void setCols(const unsigned int&); - - type::AronEigenMatrixTypePtr toAronEigenMatrixTypePtr() const; - - // static methods - static AronEigenMatrixTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronEigenMatrixTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); - - // virtual implementations - virtual void setDimensions(const std::vector<int>&) override; - virtual void setUsedType(const std::string&) override; - - std::string getUsedType() const; - std::vector<int> getDimensions() const; - - virtual type::AronTypePtr getResult() const override; - virtual std::string getName() const override; - - public: - static const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES; - - private: - // members - type::AronEigenMatrixTypePtr type; - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.cpp deleted file mode 100644 index f513259d79cfb92c9b6a605b674f349d93706932..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.cpp +++ /dev/null @@ -1,173 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -// Header -#include "AronIVTCByteImageTypeNavigator.h" - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - const std::map<std::string, std::vector<std::string>> AronIVTCByteImageTypeNavigator::ACCEPTED_TYPES = - { - {"GrayScale", {"CByteImage::ImageType::eGrayScale"}}, - {"RGB24", {"CByteImage::ImageType::eRGB24"}}, - {"RGB24Split", {"CByteImage::ImageType::eRGB24Split"}} - }; - - // constructors - AronIVTCByteImageTypeNavigator::AronIVTCByteImageTypeNavigator(const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronIVTCByteImageType, path), - AronTypeNavigator(AronTypeDescriptor::eAronIVTCByteImageType, path), - type(new type::AronIVTCByteImageType({0, 0}, "")) - { - } - - AronIVTCByteImageTypeNavigator::AronIVTCByteImageTypeNavigator(const type::AronIVTCByteImageTypePtr& o, const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronIVTCByteImageType, path), - AronTypeNavigator(AronTypeDescriptor::eAronIVTCByteImageType, path), - type(o) - { - CheckAronPtrForNull("AronIVTCByteImageTypeNavigator", "AronIVTCByteImageTypeNavigator", getPath(), o); - if (type->dimensions.size() != 2) - { - throw exception::AronSizeNotValidException("AronIVTCByteImageTypeNavigator", "AronIVTCByteImageTypeNavigator", "The size of the AronPtr is too small", type->dimensions.size(), 2); - } - } - - type::AronIVTCByteImageTypePtr AronIVTCByteImageTypeNavigator::toAronIVTCByteImageTypePtr() const - { - if (type->dimensions.size() != 2) - { - throw exception::AronExceptionWithPathInfo("AronIVTCByteImageTypeNavigator", "getCastedResult", "The dimension size is wrong. Got size: " + std::to_string(type->dimensions.size()), getPath()); - } - if (std::any_of(type->dimensions.begin(), type->dimensions.end(), [](int i) - { - return i <= 0; - })) - { - throw exception::AronExceptionWithPathInfo("AronIVTCByteImageTypeNavigator", "getCastedResult", "The dimension size is wrong. At least one empty is <=0", getPath()); - } - if (type->typeName.empty()) - { - throw exception::AronExceptionWithPathInfo("AronIVTCByteImageTypeNavigator", "getCastedResult", "The useType of image is empty.", getPath()); - } - return type; - } - - std::vector<int> AronIVTCByteImageTypeNavigator::getDimensions() const - { - return type->dimensions; - } - - void AronIVTCByteImageTypeNavigator::setDimensions(const std::vector<int>& d) - { - if (d.size() != 2) - { - throw exception::AronExceptionWithPathInfo("AronIVTCByteImageTypeNavigator", "setDimensions", "Wrong number of elements in dimension array. The size must be equal to 2. The size was: " + std::to_string(d.size()), getPath()); - } - - type->dimensions = d; - } - - unsigned int AronIVTCByteImageTypeNavigator::getWidth() const - { - return type->dimensions[0]; - } - - unsigned int AronIVTCByteImageTypeNavigator::getHeight() const - { - return type->dimensions[1]; - } - - std::string AronIVTCByteImageTypeNavigator::getUsedType() const - { - return type->typeName; - } - - void AronIVTCByteImageTypeNavigator::setWidth(const unsigned int& w) - { - if (w == 0) - { - throw exception::AronExceptionWithPathInfo("AronIVTCByteImageTypeNavigator", "setWidth", "The width of an cannot be 0", getPath()); - } - type->dimensions[0] = w; - } - - void AronIVTCByteImageTypeNavigator::setHeight(const unsigned int& h) - { - if (h == 0) - { - throw exception::AronExceptionWithPathInfo("AronIVTCByteImageTypeNavigator", "setHeight", "The height of an image cannot be 0", getPath()); - } - type->dimensions[1] = h; - } - - void AronIVTCByteImageTypeNavigator::setUsedType(const std::string& u) - { - if (u.empty()) - { - throw exception::AronExceptionWithPathInfo("AronIVTCByteImageTypeNavigator", "setUsedType", "The useType cannot be empty", getPath()); - } - - for (const auto& [key, vec] : ACCEPTED_TYPES) - { - if (u == key || std::find(vec.begin(), vec.end(), key) != vec.end()) - { - type->typeName = key; - return; - } - } - throw exception::AronStringNotValidException("AronIVTCByteImageTypeNavigator", "setUsedType", "The type was not found in the ACCEPTED_TYPES", u); - } - - // static methods - AronIVTCByteImageTypeNavigatorPtr AronIVTCByteImageTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) - { - return std::dynamic_pointer_cast<AronIVTCByteImageTypeNavigator>(n); - } - - AronIVTCByteImageTypeNavigatorPtr AronIVTCByteImageTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) - { - CheckTypeNavigatorPtrForNull("AronIVTCByteImageTypeNavigator", "DynamicCast[Before]", n); - AronIVTCByteImageTypeNavigatorPtr casted = AronIVTCByteImageTypeNavigator::DynamicCast(n); - CheckTypeNavigatorPtrForNull("AronIVTCByteImageTypeNavigator", "DynamicCast[After]", n->getPath(), casted); - return casted; - } - - // virtual implementations - type::AronTypePtr AronIVTCByteImageTypeNavigator::getResult() const - { - return toAronIVTCByteImageTypePtr(); - } - - std::string AronIVTCByteImageTypeNavigator::getName() const - { - return "AronIVTCByteImageType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; - } - } - } -} - diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.h deleted file mode 100644 index b0ebf28bbed62632a41f757348de7687ee9d7abb..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronIVTCByteImageTypeNavigator.h +++ /dev/null @@ -1,86 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <string> -#include <map> - -// Base Class -#include "AronTypeNavigator.h" - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - - class AronIVTCByteImageTypeNavigator; - typedef std::shared_ptr<AronIVTCByteImageTypeNavigator> AronIVTCByteImageTypeNavigatorPtr; - - class AronIVTCByteImageTypeNavigator : - virtual public AronNDArraySerializerTypeNavigator - { - public: - using PointerType = AronIVTCByteImageTypeNavigatorPtr; - - public: - // constructors - AronIVTCByteImageTypeNavigator() = delete; - AronIVTCByteImageTypeNavigator(const AronPath& path); - AronIVTCByteImageTypeNavigator(const type::AronIVTCByteImageTypePtr&, const AronPath& path); - - unsigned int getWidth() const; - unsigned int getHeight() const; - - void setWidth(const unsigned int&); - void setHeight(const unsigned int&); - - type::AronIVTCByteImageTypePtr toAronIVTCByteImageTypePtr() const; - - // static methods - static AronIVTCByteImageTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronIVTCByteImageTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); - - // virtual implementations - virtual void setDimensions(const std::vector<int>&) override; - virtual void setUsedType(const std::string&) override; - - virtual std::vector<int> getDimensions() const override; - virtual std::string getUsedType() const override; - - virtual type::AronTypePtr getResult() const override; - virtual std::string getName() const override; - - public: - static const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES; - - private: - // members - type::AronIVTCByteImageTypePtr type; - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.cpp deleted file mode 100644 index cf58ee6f50b8503515744cd0308fca033f4c14f6..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronOpenCVMatTypeNavigator.cpp +++ /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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -// Header -#include "AronOpenCVMatTypeNavigator.h" - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - const std::map<std::string, std::vector<std::string>> AronOpenCVMatTypeNavigator::ACCEPTED_TYPES = - { - {"CV_8U", {"8U"}}, - {"CV_8S", {"8S"}}, - {"CV_16U", {"16U"}}, - {"CV_16S", {"16S"}}, - {"CV_32S", {"32S"}}, - {"CV_32F", {"32F"}}, - {"CV_64F", {"64F"}}, - }; - - // constructors - AronOpenCVMatTypeNavigator::AronOpenCVMatTypeNavigator(const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronOpenCVMatType, path), - AronTypeNavigator(AronTypeDescriptor::eAronOpenCVMatType, path), - type(new type::AronOpenCVMatType({}, "")) - { - } - - AronOpenCVMatTypeNavigator::AronOpenCVMatTypeNavigator(const type::AronOpenCVMatTypePtr& o, const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronOpenCVMatType, path), - AronTypeNavigator(AronTypeDescriptor::eAronOpenCVMatType, path), - type(o) - { - CheckAronPtrForNull("AronOpenCVMatTypeNavigator", "AronOpenCVMatTypeNavigator", getPath(), o); - } - - type::AronOpenCVMatTypePtr AronOpenCVMatTypeNavigator::toAronOpenCVMatTypePtr() const - { - if (type->dimensions.empty()) - { - throw exception::AronExceptionWithPathInfo("AronOpenCVMatTypeNavigator", "getCastedResult", "The dimension size is empty", getPath()); - } - if (std::any_of(type->dimensions.begin(), type->dimensions.end(), [](int i) - { - return i < -1; - })) - { - throw exception::AronExceptionWithPathInfo("AronOpenCVMatTypeNavigator", "getCastedResult", "The dimension size is wrong. At least one empty is <-1", getPath()); - } - if (type->typeName.empty()) - { - throw exception::AronExceptionWithPathInfo("AronOpenCVMatTypeNavigator", "getCastedResult", "The useType of image is empty.", getPath()); - } - return type; - } - - std::string AronOpenCVMatTypeNavigator::getUsedType() const - { - return type->typeName; - } - - std::vector<int> AronOpenCVMatTypeNavigator::getDimensions() const - { - return type->dimensions; - } - - void AronOpenCVMatTypeNavigator::setUsedType(const std::string& u) - { - if (u.empty()) - { - throw exception::AronExceptionWithPathInfo("AronOpenCVMatTypeNavigator", "setUsedType", "The useType cannot be empty", getPath()); - } - - for (const auto& [key, vec] : ACCEPTED_TYPES) - { - if (u == key || std::find(vec.begin(), vec.end(), key) != vec.end()) - { - type->typeName = key; - return; - } - } - throw exception::AronStringNotValidException("AronOpenCVMatTypeNavigator", "setUsedType", "The type was not found in the ACCEPTED_TYPES", u); - } - - void AronOpenCVMatTypeNavigator::setDimensions(const std::vector<int>& d) - { - if (d.empty()) - { - throw exception::AronExceptionWithPathInfo("AronOpenCVMatTypeNavigator", "setDimensions", "The dimensions of an opencv mat cannot be empty", getPath()); - } - if (std::any_of(d.begin(), d.end(), [](int i) - { - return i < -1; - })) - { - throw exception::AronExceptionWithPathInfo("AronOpenCVMatTypeNavigator", "setDimensions", "The dimension size is wrong. At least one empty is <-1", getPath()); - } - type->dimensions = d; - } - - - // static methods - AronOpenCVMatTypeNavigatorPtr AronOpenCVMatTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) - { - return std::dynamic_pointer_cast<AronOpenCVMatTypeNavigator>(n); - } - - AronOpenCVMatTypeNavigatorPtr AronOpenCVMatTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) - { - CheckTypeNavigatorPtrForNull("AronOpenCVMatTypeNavigator", "DynamicCast[Before]", n); - AronOpenCVMatTypeNavigatorPtr casted = AronOpenCVMatTypeNavigator::DynamicCast(n); - CheckTypeNavigatorPtrForNull("AronOpenCVMatTypeNavigator", "DynamicCast[After]", n->getPath(), casted); - return casted; - } - - // virtual implementations - type::AronTypePtr AronOpenCVMatTypeNavigator::getResult() const - { - return toAronOpenCVMatTypePtr(); - } - - std::string AronOpenCVMatTypeNavigator::getName() const - { - return "AronOpenCVMatType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; - } - } - } -} - diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.cpp b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.cpp deleted file mode 100644 index 2cec3be614a8bf391fd1dd6089a9b742cac6565a..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.cpp +++ /dev/null @@ -1,173 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -// Header -#include "AronPCLPointCloudTypeNavigator.h" - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - const std::map<std::string, std::vector<std::string>> AronPCLPointCloudTypeNavigator::ACCEPTED_TYPES = - { - {"PointXYZ", {"pcl::PointXYZ"}}, - {"PointXYZI", {"pcl::PointXYZI"}}, - {"PointXYZL", {"pcl::PointXYZL"}}, - {"PointXYZRGB", {"pcl::PointXYZRGB"}}, - {"PointXYZRGBL", {"pcl::PointXYZRGBL"}}, - {"PointXYZRGBA", {"pcl::PointXYZRGBA"}}, - {"PointXYZHSV", {"pcl::PointXYZHSV"}}, - }; - - // constructors - AronPCLPointCloudTypeNavigator::AronPCLPointCloudTypeNavigator(const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronPCLPointCloudType, path), - AronTypeNavigator(AronTypeDescriptor::eAronPCLPointCloudType, path), - type(new type::AronPCLPointCloudType({0, 0}, "")) - { - } - - AronPCLPointCloudTypeNavigator::AronPCLPointCloudTypeNavigator(const type::AronPCLPointCloudTypePtr& o, const AronPath& path) : - navigator::AronNavigator<AronTypeDescriptor, type::AronType>::AronNavigator(AronTypeDescriptor::eAronPCLPointCloudType, path), - AronTypeNavigator(AronTypeDescriptor::eAronPCLPointCloudType, path), - type(o) - { - CheckAronPtrForNull("AronPCLPointCloudTypeNavigator", "AronPCLPointCloudTypeNavigator", getPath(), o); - } - - type::AronPCLPointCloudTypePtr AronPCLPointCloudTypeNavigator::toAronPCLPointCloudTypePtr() const - { - if (type->dimensions.size() != 2) - { - throw exception::AronExceptionWithPathInfo("AronPCLPointCloudTypeNavigator", "getCastedResult", "The dimension size is wrong. Got size: " + std::to_string(type->dimensions.size()), getPath()); - } - if (std::any_of(type->dimensions.begin(), type->dimensions.end(), [](int i) - { - return i <= 0; - })) - { - throw exception::AronExceptionWithPathInfo("AronPCLPointCloudTypeNavigator", "getCastedResult", "The dimension size is wrong. At least one empty is <=0", getPath()); - } - if (type->typeName.empty()) - { - throw exception::AronExceptionWithPathInfo("AronPCLPointCloudTypeNavigator", "getCastedResult", "The useType of image is empty.", getPath()); - } - return type; - } - - std::vector<int> AronPCLPointCloudTypeNavigator::getDimensions() const - { - return type->dimensions; - } - - void AronPCLPointCloudTypeNavigator::setDimensions(const std::vector<int>& d) - { - if (d.size() != 2) - { - throw exception::AronExceptionWithPathInfo("AronPCLPointCloudTypeNavigator", "setDimensions", "Wrong number of elements in dimension array. The size must be equal to 2. The size was: " + std::to_string(d.size()), getPath()); - } - type->dimensions = d; - } - - unsigned int AronPCLPointCloudTypeNavigator::getWidth() const - { - return type->dimensions[0]; - } - - unsigned int AronPCLPointCloudTypeNavigator::getHeight() const - { - return type->dimensions[1]; - } - - std::string AronPCLPointCloudTypeNavigator::getUsedType() const - { - return type->typeName; - } - - void AronPCLPointCloudTypeNavigator::setWidth(const unsigned int& w) - { - if (w == 0) - { - throw exception::AronExceptionWithPathInfo("AronPCLPointCloudTypeNavigator", "setWidth", "The width of aa pointcloud cannot be 0", getPath()); - } - type->dimensions[0] = w; - } - - void AronPCLPointCloudTypeNavigator::setHeight(const unsigned int& h) - { - if (h == 0) - { - throw exception::AronExceptionWithPathInfo("AronPCLPointCloudTypeNavigator", "setHeight", "The height of aa pointcloud cannot be 0", getPath()); - } - type->dimensions[1] = h; - } - - void AronPCLPointCloudTypeNavigator::setUsedType(const std::string& u) - { - if (u.empty()) - { - throw exception::AronExceptionWithPathInfo("AronPCLPointCloudTypeNavigator", "setUsedType", "The useType cannot be empty", getPath()); - } - - for (const auto& [key, vec] : ACCEPTED_TYPES) - { - if (u == key || std::find(vec.begin(), vec.end(), key) != vec.end()) - { - type->typeName = key; - return; - } - } - throw exception::AronStringNotValidException("AronPCLPointCloudTypeNavigator", "setUsedType", "The type was not found in the ACCEPTED_TYPES", u); - } - - - // static methods - AronPCLPointCloudTypeNavigatorPtr AronPCLPointCloudTypeNavigator::DynamicCast(const AronTypeNavigatorPtr& n) - { - return std::dynamic_pointer_cast<AronPCLPointCloudTypeNavigator>(n); - } - - AronPCLPointCloudTypeNavigatorPtr AronPCLPointCloudTypeNavigator::DynamicCastAndCheck(const AronTypeNavigatorPtr& n) - { - CheckTypeNavigatorPtrForNull("AronPCLPointCloudTypeNavigator", "DynamicCast[Before]", n); - AronPCLPointCloudTypeNavigatorPtr casted = AronPCLPointCloudTypeNavigator::DynamicCast(n); - CheckTypeNavigatorPtrForNull("AronPCLPointCloudTypeNavigator", "DynamicCast[After]", n->getPath(), casted); - return casted; - } - - // virtual implementations - type::AronTypePtr AronPCLPointCloudTypeNavigator::getResult() const - { - return toAronPCLPointCloudTypePtr(); - } - - std::string AronPCLPointCloudTypeNavigator::getName() const - { - return "AronPCLPointCloudType<" + simox::alg::to_string(type->dimensions, ", ") + ", " + type->typeName + ">"; - } - } - } -} - diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.h b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.h deleted file mode 100644 index 0ed1bb7b19a79df7ac7896623cccb59f8797f426..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronPCLPointCloudTypeNavigator.h +++ /dev/null @@ -1,86 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <string> -#include <map> - -// Base Class -#include "AronTypeNavigator.h" - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - - class AronPCLPointCloudTypeNavigator; - typedef std::shared_ptr<AronPCLPointCloudTypeNavigator> AronPCLPointCloudTypeNavigatorPtr; - - class AronPCLPointCloudTypeNavigator : - virtual public AronNDArraySerializerTypeNavigator - { - public: - using PointerType = AronPCLPointCloudTypeNavigatorPtr; - - public: - // constructors - AronPCLPointCloudTypeNavigator() = delete; - AronPCLPointCloudTypeNavigator(const AronPath& path); - AronPCLPointCloudTypeNavigator(const type::AronPCLPointCloudTypePtr&, const AronPath& path); - - unsigned int getWidth() const; - unsigned int getHeight() const; - - void setWidth(const unsigned int&); - void setHeight(const unsigned int&); - - type::AronPCLPointCloudTypePtr toAronPCLPointCloudTypePtr() const; - - // static methods - static AronPCLPointCloudTypeNavigatorPtr DynamicCast(const AronTypeNavigatorPtr& n); - static AronPCLPointCloudTypeNavigatorPtr DynamicCastAndCheck(const AronTypeNavigatorPtr& n); - - // virtual implementations - virtual void setDimensions(const std::vector<int>&) override; - virtual void setUsedType(const std::string&) override; - - virtual std::vector<int> getDimensions() const override; - virtual std::string getUsedType() const override; - - virtual type::AronTypePtr getResult() const override; - virtual std::string getName() const override; - - public: - static const std::map<std::string, std::vector<std::string>> ACCEPTED_TYPES; - - private: - // members - type::AronPCLPointCloudTypePtr type; - }; - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.h b/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.h deleted file mode 100644 index dfda634e4dd750f00e9cfaed669c16451a099b87..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronTypeNavigatorFactory.h +++ /dev/null @@ -1,74 +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/>. - * - * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -// STD/STL -#include <memory> -#include <unordered_map> - -// BaseClass -#include <RobotAPI/libraries/aron/aroncore/navigators/AronNavigatorFactory.h> - -// ArmarX -#include <RobotAPI/libraries/aron/aroncore/navigators/typenavigator/AronAllTypeNavigators.h> -#include <RobotAPI/libraries/aron/aroncore/AronDescriptor.h> - -namespace armarx -{ - namespace aron - { - namespace typenavigator - { - class AronTypeNavigatorFactory; - typedef std::shared_ptr<AronTypeNavigatorFactory> AronTypeNavigatorFactoryPtr; - - class AronTypeNavigatorFactory : - virtual public navigator::AronNavigatorFactory<type::AronTypePtr, AronTypeNavigatorPtr> - { - public: - AronTypeNavigatorFactory() = default; - virtual AronTypeNavigatorPtr create(const type::AronTypePtr&, const AronPath&) const override; - virtual AronTypeNavigatorPtr createSpecific(const type::AronTypePtr&, const AronPath&) const override; - - private: - static const std::map<AronTypeDescriptor, AronTypeNavigatorFactoryPtr> FACTORIES; - }; - - // Factories -#define RUN_ARON_MACRO(upperType, lowerType, capsType) \ - class Aron##upperType##TypeNavigatorFactory : \ - virtual public AronTypeNavigatorFactory \ - { \ - public: \ - Aron##upperType##TypeNavigatorFactory() = default; \ - virtual AronTypeNavigatorPtr createSpecific(const type::AronTypePtr&, const AronPath&) const override; \ - }; - - HANDLE_CONTAINER_TYPES - HANDLE_COMPLEX_TYPES - HANDLE_PRIMITIVE_TYPES -#undef RUN_ARON_MACRO - } - } -} diff --git a/source/RobotAPI/libraries/aron/aroncore/test/aronDataWithoutCodeGeneration.h b/source/RobotAPI/libraries/aron/aroncore/test/aronDataWithoutCodeGeneration.h index 67fd71120c0946be7d21c4df0229b78ec90eff6f..723513b609eb21eb9b1b476081a41c2bfe6e0595 100644 --- a/source/RobotAPI/libraries/aron/aroncore/test/aronDataWithoutCodeGeneration.h +++ b/source/RobotAPI/libraries/aron/aroncore/test/aronDataWithoutCodeGeneration.h @@ -2,14 +2,14 @@ #include <vector> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/AronDataNavigatorReader.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/AronDataNavigatorReader.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/AronTypeClassWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronTypeIO/classWriters/NavigatorWriter/AronTypeNavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/Writer.h> +#include <RobotAPI/libraries/aron/aroncore/io/typeIO/writer/navigator/NavigatorWriter.h> namespace armarx { @@ -35,7 +35,7 @@ namespace armarx w.writeEndDict(); } - void writeType(armarx::aron::io::AronTypeWriter& w) const + void writeType(armarx::aron::io::Writer& w) const { w.writeStartObjectType(); w.writeObjectName("AronTrivialDataWithoutCodeGeneration"); @@ -74,7 +74,7 @@ namespace armarx armarx::aron::typenavigator::AronObjectTypeNavigatorPtr toInitialAronType() const { - armarx::aron::io::AronTypeNavigatorWriter writer; + armarx::aron::io::NavigatorWriter writer; this->writeType(writer); return armarx::aron::typenavigator::AronObjectTypeNavigator::DynamicCast(writer.getResult()); } @@ -109,7 +109,7 @@ namespace armarx w.writeEndDict(); } - void writeType(armarx::aron::io::AronTypeWriter& w) const + void writeType(armarx::aron::io::Writer& w) const { w.writeStartObjectType(); w.writeObjectName("AronSimpleDataWithoutCodeGeneration"); @@ -159,7 +159,7 @@ namespace armarx armarx::aron::typenavigator::AronObjectTypeNavigatorPtr toInitialAronType() const { - armarx::aron::io::AronTypeNavigatorWriter writer; + armarx::aron::io::NavigatorWriter writer; this->writeType(writer); return armarx::aron::typenavigator::AronObjectTypeNavigator::DynamicCast(writer.getResult()); } @@ -208,7 +208,7 @@ namespace armarx w.writeEndDict(); } - void writeType(armarx::aron::io::AronTypeWriter& w) const + void writeType(armarx::aron::io::Writer& w) const { w.writeStartObjectType(); w.writeObjectName("AronNestedDataWithoutCodeGeneration"); @@ -282,7 +282,7 @@ namespace armarx armarx::aron::typenavigator::AronObjectTypeNavigatorPtr toInitialAronType() const { - armarx::aron::io::AronTypeNavigatorWriter writer; + armarx::aron::io::NavigatorWriter writer; this->writeType(writer); return armarx::aron::typenavigator::AronObjectTypeNavigator::DynamicCast(writer.getResult()); } diff --git a/source/RobotAPI/libraries/aron/aroncore/test/aronTest.cpp b/source/RobotAPI/libraries/aron/aroncore/test/aronTest.cpp index 8f9abab8c954c5c9382a3820059cc48fe2e9b1f8..f653cb173fbb0eacee40fa1b379bf45b0578a70a 100644 --- a/source/RobotAPI/libraries/aron/aroncore/test/aronTest.cpp +++ b/source/RobotAPI/libraries/aron/aroncore/test/aronTest.cpp @@ -52,17 +52,17 @@ // ArmarX #include <ArmarXCore/libraries/cppgen/CppMethod.h> #include <ArmarXCore/libraries/cppgen/CppClass.h> -#include <RobotAPI/libraries/aron/aroncore/AronException.h> +#include <RobotAPI/libraries/aron/aroncore/Exception.h> // Aron -#include <RobotAPI/libraries/aron/aroncore/AronDebug.h> +#include <RobotAPI/libraries/aron/aroncore/Debug.h> #include <RobotAPI/libraries/aron/aroncore/AronRandomizer.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NavigatorReader/AronDataNavigatorReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/navigator/AronDataNavigatorReader.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NavigatorWriter/AronDataNavigatorWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/NlohmannJSONWriter/AronDataNlohmannJSONWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classWriters/RapidXMLWriter/AronDataRapidXMLWriter.h> -#include <RobotAPI/libraries/aron/aroncore/io/AronDataIO/classReaders/NlohmannJSONReader/AronDataNlohmannJSONReader.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/navigator/NavigatorWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/writer/rapidXML/AronDataRapidXMLWriter.h> +#include <RobotAPI/libraries/aron/aroncore/io/dataIO/reader/nlohmannJSON/AronDataNlohmannJSONReader.h> // Files without code generation #include "aronDataWithoutCodeGeneration.h" @@ -146,7 +146,7 @@ void runTestWithInstances(T& k1, T& k2) std::string k1_aron_json_str = k1_aron_json.dump(4); armarx::aron::io::AronDataNlohmannJSONWriter direct_json_writer_for_k1; - armarx::aron::io::AronDataWriterVisitor::SetupWriterFromAronDataPtr(direct_json_writer_for_k1, k1_aron); + armarx::aron::io::Visitor::SetupWriterFromAronDataPtr(direct_json_writer_for_k1, k1_aron); nlohmann::json direct_k1_aron_json = direct_json_writer_for_k1.getResult(); std::string direct_k1_aron_json_str = direct_k1_aron_json.dump(4); BOOST_CHECK_EQUAL((k1_aron_json_str == direct_k1_aron_json_str), true); @@ -185,13 +185,13 @@ BOOST_AUTO_TEST_CASE(AronNaturalIKTest) NaturalIKResult k2; runTestWithInstances<NaturalIKResult>(k, k2); - // also test AronPath + // also test Path datanavigator::AronDictDataNavigatorPtr aron = k.toAron(); - AronPath path = aron->getPath(); // should be empty since aron is top level object - AronPath memberReached(path, "reached"); - AronPath memberJointValues(path, "jointValues"); - AronPath indexJointValues0(memberJointValues, "0"); - AronPath indexJointValues1(memberJointValues, "1000"); + Path path = aron->getPath(); // should be empty since aron is top level object + Path memberReached(path, "reached"); + Path memberJointValues(path, "jointValues"); + Path indexJointValues0(memberJointValues, "0"); + Path indexJointValues1(memberJointValues, "1000"); BOOST_CHECK_EQUAL(path.toString(), "\\"); BOOST_CHECK_EQUAL(path.size(), 0); @@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(AronNaturalIKTest) datanavigator::AronFloatDataNavigatorPtr el = datanavigator::AronFloatDataNavigator::DynamicCastAndCheck(aron->navigateAbsolute(indexJointValues1)); } - AronPath diff = indexJointValues1.getWithoutPrefix(indexJointValues0); + Path diff = indexJointValues1.getWithoutPrefix(indexJointValues0); BOOST_CHECK_EQUAL(diff.toString(), "\\->1"); BOOST_CHECK_EQUAL(diff.size(), 1); } diff --git a/source/RobotAPI/libraries/natik/CartesianNaturalPositionControllerProxy.cpp b/source/RobotAPI/libraries/natik/CartesianNaturalPositionControllerProxy.cpp index aa28c50cffd92b857c88bbe339179311e9ae8ff3..e2f92312e8e02a302d4263baaf0e839a3d8aed91 100644 --- a/source/RobotAPI/libraries/natik/CartesianNaturalPositionControllerProxy.cpp +++ b/source/RobotAPI/libraries/natik/CartesianNaturalPositionControllerProxy.cpp @@ -25,7 +25,7 @@ #include <ArmarXCore/core/logging/Logging.h> #include <RobotAPI/libraries/core/CartesianPositionController.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> -//#include <RobotAPI/libraries/aron/aroncore/navigators/AronNavigator.h> +//#include <RobotAPI/libraries/aron/aroncore/navigator/Navigator.h> #include <VirtualRobot/math/Helpers.h> #include <VirtualRobot/MathTools.h>