#include <cobjecthelpers.h>
Public Member Functions | |
| IdCollector (Container &cont, const boost::shared_ptr< IProperty > &search) | |
| void | operator() (std::pair< IdType, boost::shared_ptr< IProperty > > entry) |
| Container & | getContainer () |
| void | reset () |
Private Attributes | |
| Container & | container |
| const boost::shared_ptr < IProperty > & | searched |
| const Comparator | comp |
Collector of all Id complying given condition.
Full state class which builds internal container (which may be returned by getContainer method) from entries given to functional operator and which matches according given comparator.
Container is type of storage where elements of IdType are stored. Comparator has to implement functional operator with two IProperty types wrapped by shared_ptr smart pointers. Comparator can throw only NotImplementedException to say that it is unable to compare such properties. PropertyEquals functor is used as default type for Comparator.
Container instance given, as reference, to the constructor is not encapsulated by class and can expose its state by getContainer method. Class is therefore not responsible for deallocation of its instance. Content of the container can be cleared by reset method (each time new collection should be done, it should be called).
| pdfobjects::utils::IdCollector< Container, IdType, Comparator >::IdCollector | ( | Container & | cont, | |
| const boost::shared_ptr< IProperty > & | search | |||
| ) | [inline] |
Constructor with initialization.
| cont | Container where to store ids. | |
| search | Property to be searched. |
| Container& pdfobjects::utils::IdCollector< Container, IdType, Comparator >::getContainer | ( | ) | [inline] |
Returns container.
References pdfobjects::utils::IdCollector< Container, IdType, Comparator >::container.
| void pdfobjects::utils::IdCollector< Container, IdType, Comparator >::operator() | ( | std::pair< IdType, boost::shared_ptr< IProperty > > | entry | ) | [inline] |
Filters ids of properties which equals searched.
| entry | Entry which contains identificator, property pair. |
If entry's property equals according Comparator with searched one, adds id to the container.
Operator can hadle situation when Comparator throws NotImplementedException and ignores such element.
References pdfobjects::utils::IdCollector< Container, IdType, Comparator >::comp, pdfobjects::utils::IdCollector< Container, IdType, Comparator >::container, debug::DBG_DBG, debug::DBG_WARN, pdfobjects::utils::IdCollector< Container, IdType, Comparator >::searched, and utilsPrintDbg.
| void pdfobjects::utils::IdCollector< Container, IdType, Comparator >::reset | ( | ) | [inline] |
Clears container.
References pdfobjects::utils::IdCollector< Container, IdType, Comparator >::container.
const Comparator pdfobjects::utils::IdCollector< Container, IdType, Comparator >::comp [private] |
Container& pdfobjects::utils::IdCollector< Container, IdType, Comparator >::container [private] |
const boost::shared_ptr<IProperty>& pdfobjects::utils::IdCollector< Container, IdType, Comparator >::searched [private] |