From d43c3ba109b8ee9de18600d0849795c04b94c077 Mon Sep 17 00:00:00 2001 From: Rainer Kartmann <rainer.kartmann@kit.edu> Date: Tue, 27 Apr 2021 09:52:17 +0200 Subject: [PATCH] Use non-underscored typenames --- .../armem/core/base/CoreSegmentBase.h | 20 +++++----- .../libraries/armem/core/base/EntityBase.h | 38 +++++++++---------- .../armem/core/base/EntityInstanceBase.h | 4 ++ .../armem/core/base/EntitySnapshotBase.h | 28 +++++++------- .../libraries/armem/core/base/MemoryBase.h | 32 ++++++++-------- .../armem/core/base/ProviderSegmentBase.h | 26 ++++++------- 6 files changed, 75 insertions(+), 73 deletions(-) diff --git a/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h b/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h index 8e99598c1..b80ca2ccd 100644 --- a/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h +++ b/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h @@ -45,13 +45,13 @@ namespace armarx::armem::base using Base::container; - inline const std::map<std::string, _ProviderSegmentT>& providerSegments() const + inline const std::map<std::string, ProviderSegmentT>& providerSegments() const { return container; } - inline std::map<std::string, _ProviderSegmentT>& providerSegments() + inline std::map<std::string, ProviderSegmentT>& providerSegments() { - return const_cast<std::map<std::string, _ProviderSegmentT>&>(const_cast<const CoreSegmentBase*>(this)->providerSegments()); + return const_cast<std::map<std::string, ProviderSegmentT>&>(const_cast<const CoreSegmentBase*>(this)->providerSegments()); } @@ -60,12 +60,12 @@ namespace armarx::armem::base return container.count(name) > 0; } - _ProviderSegmentT& getProviderSegment(const std::string& name) + ProviderSegmentT& getProviderSegment(const std::string& name) { - return const_cast<_ProviderSegmentT&>(const_cast<const CoreSegmentBase*>(this)->getProviderSegment(name)); + return const_cast<ProviderSegmentT&>(const_cast<const CoreSegmentBase*>(this)->getProviderSegment(name)); } - const _ProviderSegmentT& getProviderSegment(const std::string& name) const + const ProviderSegmentT& getProviderSegment(const std::string& name) const { auto it = this->container.find(name); if (it != container.end()) @@ -106,20 +106,20 @@ namespace armarx::armem::base * @param providerSegmentType The provider type. If nullptr, the core segment type is used. * @return The added provider segment. */ - _ProviderSegmentT& addProviderSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr providerSegmentType = nullptr) + ProviderSegmentT& addProviderSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr providerSegmentType = nullptr) { aron::typenavigator::ObjectNavigatorPtr type = providerSegmentType ? providerSegmentType : this->aronType; - return addProviderSegment(_ProviderSegmentT(name, type)); + return addProviderSegment(ProviderSegmentT(name, type)); } /// Copy and insert a provider segment. - _ProviderSegmentT& addProviderSegment(const _ProviderSegmentT& providerSegment) + ProviderSegmentT& addProviderSegment(const ProviderSegmentT& providerSegment) { return addProviderSegment(ProviderSegment(providerSegment)); } /// Move and insert a provider segment. - _ProviderSegmentT& addProviderSegment(_ProviderSegmentT&& providerSegment) + ProviderSegmentT& addProviderSegment(ProviderSegmentT&& providerSegment) { if (hasProviderSegment(providerSegment.name())) { diff --git a/source/RobotAPI/libraries/armem/core/base/EntityBase.h b/source/RobotAPI/libraries/armem/core/base/EntityBase.h index 2f7788696..08e7dc5bc 100644 --- a/source/RobotAPI/libraries/armem/core/base/EntityBase.h +++ b/source/RobotAPI/libraries/armem/core/base/EntityBase.h @@ -85,13 +85,13 @@ namespace armarx::armem::base using Base::container; - inline const std::map<Time, _EntitySnapshotT>& history() const + inline const std::map<Time, EntitySnapshotT>& history() const { return container; } - inline std::map<Time, _EntitySnapshotT>& history() + inline std::map<Time, EntitySnapshotT>& history() { - return const_cast<std::map<Time, _EntitySnapshotT>&>(const_cast<const EntityBase*>(this)->history()); + return const_cast<std::map<Time, EntitySnapshotT>&>(const_cast<const EntityBase*>(this)->history()); } @@ -129,12 +129,12 @@ namespace armarx::armem::base * @throws `armem::error::MissingEntry` If there is no such entry. * @throws `armem::error::MissingData` If the entry has no data. */ - _EntitySnapshotT& getSnapshot(Time time) + EntitySnapshotT& getSnapshot(Time time) { - return const_cast<_EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getSnapshot(time)); + return const_cast<EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getSnapshot(time)); } - const _EntitySnapshotT& getSnapshot(Time time) const + const EntitySnapshotT& getSnapshot(Time time) const { auto it = container.find(time); if (it != container.end()) @@ -147,12 +147,12 @@ namespace armarx::armem::base } } - _EntitySnapshotT& getSnapshot(const MemoryID& id) + EntitySnapshotT& getSnapshot(const MemoryID& id) { - return const_cast<_EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getSnapshot(id)); + return const_cast<EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getSnapshot(id)); } - const _EntitySnapshotT& getSnapshot(const MemoryID& id) const + const EntitySnapshotT& getSnapshot(const MemoryID& id) const { checkEntityName(id.entityName); return getSnapshot(id.timestamp); @@ -164,12 +164,12 @@ namespace armarx::armem::base * @throw `armem::error::EntityHistoryEmpty` If the history is empty. * @throw `armem::error::MissingData` If the latest snapshot has no data. */ - _EntitySnapshotT& getLatestSnapshot() + EntitySnapshotT& getLatestSnapshot() { - return const_cast<_EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getLatestSnapshot()); + return const_cast<EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getLatestSnapshot()); } - const _EntitySnapshotT& getLatestSnapshot() const + const EntitySnapshotT& getLatestSnapshot() const { return getLatestItem().second; } @@ -185,7 +185,7 @@ namespace armarx::armem::base checkEntityName(update.entityID.entityName); id = update.entityID; - _EntitySnapshotT* snapshot; + EntitySnapshotT* snapshot; auto it = container.find(update.timeCreated); if (it == container.end()) @@ -209,21 +209,21 @@ namespace armarx::armem::base * @param snapshot The snapshot. * @return The stored snapshot. */ - _EntitySnapshotT& addSnapshot(const _EntitySnapshotT& snapshot) + EntitySnapshotT& addSnapshot(const EntitySnapshotT& snapshot) { - return addSnapshot(_EntitySnapshotT(snapshot)); + return addSnapshot(EntitySnapshotT(snapshot)); } - _EntitySnapshotT& addSnapshot(_EntitySnapshotT&& snapshot) + EntitySnapshotT& addSnapshot(EntitySnapshotT&& snapshot) { auto it = container.emplace(snapshot.time(), std::move(snapshot)).first; it->second.id.setEntityID(id); return it->second; } - _EntitySnapshotT& addSnapshot(const Time& timestamp) + EntitySnapshotT& addSnapshot(const Time& timestamp) { - return addSnapshot(_EntitySnapshotT(timestamp)); + return addSnapshot(EntitySnapshotT(timestamp)); } @@ -299,7 +299,7 @@ namespace armarx::armem::base * @return The latest snapshot. * @throw `armem::error::EntityHistoryEmpty` If the history is empty. */ - const typename std::map<Time, _EntitySnapshotT>::value_type& getLatestItem() const + const typename std::map<Time, EntitySnapshotT>::value_type& getLatestItem() const { if (container.empty()) { diff --git a/source/RobotAPI/libraries/armem/core/base/EntityInstanceBase.h b/source/RobotAPI/libraries/armem/core/base/EntityInstanceBase.h index 872521f2a..1b82abd41 100644 --- a/source/RobotAPI/libraries/armem/core/base/EntityInstanceBase.h +++ b/source/RobotAPI/libraries/armem/core/base/EntityInstanceBase.h @@ -18,6 +18,7 @@ namespace armarx::armem::base using Base = detail::MemoryItem; public: + EntityInstanceBase& operator=(const EntityInstanceBase& other) { //other._copySelf(*this); @@ -61,11 +62,14 @@ namespace armarx::armem::base return std::to_string(index()); } + protected: + virtual void _copySelf(_Derived& other) const { Base::_copySelf(other); } + }; } diff --git a/source/RobotAPI/libraries/armem/core/base/EntitySnapshotBase.h b/source/RobotAPI/libraries/armem/core/base/EntitySnapshotBase.h index 1f74f36d0..408423b72 100644 --- a/source/RobotAPI/libraries/armem/core/base/EntitySnapshotBase.h +++ b/source/RobotAPI/libraries/armem/core/base/EntitySnapshotBase.h @@ -63,13 +63,13 @@ namespace armarx::armem::base using Base::container; - inline const std::vector<_EntityInstanceT>& instances() const + inline const std::vector<EntityInstanceT>& instances() const { return container; } - inline std::vector<_EntityInstanceT>& instances() + inline std::vector<EntityInstanceT>& instances() { - return const_cast<std::vector<_EntityInstanceT>&>(const_cast<const EntitySnapshotBase*>(this)->instances()); + return const_cast<std::vector<EntityInstanceT>&>(const_cast<const EntitySnapshotBase*>(this)->instances()); } @@ -84,7 +84,7 @@ namespace armarx::armem::base container.clear(); for (int i = 0; i < int(update.instancesData.size()); ++i) { - _EntityInstanceT& data = container.emplace_back(i, id); + EntityInstanceT& data = container.emplace_back(i, id); data.update(update, i); } } @@ -102,12 +102,12 @@ namespace armarx::armem::base * @return The instance. * @throw `armem::error::MissingEntry` If the given index is invalid. */ - _EntityInstanceT& getInstance(int index) + EntityInstanceT& getInstance(int index) { - return const_cast<_EntityInstanceT&>(const_cast<const EntitySnapshotBase*>(this)->getInstance(index)); + return const_cast<EntityInstanceT&>(const_cast<const EntitySnapshotBase*>(this)->getInstance(index)); } - const _EntityInstanceT& getInstance(int index) const + const EntityInstanceT& getInstance(int index) const { if (hasInstance(index)) { @@ -116,7 +116,7 @@ namespace armarx::armem::base } else { - throw armem::error::MissingEntry(_EntityInstanceT().getLevelName(), std::to_string(index), getLevelName(), toDateTimeMilliSeconds(time())); + throw armem::error::MissingEntry(EntityInstanceT().getLevelName(), std::to_string(index), getLevelName(), toDateTimeMilliSeconds(time())); } } @@ -127,12 +127,12 @@ namespace armarx::armem::base * @throw `armem::error::MissingEntry` If the given index is invalid. * @throw `armem::error::InvalidMemoryID` If memory ID does not have an instance index. */ - _EntityInstanceT& getInstance(const MemoryID& id) + EntityInstanceT& getInstance(const MemoryID& id) { - return const_cast<_EntityInstanceT&>(const_cast<const EntitySnapshotBase*>(this)->getInstance(id)); + return const_cast<EntityInstanceT&>(const_cast<const EntitySnapshotBase*>(this)->getInstance(id)); } - const _EntityInstanceT& getInstance(const MemoryID& id) const + const EntityInstanceT& getInstance(const MemoryID& id) const { if (!id.hasInstanceIndex()) { @@ -148,12 +148,12 @@ namespace armarx::armem::base * @return The stored instance. * @throw `armem::error::InvalidArgument` If the given index is invalid. Must be equal to container.size() or -1 (meaning push_back) */ - _EntityInstanceT& addInstance(const _EntityInstanceT& instance) + EntityInstanceT& addInstance(const EntityInstanceT& instance) { - return addInstance(_EntityInstanceT(instance)); + return addInstance(EntityInstanceT(instance)); } - _EntityInstanceT& addInstance(_EntityInstanceT&& instance) + EntityInstanceT& addInstance(EntityInstanceT&& instance) { if (instance.index() > 0 && (size_t) instance.index() < container.size()) { diff --git a/source/RobotAPI/libraries/armem/core/base/MemoryBase.h b/source/RobotAPI/libraries/armem/core/base/MemoryBase.h index bb7d5a8b9..084e2ff9e 100644 --- a/source/RobotAPI/libraries/armem/core/base/MemoryBase.h +++ b/source/RobotAPI/libraries/armem/core/base/MemoryBase.h @@ -43,13 +43,13 @@ namespace armarx::armem::base using Base::container; - inline const std::map<std::string, _CoreSegmentT>& coreSegments() const + inline const std::map<std::string, CoreSegmentT>& coreSegments() const { return container; } - inline std::map<std::string, _CoreSegmentT>& coreSegments() + inline std::map<std::string, CoreSegmentT>& coreSegments() { - return const_cast<std::map<std::string, _CoreSegmentT>&>(const_cast<const MemoryBase*>(this)->coreSegments()); + return const_cast<std::map<std::string, CoreSegmentT>&>(const_cast<const MemoryBase*>(this)->coreSegments()); } @@ -58,12 +58,12 @@ namespace armarx::armem::base return container.count(name) > 0; } - _CoreSegmentT& getCoreSegment(const std::string& name) + CoreSegmentT& getCoreSegment(const std::string& name) { - return const_cast<_CoreSegmentT&>(const_cast<const MemoryBase*>(this)->getCoreSegment(name)); + return const_cast<CoreSegmentT&>(const_cast<const MemoryBase*>(this)->getCoreSegment(name)); } - const _CoreSegmentT& getCoreSegment(const std::string& name) const + const CoreSegmentT& getCoreSegment(const std::string& name) const { auto it = this->container.find(name); if (it != container.end()) @@ -72,7 +72,7 @@ namespace armarx::armem::base } else { - throw armem::error::MissingEntry(_CoreSegmentT().getLevelName(), name, getLevelName(), this->name()); + throw armem::error::MissingEntry(CoreSegmentT().getLevelName(), name, getLevelName(), this->name()); } } @@ -89,17 +89,17 @@ namespace armarx::armem::base * @param coreSegmentType The core segment type (optional). * @return The added core segment. */ - _CoreSegmentT& addCoreSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr coreSegmentType = nullptr) + CoreSegmentT& addCoreSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr coreSegmentType = nullptr) { - return addCoreSegment(_CoreSegmentT(name, coreSegmentType)); + return addCoreSegment(CoreSegmentT(name, coreSegmentType)); } /// Copy and insert a core segment. - _CoreSegmentT& addCoreSegment(const _CoreSegmentT& coreSegment) + CoreSegmentT& addCoreSegment(const CoreSegmentT& coreSegment) { - return addCoreSegment(_CoreSegmentT(coreSegment)); + return addCoreSegment(CoreSegmentT(coreSegment)); } /// Move and insert a core segment. - _CoreSegmentT& addCoreSegment(_CoreSegmentT&& coreSegment) + CoreSegmentT& addCoreSegment(CoreSegmentT&& coreSegment) { if (container.count(coreSegment.name()) > 0) { @@ -116,9 +116,9 @@ namespace armarx::armem::base * @param The core segment names. * @return The core segments. The contained pointers are never null. */ - std::vector<_CoreSegmentT*> addCoreSegments(const std::vector<std::string>& names) + std::vector<CoreSegmentT*> addCoreSegments(const std::vector<std::string>& names) { - std::vector<_CoreSegmentT*> segments; + std::vector<CoreSegmentT*> segments; for (const auto& name : names) { try @@ -144,7 +144,7 @@ namespace armarx::armem::base } else { - throw armem::error::MissingEntry(_CoreSegmentT().getLevelName(), update.entityID.coreSegmentName, getLevelName(), this->name()); + throw armem::error::MissingEntry(CoreSegmentT().getLevelName(), update.entityID.coreSegmentName, getLevelName(), this->name()); } } @@ -179,7 +179,5 @@ namespace armarx::armem::base { return this->name(); } - - public: }; } diff --git a/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h b/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h index 25ed0e585..d3589d552 100644 --- a/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h +++ b/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h @@ -44,13 +44,13 @@ namespace armarx::armem::base using Base::container; - inline const std::map<std::string, _EntityT>& entities() const + inline const std::map<std::string, EntityT>& entities() const { return container; } - inline std::map<std::string, _EntityT>& entities() + inline std::map<std::string, EntityT>& entities() { - return const_cast<std::map<std::string, _EntityT>&>(const_cast<const ProviderSegmentBase*>(this)->entities()); + return const_cast<std::map<std::string, EntityT>&>(const_cast<const ProviderSegmentBase*>(this)->entities()); } @@ -60,18 +60,18 @@ namespace armarx::armem::base } using Base::_checkContainerName; - const _EntityT& getEntity(const MemoryID& id) const override + const EntityT& getEntity(const MemoryID& id) const override { _checkContainerName(id.providerSegmentName, this->getKeyString()); return getEntity(id.entityName); } - _EntityT& getEntity(const std::string& name) + EntityT& getEntity(const std::string& name) { - return const_cast<_EntityT&>(const_cast<const ProviderSegmentBase*>(this)->getEntity(name)); + return const_cast<EntityT&>(const_cast<const ProviderSegmentBase*>(this)->getEntity(name)); } - const _EntityT& getEntity(const std::string& name) const + const EntityT& getEntity(const std::string& name) const { auto it = this->container.find(name); if (it != container.end()) @@ -93,7 +93,7 @@ namespace armarx::armem::base { _checkContainerName(update.entityID.providerSegmentName, this->name()); - _EntityT* entity; + EntityT* entity; auto it = this->container.find(update.entityID.providerSegmentName); if (it == container.end()) { @@ -110,17 +110,17 @@ namespace armarx::armem::base } /// Add an empty entity with the given name. - _EntityT& addEntity(const std::string& name) + EntityT& addEntity(const std::string& name) { - return addEntity(_EntityT(name)); + return addEntity(EntityT(name)); } /// Copy and insert an entity. - _EntityT& addEntity(const _EntityT& entity) + EntityT& addEntity(const EntityT& entity) { - return addEntity(_EntityT(entity)); + return addEntity(EntityT(entity)); } /// Move and insert an entity. - _EntityT& addEntity(_EntityT&& entity) + EntityT& addEntity(EntityT&& entity) { auto it = container.emplace(entity.name(), std::move(entity)).first; it->second.id.setProviderSegmentID(id); -- GitLab