diff --git a/include/dynamic-graph/pool.h b/include/dynamic-graph/pool.h index a16844eb2c0e906e7765559cb7bd424bdff321c4..885b171c667628ae88da54937eaf92cfe39749c8 100644 --- a/include/dynamic-graph/pool.h +++ b/include/dynamic-graph/pool.h @@ -86,6 +86,11 @@ namespace dynamicgraph */ Entity& getEntity (const std::string& name); + /*! \brief Test if the entity exists. */ + bool existEntity (const std::string& name); + /*! \brief Test if the entity exists. If it does, return a pointer on it. */ + bool existEntity (const std::string& name, Entity*& ptr); + /*! \brief Disallocate an entity. \par[in] entname: The name of the entity, */ diff --git a/src/dgraph/pool.cpp b/src/dgraph/pool.cpp index 28eee63768b7c10c7a0df97e2eb6d411f76b77a0..30054f468dc2f85aa17e0643a0d7027b3776d178 100644 --- a/src/dgraph/pool.cpp +++ b/src/dgraph/pool.cpp @@ -115,6 +115,24 @@ getEntity( const std::string& name ) else return *entPtr->second; } +bool PoolStorage:: +existEntity (const std::string& name) +{ + return entityMap.find( name ) != entityMap.end(); +} +bool PoolStorage:: +existEntity (const std::string& name, Entity*& ptr) +{ + Entities::iterator entPtr = entityMap.find( name ); + if( entPtr == entityMap.end () ) return false; + else + { + ptr = entPtr->second; + return true; + } +} + + void PoolStorage:: clearPlugin( const std::string& name ) {