Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/gz/physics/CompositeData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>
#include <map>
#include <set>
#include <typeindex>

#include <gz/utils/SuppressWarning.hh>

Expand Down Expand Up @@ -963,7 +964,7 @@ namespace gz

// We make this typedef public so that helper functions can use it without
// being friends of the class.
public: using MapOfData = std::map<std::string, DataEntry>;
public: using MapOfData = std::map<std::type_index, DataEntry>;

GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Map from the label of a data object type to its entry
Expand Down
19 changes: 10 additions & 9 deletions include/gz/physics/detail/CompositeData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <memory>
#include <utility>
#include <typeindex>

#include <gz/utils/SuppressWarning.hh>

Expand Down Expand Up @@ -92,7 +93,7 @@ namespace gz
{
bool inserted = false;
const CompositeData::MapOfData::iterator it = _dataMap.insert(
std::make_pair(typeid(Data).name(),
std::make_pair(std::type_index(typeid(Data)),
CompositeData::DataEntry())).first;

if (!it->second.data)
Expand Down Expand Up @@ -121,7 +122,7 @@ namespace gz
Data &CompositeData::Get()
{
const MapOfData::iterator it = this->dataMap.insert(
std::make_pair(typeid(Data).name(), DataEntry())).first;
std::make_pair(std::type_index(typeid(Data)), DataEntry())).first;

if (!it->second.data)
{
Expand Down Expand Up @@ -157,7 +158,7 @@ namespace gz
bool CompositeData::Remove()
{
const MapOfData::iterator it =
this->dataMap.find(typeid(Data).name());
this->dataMap.find(std::type_index(typeid(Data)));

if (this->dataMap.end() == it || !it->second.data)
return true;
Expand All @@ -183,7 +184,7 @@ namespace gz
Data *CompositeData::Query(const QueryMode _mode)
{
const MapOfData::const_iterator it =
this->dataMap.find(typeid(Data).name());
this->dataMap.find(std::type_index(typeid(Data)));

if (this->dataMap.end() == it)
return nullptr;
Expand All @@ -202,7 +203,7 @@ namespace gz
const Data *CompositeData::Query(const QueryMode _mode) const
{
const MapOfData::const_iterator it =
this->dataMap.find(typeid(Data).name());
this->dataMap.find(std::type_index(typeid(Data)));

if (this->dataMap.end() == it)
return nullptr;
Expand Down Expand Up @@ -231,7 +232,7 @@ namespace gz
DataStatus status;

const MapOfData::const_iterator it =
this->dataMap.find(typeid(Data).name());
this->dataMap.find(std::type_index(typeid(Data)));

if (this->dataMap.end() == it)
return status;
Expand All @@ -251,7 +252,7 @@ namespace gz
bool CompositeData::Unquery() const
{
const MapOfData::const_iterator it =
this->dataMap.find(typeid(Data).name());
this->dataMap.find(std::type_index(typeid(Data)));

if (this->dataMap.end() == it)
return false;
Expand All @@ -273,7 +274,7 @@ namespace gz
Data &CompositeData::MakeRequired(Args &&..._args)
{
const MapOfData::iterator it = this->dataMap.insert(
std::make_pair(typeid(Data).name(), DataEntry())).first;
std::make_pair(std::type_index(typeid(Data)), DataEntry())).first;

it->second.required = true;
if (!it->second.data)
Expand All @@ -293,7 +294,7 @@ namespace gz
bool CompositeData::Requires() const
{
const MapOfData::const_iterator it =
this->dataMap.find(typeid(Data).name());
this->dataMap.find(std::type_index(typeid(Data)));

if (this->dataMap.end() == it)
return false;
Expand Down
3 changes: 2 additions & 1 deletion include/gz/physics/detail/SpecifyData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <memory>
#include <utility>
#include <iostream>
#include <typeindex>

#include "gz/physics/SpecifyData.hh"

Expand All @@ -34,7 +35,7 @@ namespace gz
: CompositeData(),
privateExpectData(
this->dataMap.insert(
std::make_pair(typeid(Expected).name(),
std::make_pair(std::type_index(typeid(Expected)),
CompositeData::DataEntry())).first)
{
// Do nothing
Expand Down
5 changes: 3 additions & 2 deletions src/CompositeData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <cassert>
#include <utility>
#include <typeindex>

#include "gz/physics/CompositeData.hh"

Expand Down Expand Up @@ -336,7 +337,7 @@ namespace gz
for (const auto &entry : dataMap)
{
if (entry.second.data)
entries.insert(entries.end(), entry.first);
entries.insert(entries.end(), entry.first.name());
}

return entries;
Expand All @@ -353,7 +354,7 @@ namespace gz
for (const auto &entry : dataMap)
{
if (entry.second.data && !entry.second.queried)
unqueried.insert(unqueried.end(), entry.first);
unqueried.insert(unqueried.end(), entry.first.name());
}

return unqueried;
Expand Down
Loading