Skip to content
Snippets Groups Projects
Commit 47692c63 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Florent Lamiraux
Browse files

Add GraphComponent::components

Conflicts:
	include/hpp/manipulation/graph/graph-component.hh
	src/graph/graph-component.cc
parent b9d620e4
No related branches found
No related tags found
No related merge requests found
...@@ -41,16 +41,19 @@ namespace hpp { ...@@ -41,16 +41,19 @@ namespace hpp {
class HPP_MANIPULATION_DLLAPI GraphComponent class HPP_MANIPULATION_DLLAPI GraphComponent
{ {
public: 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. /// Get the component name.
const std::string& name() const; const std::string& name() const;
/// Set the component name. /// Set the component name.
void name(const std::string& name) HPP_MANIPULATION_DEPRECATED; 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. /// Return the component id.
std::size_t id () const; std::size_t id () const;
...@@ -116,7 +119,7 @@ namespace hpp { ...@@ -116,7 +119,7 @@ namespace hpp {
private: private:
/// Keep track of the created components in order to retrieve them /// Keep track of the created components in order to retrieve them
/// easily. /// easily.
static std::vector < GraphComponentWkPtr_t > components; static std::vector < GraphComponentWkPtr_t > components_;
/// Name of the component. /// Name of the component.
std::string name_; std::string name_;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
namespace hpp { namespace hpp {
namespace manipulation { namespace manipulation {
namespace graph { 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 const std::string& GraphComponent::name() const
{ {
...@@ -40,13 +40,19 @@ namespace hpp { ...@@ -40,13 +40,19 @@ namespace hpp {
GraphComponentWkPtr_t GraphComponent::get(std::size_t id) GraphComponentWkPtr_t GraphComponent::get(std::size_t id)
{ {
# ifdef HPP_DEBUG # 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."); throw std::out_of_range ("ID out of range.");
# endif // HPP_DEBUG # 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_; return id_;
} }
...@@ -119,8 +125,8 @@ namespace hpp { ...@@ -119,8 +125,8 @@ namespace hpp {
void GraphComponent::init (const GraphComponentWkPtr_t& weak) void GraphComponent::init (const GraphComponentWkPtr_t& weak)
{ {
wkPtr_ = weak; wkPtr_ = weak;
id_ = components.size(); id_ = components_.size();
components.push_back (wkPtr_); components_.push_back (wkPtr_);
} }
std::ostream& operator<< (std::ostream& os, std::ostream& operator<< (std::ostream& os,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment