pdfobjects::utils::IdCollector< Container, IdType, Comparator > Class Template Reference

#include <cobjecthelpers.h>

List of all members.

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

Detailed Description

template<typename Container, typename IdType, typename Comparator = PropertyEquals>
class pdfobjects::utils::IdCollector< Container, IdType, Comparator >

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).


Constructor & Destructor Documentation

template<typename Container , typename IdType , typename Comparator = PropertyEquals>
pdfobjects::utils::IdCollector< Container, IdType, Comparator >::IdCollector ( Container &  cont,
const boost::shared_ptr< IProperty > &  search 
) [inline]

Constructor with initialization.

Parameters:
cont Container where to store ids.
search Property to be searched.

Member Function Documentation

template<typename Container , typename IdType , typename Comparator = PropertyEquals>
Container& pdfobjects::utils::IdCollector< Container, IdType, Comparator >::getContainer (  )  [inline]

Returns container.

Returns:
Reference to container.

References pdfobjects::utils::IdCollector< Container, IdType, Comparator >::container.

template<typename Container , typename IdType , typename Comparator = PropertyEquals>
void pdfobjects::utils::IdCollector< Container, IdType, Comparator >::operator() ( std::pair< IdType, boost::shared_ptr< IProperty > >  entry  )  [inline]

Filters ids of properties which equals searched.

Parameters:
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.

template<typename Container , typename IdType , typename Comparator = PropertyEquals>
void pdfobjects::utils::IdCollector< Container, IdType, Comparator >::reset (  )  [inline]

Member Data Documentation

template<typename Container , typename IdType , typename Comparator = PropertyEquals>
const Comparator pdfobjects::utils::IdCollector< Container, IdType, Comparator >::comp [private]
template<typename Container , typename IdType , typename Comparator = PropertyEquals>
Container& pdfobjects::utils::IdCollector< Container, IdType, Comparator >::container [private]
template<typename Container , typename IdType , typename Comparator = PropertyEquals>
const boost::shared_ptr<IProperty>& pdfobjects::utils::IdCollector< Container, IdType, Comparator >::searched [private]

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