Helios++
Helios software for LiDAR simulations
StaticGrove< Tree > Class Template Referenceabstract

A StaticGrove is an abstract class which declares methods to handle a set of trees. More...

#include <StaticGrove.h>

Inheritance diagram for StaticGrove< Tree >:

Public Member Functions

virtual bool hasTrees () const =0
 Check whether the StaticGrove has trees (true) or not (false) More...
 
virtual size_t getNumTrees () const =0
 Obtain the number of trees handled by the StaticGrove. More...
 
virtual void addTree (std::shared_ptr< Tree > tree)=0
 Add a tree to be handled by the StaticGrove. More...
 
virtual void removeTree (size_t const index)=0
 Remove a tree from the StaticGrove. More...
 
virtual void removeTrees (size_t const startIndex, size_t const endIndex)=0
 Remove trees inside given interval (start inclusive, end exclusive) More...
 
virtual void removeAll ()=0
 Remove all trees from the StaticGrove. More...
 
void clear ()
 Alias for StaticGrove::removeAll method. More...
 
virtual void replaceTree (size_t const index, std::shared_ptr< Tree > tree)=0
 Replace tree at given index by given tree. More...
 
void setTree (size_t const index, std::shared_ptr< Tree > tree)
 Alias for StaticGrove::replaceTree. More...
 
virtual Tree & getTreeReference (size_t const index) const =0
 Obtain a reference to the tree at given index. More...
 
virtual std::shared_ptr< Tree > getTreeShared (size_t const index) const =0
 Obtain a shared pointer to the tree at given index. More...
 
virtual Tree * getTreePointer (size_t const index) const =0
 Obtain a pointer to the tree at given index. More...
 
std::shared_ptr< Tree > operator[] (size_t const index) const
 Obtain a shared pointer to the tree at given index. More...
 
virtual void toZeroTree ()=0
 Restart the internal state of while loop handling.
 
virtual bool hasNextTree () const =0
 Check whether there are more trees to be iterated through while loop (true) or not (false) More...
 
virtual Tree & nextTreeReference ()=0
 Obtain the reference to next tree and advance internal handling so next call will return next true, if any. More...
 
virtual std::shared_ptr< Tree > nextTreeShared ()=0
 Obtain the shared pointer to next tree and advance internal handling so next call will return next true, if any. More...
 
virtual Tree * nextTreePointer ()=0
 Obtain the pointer to next tree and advance internal handling so next call will return next true, if any. More...
 
virtual GroveTreeWrapper< Tree > begin ()
 Obtain the first element of a for-each loop over trees. More...
 
virtual GroveTreeWrapper< Tree > end ()
 Obtaint the last element of a for-each loop over trees. More...
 

Detailed Description

template<typename Tree>
class StaticGrove< Tree >

A StaticGrove is an abstract class which declares methods to handle a set of trees.

Author
Alberto M. Esmoris Pena
Version
1.0

The StaticGrove::hasTrees and StaticGrove::getNumTrees functions allow to query if the grove has trees and how many.

The StaticGrove::addTree, StaticGrove::removeTree, StaticGrove::removeTrees, StaticGrove::removeAll, StaticGrove::clear, StaticGrove::replaceTree and StaticGrove::setTree functions allow to add and remove trees from the grove.

The StaticGrove::getNumTrees, StaticGrove::getTreeReference, StaticGrove::getTreeShared, StaticGrove::getTreePointer and StaticGrove::operator[] functions provide a friendly way to iterate over trees through a for loop and to retrieve trees based on their indices.

...
std::shared_ptr<Tree> tree;
size_t const m = grove.getNumTrees();
for(size_t i = 0 ; i < m ; ++i){
tree = grove.getTreeShared(i);
tree.doSomething();
}
...

The StaticGrove::hasNextTree, StaticGrove::nextTreeReference, StaticGrove::nextTreeShared and StaticGrove::nextTreePointer functions provide a friendly way to iterate over trees through a while loop.

...
std::shared_ptr<Tree> tree;
grove.toZeroTree(); // Restart while loop state
while(grove.hasNextTree()){
tree = grove.nextTreeShared();
tree.doSomething();
}
...

The StaticGrove::begind and StaticGrove::end methods support for-each loop.

...
std::shared_ptr<Tree> tree;
for(shared_ptr<Tree> tree : grove){
tree.doSomething();
}
...
Template Parameters
TreeThe type of tree to be handled

Member Function Documentation

◆ addTree()

template<typename Tree >
virtual void StaticGrove< Tree >::addTree ( std::shared_ptr< Tree >  tree)
pure virtual

Add a tree to be handled by the StaticGrove.

Parameters
treeTree to be added to the StaticGrove

Implemented in BasicStaticGrove< Tree >.

◆ begin()

template<typename Tree >
virtual GroveTreeWrapper<Tree> StaticGrove< Tree >::begin ( )
inlinevirtual

Obtain the first element of a for-each loop over trees.

Returns
First element of a for-each loop over trees

◆ clear()

