diff --git a/include/hpp/manipulation/graph/graph-component.hh b/include/hpp/manipulation/graph/graph-component.hh index a725c1230c5f2f9802e8972cd899f0ba7bec77e2..79faab3a186402846c60f9999f1c845e9dec961f 100644 --- a/include/hpp/manipulation/graph/graph-component.hh +++ b/include/hpp/manipulation/graph/graph-component.hh @@ -41,16 +41,19 @@ namespace hpp { class HPP_MANIPULATION_DLLAPI GraphComponent { public: + /// Get the component by its ID. The validity of the GraphComponent + /// is not checked. + static GraphComponentWkPtr_t get(int id); + + /// The list of elements + static const std::vector < GraphComponentWkPtr_t >& components (); + /// Get the component name. const std::string& name() const; /// Set the component name. void name(const std::string& name) HPP_MANIPULATION_DEPRECATED; - /// Get the component by its ID. The validity of the GraphComponent - /// is not checked. - static GraphComponentWkPtr_t get(std::size_t id); - /// Return the component id. std::size_t id () const; @@ -116,7 +119,7 @@ namespace hpp { private: /// Keep track of the created components in order to retrieve them /// easily. - static std::vector < GraphComponentWkPtr_t > components; + static std::vector < GraphComponentWkPtr_t > components_; /// Name of the component. std::string name_; diff --git a/src/graph/graph-component.cc b/src/graph/graph-component.cc index f4ee6138d966028b51291e64c14e86e866b3017f..0bc453cb6e749c911d9d387748fe1338b3379d90 100644 --- a/src/graph/graph-component.cc +++ b/src/graph/graph-component.cc @@ -25,7 +25,7 @@ namespace hpp { namespace manipulation { namespace graph { - std::vector < GraphComponentWkPtr_t > GraphComponent::components = std::vector < GraphComponentWkPtr_t >(); + std::vector < GraphComponentWkPtr_t > GraphComponent::components_ = std::vector < GraphComponentWkPtr_t >(); const std::string& GraphComponent::name() const { @@ -40,13 +40,19 @@ namespace hpp { GraphComponentWkPtr_t GraphComponent::get(std::size_t id) { # ifdef HPP_DEBUG - if (id < 0 || id >= components.size()) + if (id < 0 || id >= (int)components_.size()) throw std::out_of_range ("ID out of range."); # endif // HPP_DEBUG - return components[id]; + return components_[id]; } - std::size_t GraphComponent::id () const + const std::vector <GraphComponentWkPtr_t>& GraphComponent::components () + { + return components_; + } + + + int GraphComponent::id () const { return id_; } @@ -119,8 +125,8 @@ namespace hpp { void GraphComponent::init (const GraphComponentWkPtr_t& weak) { wkPtr_ = weak; - id_ = components.size(); - components.push_back (wkPtr_); + id_ = components_.size(); + components_.push_back (wkPtr_); } std::ostream& operator<< (std::ostream& os,