Helios++
Helios software for LiDAR simulations
StaticGrove.h
1 #pragma once
2 
3 #include <GroveTreeWrapper.h>
4 
5 #include <memory>
6 
67 template <typename Tree>
69 public:
70  // *** CONSTRUCTION / DESTRUCTION *** //
71  // ************************************ //
72  virtual ~StaticGrove () = default;
73 
74  // *** QUERY METHODS *** //
75  // *********************** //
80  virtual bool hasTrees() const = 0;
85  virtual size_t getNumTrees() const = 0;
86 
87  // *** MANIPULATION METHODS *** //
88  // ****************************** //
93  virtual void addTree(std::shared_ptr<Tree> tree) = 0;
98  virtual void removeTree(size_t const index) = 0;
105  virtual void removeTrees(
106  size_t const startIndex, size_t const endIndex
107  ) = 0;
112  virtual void removeAll() = 0;
117  inline void clear() {removeAll();}
123  virtual void replaceTree(
124  size_t const index,
125  std::shared_ptr<Tree> tree
126  ) = 0;
131  inline void setTree(size_t const index, std::shared_ptr<Tree> tree)
132  {replaceTree(index, tree);}
133 
134  // *** FOR LOOP METHODS *** //
135  // ************************** //
141  virtual Tree & getTreeReference(size_t const index) const = 0;
147  virtual std::shared_ptr<Tree> getTreeShared(size_t const index) const = 0;
153  virtual Tree * getTreePointer(size_t const index) const = 0;
159  inline std::shared_ptr<Tree> operator[] (size_t const index) const
160  {return getTreeShared(index);}
161 
162  // *** WHILE LOOP METHODS *** //
163  // **************************** //
167  virtual void toZeroTree() = 0;
174  virtual bool hasNextTree() const = 0;
180  virtual Tree & nextTreeReference() = 0;
186  virtual std::shared_ptr<Tree> nextTreeShared() = 0;
192  virtual Tree * nextTreePointer() = 0;
193 
194  // *** FOR-EACH LOOP METHODS *** //
195  // ******************************* //
201  {return GroveTreeWrapper<Tree>(*this, 0);}
207  {return GroveTreeWrapper<Tree>(*this, getNumTrees());}
208 };
Wrapper for trees belonging to a StaticGrove so for-each loop can be used.
Definition: GroveTreeWrapper.h:17
A StaticGrove is an abstract class which declares methods to handle a set of trees.
Definition: StaticGrove.h:68
virtual void removeTrees(size_t const startIndex, size_t const endIndex)=0
Remove trees inside given interval (start inclusive, end exclusive)
virtual Tree * getTreePointer(size_t const index) const =0
Obtain a pointer to the tree at given index.
virtual Tree * nextTreePointer()=0
Obtain the pointer to next tree and advance internal handling so next call will return next true,...
virtual GroveTreeWrapper< Tree > end()
Obtaint the last element of a for-each loop over trees.
Definition: StaticGrove.h:206
virtual void toZeroTree()=0
Restart the internal state of while loop handling.
virtual void removeAll()=0
Remove all trees from the StaticGrove.
virtual std::shared_ptr< Tree > nextTreeShared()=0
Obtain the shared pointer to next tree and advance internal handling so next call will return next tr...
virtual GroveTreeWrapper< Tree > begin()
Obtain the first element of a for-each loop over trees.
Definition: StaticGrove.h:200
void clear()
Alias for StaticGrove::removeAll method.
Definition: StaticGrove.h:117
virtual Tree & getTreeReference(size_t const index) const =0
Obtain a reference to the tree at given index.
virtual bool hasTrees() const =0
Check whether the StaticGrove has trees (true) or not (false)
virtual void addTree(std::shared_ptr< Tree > tree)=0
Add a tree to be handled by the StaticGrove.
virtual Tree & nextTreeReference()=0
Obtain the reference to next tree and advance internal handling so next call will return next true,...
virtual void removeTree(size_t const index)=0
Remove a tree from the StaticGrove.
virtual void replaceTree(size_t const index, std::shared_ptr< Tree > tree)=0
Replace tree at given index by given tree.
virtual size_t getNumTrees() const =0
Obtain the number of trees handled by the StaticGrove.
std::shared_ptr< Tree > operator[](size_t const index) const
Obtain a shared pointer to the tree at given index.
Definition: StaticGrove.h:159
virtual bool hasNextTree() const =0
Check whether there are more trees to be iterated through while loop (true) or not (false)
virtual std::shared_ptr< Tree > getTreeShared(size_t const index) const =0
Obtain a shared pointer to the tree at given index.
void setTree(size_t const index, std::shared_ptr< Tree > tree)
Alias for StaticGrove::replaceTree.
Definition: StaticGrove.h:131