template<typename Tree >
void StaticGrove< Tree >::clear ( )
inline

◆ end()

template<typename Tree >
virtual GroveTreeWrapper<Tree> StaticGrove< Tree >::end ( )
inlinevirtual

Obtaint the last element of a for-each loop over trees.

Returns
Last element of a for-each loop over trees

◆ getNumTrees()

template<typename Tree >
virtual size_t StaticGrove< Tree >::getNumTrees ( ) const
pure virtual

Obtain the number of trees handled by the StaticGrove.

Returns
Number of trees handled by the StaticGrove

Implemented in BasicStaticGrove< Tree >.

◆ getTreePointer()

template<typename Tree >
virtual Tree* StaticGrove< Tree >::getTreePointer ( size_t const  index) const
pure virtual

Obtain a pointer to the tree at given index.

Parameters
indexIndex of the tree to be obtained
Returns
Pointer to the tree at given index

Implemented in BasicStaticGrove< Tree >.

◆ getTreeReference()

template<typename Tree >
virtual Tree& StaticGrove< Tree >::getTreeReference ( size_t const  index) const
pure virtual

Obtain a reference to the tree at given index.

Parameters
indexIndex of the tree to be obtained
Returns
Reference to the tree at given index

Implemented in BasicStaticGrove< Tree >.

◆ getTreeShared()

template<typename Tree >
virtual std::shared_ptr<Tree> StaticGrove< Tree >::getTreeShared ( size_t const  index) const
pure virtual

Obtain a shared pointer to the tree at given index.

Parameters
indexIndex of the tree to be obtained
Returns
Shared pointer to the tree at given index

Implemented in BasicStaticGrove< Tree >.

◆ hasNextTree()

template<typename Tree >
virtual bool StaticGrove< Tree >::hasNextTree ( ) const
pure virtual

Check whether there are more trees to be iterated through while loop (true) or not (false)

Returns
True if there are more trees to be iterated through while loop, false otherwise

Implemented in BasicStaticGrove< Tree >.

◆ hasTrees()

template<typename Tree >
virtual bool StaticGrove< Tree >::hasTrees ( ) const
pure virtual

Check whether the StaticGrove has trees (true) or not (false)

Returns
True if the StaticGrove has trees, false otherwise

Implemented in BasicStaticGrove< Tree >.

◆ nextTreePointer()

template<typename Tree >
virtual Tree* StaticGrove< Tree >::nextTreePointer ( )
pure virtual

Obtain the pointer to next tree and advance internal handling so next call will return next true, if any.

Returns
Pointer to next tree

Implemented in BasicStaticGrove< Tree >.

◆ nextTreeReference()

template<typename Tree >
virtual Tree& StaticGrove< Tree >::nextTreeReference ( )
pure virtual

Obtain the reference to next tree and advance internal handling so next call will return next true, if any.

Returns
Reference to next tree

Implemented in BasicStaticGrove< Tree >.

◆ nextTreeShared()

template<typename Tree >
virtual std::shared_ptr<Tree> StaticGrove< Tree >::nextTreeShared ( )
pure virtual

Obtain the shared pointer to next tree and advance internal handling so next call will return next true, if any.

Returns
Shared pointer to next tree

Implemented in BasicStaticGrove< Tree >.

◆ operator[]()

template<typename Tree >
std::shared_ptr<Tree> StaticGrove< Tree >::operator[] ( size_t const  index) const
inline

Obtain a shared pointer to the tree at given index.

Parameters
indexIndex of the tree to be obtained
Returns
Shared pointer to the tree at given index

◆ removeAll()

template<typename Tree >
virtual void StaticGrove< Tree >::removeAll ( )
pure virtual

Remove all trees from the StaticGrove.

See also
StaticGrove::clear

Implemented in BasicStaticGrove< Tree >.

◆ removeTree()

template<typename Tree >
virtual void StaticGrove< Tree >::removeTree ( size_t const  index)
pure virtual

Remove a tree from the StaticGrove.

Parameters
indexIndex of tree to be removed from StaticGrove

Implemented in BasicStaticGrove< Tree >.

◆ removeTrees()

template<typename Tree >
virtual void StaticGrove< Tree >::removeTrees ( size_t const  startIndex,
size_t const  endIndex 
)
pure virtual

Remove trees inside given interval (start inclusive, end exclusive)

Parameters
startIndexStart index (inclusive) of deletion interval
endIndexEnd index (exclusive) of deletion interval

Implemented in BasicStaticGrove< Tree >.

◆ replaceTree()

template<typename Tree >
virtual void StaticGrove< Tree >::replaceTree ( size_t const  index,
std::shared_ptr< Tree >  tree 
)
pure virtual

Replace tree at given index by given tree.

Parameters
indexIndex of tree to be replaced
treeNew tree

Implemented in BasicStaticGrove< Tree >.

◆ setTree()

template<typename Tree >
void StaticGrove< Tree >::setTree ( size_t const  index,
std::shared_ptr< Tree >  tree 
)
inline

The documentation for this class was generated from the following files: