From 47692c636345e4beb86762106f274ce26ffba9ad Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Mon, 8 Jun 2015 11:13:21 +0200
Subject: [PATCH] Add GraphComponent::components

Conflicts:
	include/hpp/manipulation/graph/graph-component.hh
	src/graph/graph-component.cc
---
 .../hpp/manipulation/graph/graph-component.hh  | 13 ++++++++-----
 src/graph/graph-component.cc                   | 18 ++++++++++++------
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/include/hpp/manipulation/graph/graph-component.hh b/include/hpp/manipulation/graph/graph-component.hh
index a725c12..79faab3 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 f4ee613..0bc453c 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,
-- 
GitLab