Helios++
Helios software for LiDAR simulations
|
Basic implementation of a DynGrove which extends BasicStaticGrove to provided dynamic funcionalities. More...
#include <BasicDynGrove.h>
Public Member Functions | |
BasicDynGrove () | |
Default constructor for BasicDynGrove. | |
void | update (Subject &s) override |
virtual void | addSubject (BasicDynGroveSubject< Tree, Subject > *subject, std::shared_ptr< Tree > tree) |
Add a new subject which identifier is automatically and internally computed. More... | |
virtual void | removeSubject (BasicDynGroveSubject< Tree, Subject > *subject) |
Remove subject with given identifier from the grove. More... | |
virtual std::vector< BasicDynGroveSubject< Tree, Subject > * > const & | getSubjects () const |
Obtain a read-only reference to vector of subjects. More... | |
![]() | |
BasicStaticGrove ()=default | |
Default constructor for BasicStaticGrove. | |
bool | hasTrees () const override |
size_t | getNumTrees () const override |
void | addTree (std::shared_ptr< Tree > tree) override |
void | removeTree (size_t const index) override |
void | removeTrees (size_t const startIndex, size_t const endIndex) override |
void | removeAll () override |
void | replaceTree (size_t const index, std::shared_ptr< Tree > tree) override |
Replace tree at given index by given tree. More... | |
Tree & | getTreeReference (size_t const index) const override |
std::shared_ptr< Tree > | getTreeShared (size_t const index) const override |
Tree * | getTreePointer (size_t const index) const override |
void | toZeroTree () override |
bool | hasNextTree () const override |
Tree & | nextTreeReference () override |
std::shared_ptr< Tree > | nextTreeShared () override |
Tree * | nextTreePointer () override |
![]() | |
void | clear () |
Alias for StaticGrove::removeAll method. More... | |
void | setTree (size_t const index, std::shared_ptr< Tree > tree) |
Alias for StaticGrove::replaceTree. More... | |
std::shared_ptr< Tree > | operator[] (size_t const index) const |
Obtain a shared pointer to the tree at given index. 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... | |
Protected Attributes | |
std::vector< BasicDynGroveSubject< Tree, Subject > * > | subjects |
Vector with pointers to subjects. More... | |
![]() | |
std::vector< std::shared_ptr< Tree > > | trees |
The trees contained in the grove. | |
size_t | whileIter |
Current iteration for while loop friendly methods. | |
Basic implementation of a DynGrove which extends BasicStaticGrove to provided dynamic funcionalities.
Tree | The type of the tree to be handled |
Subject | The type of the subject that can be observed |
|
virtual |
Add a new subject which identifier is automatically and internally computed.
Notice when adding a subject, its identifier will be updated through the BasicDynGroveSubject::setGroveSubjectId method
subject | Reference to the subject itself |
tree | Tree associated to new subject |
|
inlinevirtual |
Obtain a read-only reference to vector of subjects.
|
virtual |
Remove subject with given identifier from the grove.
Notice when removing a subject, all other subject which identifier needs to be updated will be automatically updated. (Through BasicDynGroveSubject::setGroveSubjectId method)
id | Identifier of the subject to be removed |
|
overridevirtual |
Implements DynGrove< Subject >.
|
protected |
Vector with pointers to subjects.
The typical observer pattern does not require the observer (BasicDynGrove) to be aware of all subjects, just to handle their notifications. Nonetheless, to avoid using a map to know to which sub-observer (Tree) each subjects is associated, this vector is used. In consequence, all subjects are handled by the BasicDynGrove to have their indices corresponding with vector indices. This reduces the computational cost of calculating the key-value for a map always that a subject notifies to the observer (which happens too frequently during simulation).