From 319d9a1aa7f823823617ca929590eae1904213ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Hagen?= Date: Mon, 10 Aug 2015 16:57:16 +0200 Subject: [PATCH] Added new method index() --- .../cafPdmCore/cafPdmChildArrayField.h | 1 + .../cafPdmCore/cafPdmChildArrayField.inl | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h index 65e68da143..a9067db6e4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.h @@ -76,6 +76,7 @@ public: size_t count(const DataType* pointer) const; void erase(size_t index); + size_t index(DataType* pointer); // Child objects diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl index 8338594e99..3ad3ef09a6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmChildArrayField.inl @@ -141,6 +141,18 @@ void PdmChildArrayField::erase(size_t index) } } + +//-------------------------------------------------------------------------------------------------- +/// Get the index of the given object pointer +//-------------------------------------------------------------------------------------------------- +template +size_t PdmChildArrayField::index(DataType* pointer) +{ + typename std::vector< PdmPointer >::iterator it = std::find(m_pointers.begin(), m_pointers.end(), pointer); + return it - m_pointers.begin(); +} + + //-------------------------------------------------------------------------------------------------- /// Removes all instances of object pointer from the container without deleting the object. //--------------------------------------------------------------------------------------------------