gatb.core-API-0.0.0
CollectionAbstract< Item > Class Template Reference

Abstract implementation of the Collection interface. More...

#include <CollectionAbstract.hpp>

Inheritance diagram for CollectionAbstract< Item >:
Inheritance graph

Public Member Functions

 CollectionAbstract (Bag< Item > *bag, Iterable< Item > *iterable)
 
virtual ~CollectionAbstract ()
 
Bag< Item > * bag ()
 
Iterable< Item > * iterable ()
 
dp::Iterator< Item > * iterator ()
 
int64_t getNbItems ()
 
int64_t estimateNbItems ()
 
Item * getItems (Item *&buffer)
 
size_t getItems (Item *&buffer, size_t start, size_t nb)
 
void insert (const Item &item)
 
void insert (const std::vector< Item > &items, size_t length)
 
void insert (const Item *items, size_t length)
 
void flush ()
 
void addProperty (const std::string &key, const std::string value)
 
void addProperty (const std::string &key, const char *format...)
 
std::string getProperty (const std::string &key)
 
- Public Member Functions inherited from Collection< Item >
virtual ~Collection ()
 
virtual void remove ()=0
 
virtual void addProperty (const std::string &key, const char *format,...)=0
 
- Public Member Functions inherited from ISmartPointer
virtual ~ISmartPointer ()
 
virtual void use ()=0
 
virtual void forget ()=0
 
- Public Member Functions inherited from Iterable< Item >
template<typename Functor >
void iterate (Functor f)
 

Detailed Description

template<class Item>
class gatb::core::tools::collections::impl::CollectionAbstract< Item >

Abstract implementation of the Collection interface.

This class implements the Collection interface by delegating the job to an instance of Bag and an instance of Iterable.

All the methods are delegated to one of these two instances.

Constructor & Destructor Documentation

CollectionAbstract ( Bag< Item > *  bag,
Iterable< Item > *  iterable 
)
inline

Constructor.

Parameters
bag: reference on the bag delegate.
iterable: reference on the iterable delegate
virtual ~CollectionAbstract ( )
inlinevirtual

Destructor.

Member Function Documentation

void addProperty ( const std::string &  key,
const std::string  value 
)
inlinevirtual

Add a property to the collection.

Parameters
[in]key: key of the property
[in]value: value of the property.

Implements Collection< Item >.

Reimplemented in CollectionHDF5< Item >, CollectionNode< Item >, and CollectionFile< Item >.

void addProperty ( const std::string &  key,
const char *  format... 
)
inline

Add a property to the collection.

Parameters
[in]key: key of the property
[in]value: value of the property.
Bag<Item>* bag ( )
inlinevirtual

Returns
the bag instance.

Implements Collection< Item >.

int64_t estimateNbItems ( )
inlinevirtual

Return the (approximate) number of items. If a specific implementation doesn't know the value, it should return -1 by convention.

Returns
the number of items if known, -1 otherwise.

Implements Iterable< Item >.

void flush ( )
inlinevirtual

Flush the current content. May be useful for implementation that uses a cache.

Implements Bag< Item >.

Item* getItems ( Item *&  buffer)
inlinevirtual

Return a buffer of items.

Parameters
[out]buffer: the buffer
Returns
the buffer

Reimplemented from Iterable< Item >.

size_t getItems ( Item *&  buffer,
size_t  start,
size_t  nb 
)
inlinevirtual

Return a buffer of items.

Parameters
[out]buffer: the buffer
[in]start: index where to start in the buffer
[in]nb: number of items to be retrieved
Returns
the number of items retrieved

Reimplemented from Iterable< Item >.

int64_t getNbItems ( )
inlinevirtual

Return the number of items. If a specific implementation doesn't know the value, it should return -1 by convention.

Returns
the number of items if known, -1 otherwise.

Implements Iterable< Item >.

std::string getProperty ( const std::string &  key)
inlinevirtual

Retrieve a property for a given key

Parameters
[in]key: key of the property to be retrieved
Returns
the value of the property.

Implements Collection< Item >.

Reimplemented in CollectionHDF5< Item >, CollectionNode< Item >, and CollectionFile< Item >.

void insert ( const Item &  item)
inlinevirtual

Insert an item into the bag.

Parameters
[in]item: the item to be inserted.

Implements Bag< Item >.

void insert ( const std::vector< Item > &  items,
size_t  length 
)
inlinevirtual

Insert items into the bag.

Parameters
[in]items: items to be inserted.
[in]length: the number of items to be inserted. If 0 (default value), all the items of the vector are inserted.

Reimplemented from Bag< Item >.

void insert ( const Item *  items,
size_t  length 
)
inlinevirtual

Insert items into the bag.

Parameters
[in]items: items to be inserted.
[in]length: number of items to be inserted.

Reimplemented from Bag< Item >.

Iterable<Item>* iterable ( )
inlinevirtual

Returns
the iterable instance.

Implements Collection< Item >.

dp::Iterator<Item>* iterator ( )
inlinevirtual

Create an iterator for the given Iterable instance.

Returns
the new iterator.

Implements Iterable< Item >.


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