GLStorageSet Class Reference

#include <GLStorageSet.h>

Inheritance diagram for GLStorageSet:

GLBaseOrganismStorage

List of all members.

Public Member Functions

 GLStorageSet ()
virtual ~GLStorageSet ()
virtual bool addOrganism (GLBaseOrganism *organism, GLConstants::TTwinsFlags twins=GLConstants::NO_TWINS)
void emptyStorage ()
virtual const GLBaseOrganismfindOrganism (const GLBaseOrganism *organism, bool soft=true) const
virtual
GLBaseOrganismStorage::iterator
getIterator ()
virtual
GLBaseOrganismStorage::const_iterator
getIteratorConst () const
virtual int getOrganismsVector (vector< GLBaseOrganism * > &container, GLConstants::TStorageFilling fill=GLConstants::APPEND, int size=-1, bool copy_clones=false)
virtual int getOrganismsVector (vector< const GLBaseOrganism * > &container, GLConstants::TStorageFilling fill=GLConstants::APPEND, int size=-1, bool copy_clones=false) const
virtual int getSize () const
virtual void merge (const GLBaseOrganismStorage *storage, GLConstants::TTwinsFlags twins=GLConstants::NO_TWINS)
virtual int trimSize (unsigned int new_size)


Detailed Description

Uses set for storing the organisms. No random access to organisms but provides considerably more convenient way to ensure the uniqueness of organisms in the storage.

Definition at line 12 of file GLStorageSet.h.


Constructor & Destructor Documentation

GLStorageSet::GLStorageSet (  ) 

Simple constructor

Definition at line 6 of file GLStorageSet.cpp.

GLStorageSet::~GLStorageSet (  )  [virtual]

Frees memory allocated to the organisms, depending on the memory policy property.

Definition at line 10 of file GLStorageSet.cpp.


Member Function Documentation

bool GLStorageSet::addOrganism ( GLBaseOrganism organism,
GLConstants::TTwinsFlags  twins = GLConstants::NO_TWINS 
) [virtual]

Adds the new organism to storage. If the 'no duplication' flag is set and organism is already in the storage -- do not add it. Organisms are checked in 'soft' manner.

Parameters:
organism new organism to be added to storage.
twins when set to NO_TWINS, check that this organism is not in the storage already.
Returns:
true if organism was successfully added and false otherwise.

Implements GLBaseOrganismStorage.

Definition at line 23 of file GLStorageSet.cpp.

void GLStorageSet::emptyStorage (  )  [virtual]

Removes all the organisms from the storage and frees memory

Implements GLBaseOrganismStorage.

Definition at line 34 of file GLStorageSet.cpp.

const GLBaseOrganism * GLStorageSet::findOrganism ( const GLBaseOrganism organism,
bool  soft = true 
) const [virtual]

Checks, if the organism is already in storage (compared not pointers, but the content of the organisms).

Parameters:
organism organism to be found.
soft when true comparison is made in the 'soft' sense.
Returns:
pointer on found organism in the storage or NULL if nothing was found.

Reimplemented from GLBaseOrganismStorage.

Definition at line 60 of file GLStorageSet.cpp.

GLBaseOrganismStorage::iterator * GLStorageSet::getIterator (  )  [virtual]

Returns the pointer to iterator at the first element of the storage.

Returns:
pointer to iterator at the first element of the storage.

Implements GLBaseOrganismStorage.

Definition at line 76 of file GLStorageSet.cpp.

GLBaseOrganismStorage::const_iterator * GLStorageSet::getIteratorConst (  )  const [virtual]

Returns the pointer to constant iterator at the first element of the storage.

Returns:
pointer to constant iterator at the first element of the storage.

Implements GLBaseOrganismStorage.

Definition at line 88 of file GLStorageSet.cpp.

int GLStorageSet::getOrganismsVector ( vector< const GLBaseOrganism * > &  container,
GLConstants::TStorageFilling  fill = GLConstants::APPEND,
int  size = -1,
bool  copy_clones = false 
) const [virtual]

Provides the vector of pointers to the organisms in storage starting from the first one.

Parameters:
container vector of pointers to the organisms from storage (output value).
fill when APPEND the new organisms are added to the container, when REPLACE -- the container is cleaned before adding the organisms.
size number of organisms from storage to be returned in vector. if < 0 or > getSize() then returns all the organisms.
copy_clones when true the pointers to the clones of the organisms will be copied, otherwise -- pointers to the original organisms.
Returns:
number of elements transferred to container.

Reimplemented from GLBaseOrganismStorage.

Definition at line 149 of file GLStorageSet.cpp.

int GLStorageSet::getOrganismsVector ( vector< GLBaseOrganism * > &  container,
GLConstants::TStorageFilling  fill = GLConstants::APPEND,
int  size = -1,
bool  copy_clones = false 
) [virtual]

Provides the vector of pointers to the organisms in storage starting from the first one. The base version uses iterator to fill the vector, however, for real implementation of storage which uses stl containers more efficient approach should be possible.

Parameters:
container vector of pointers to the organisms from storage (output value).
fill when APPEND the new organisms are added to the container, when REPLACE -- the container is cleaned before adding the organisms.
size number of organisms from storage to be returned in vector. if < 0 or > getSize() then returns all the organisms.
copy_clones when true the pointers to the clones of the organisms will be copied, otherwise -- pointers to the original organisms.
Returns:
number of elements transferred to container.

Reimplemented from GLBaseOrganismStorage.

Definition at line 111 of file GLStorageSet.cpp.

virtual int GLStorageSet::getSize (  )  const [inline, virtual]

Returns the number of elements in storage.

Returns:
number of elements in storage.

Implements GLBaseOrganismStorage.

Definition at line 118 of file GLStorageSet.h.

void GLStorageSet::merge ( const GLBaseOrganismStorage storage,
GLConstants::TTwinsFlags  twins = GLConstants::NO_TWINS 
) [virtual]

Adds organisms from another storage to the current one.

Parameters:
storage another organism storage.
twins when equal to NO_TWINS, check that this organism is not in the storage already.

Implements GLBaseOrganismStorage.

Definition at line 186 of file GLStorageSet.cpp.

int GLStorageSet::trimSize ( unsigned int  new_size  )  [virtual]

Decreases the size of the storage. If the size of storage was less, than new size, that nothing will be done.

Parameters:
new_size new number of organisms in the storage.
Returns:
the number of organisms in storage after operation.

Implements GLBaseOrganismStorage.

Definition at line 212 of file GLStorageSet.cpp.


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

Generated on Sat Jun 13 13:58:12 2009 for GenLib by  doxygen 1.5.9