#include <SimObjectPool.h>
Public Member Functions | |
SimObjectPool (int nTypes) | |
virtual | ~SimObjectPool () |
local_objectid_t | addObject (SimObjectFactory const &objFactory, RandomEngine *rng) |
Add a new instance (or random variarion thereof) of the specified object. | |
local_objectid_t | addObject (SimObjectFactory const &objFactory) |
Add a new instance of the specified object. | |
SimObject * | getObject (object_type_t otype, local_objectid_t oid) |
Get a pointer to the specified objects. | |
void | updateObjects (bool dtHasChanged, double dt) |
A call to this function makes sure that all objects contained in the pool are self-consistent. | |
int | numOfTypes () |
Return the number of different object types stored. | |
int | numOfObjects (object_type_t type) |
Returns the number of a specified type of objects. | |
object_type_t | getLastTypeId () |
Return the type ID with the higest value. | |
SimObjectIterator | beginObject (object_type_t type) |
Returns an iterator for looping over all objects of the given type. | |
SimObjectIterator | endObject (object_type_t type) |
End iterator corresponding to beginObject( eid, type ). | |
Protected Types | |
typedef vector< vector < SimObject * > > | eng_type_pool_t |
Protected Member Functions | |
local_objectid_t | addObject (SimObject *o, object_type_t type) |
Protected Attributes | |
eng_type_pool_t | pool |
Classes | |
class | SimObjectIterator |
Iterator for iterating over the advancable objects in the pool. More... |
Definition at line 11 of file SimObjectPool.h.
typedef vector< vector< SimObject* > > SimObjectPool::eng_type_pool_t [protected] |
Definition at line 43 of file SimObjectPool.h.
SimObjectPool::SimObjectPool | ( | int | nTypes | ) |
SimObjectPool::~SimObjectPool | ( | ) | [virtual] |
Destructor. All objects (simulation elements) that are contained in the pool are also deleted from the heap.
Definition at line 76 of file SimObjectPool.cpp.
References pool.
local_objectid_t SimObjectPool::addObject | ( | SimObjectFactory const & | objFactory, | |
RandomEngine * | rng | |||
) | [inline] |
Add a new instance (or random variarion thereof) of the specified object.
Definition at line 130 of file SimObjectPool.h.
References SimObjectFactory::create(), SimObjectFactory::getObjectTypeID(), and SimObject::setAllocator().
Referenced by SingleThreadSimEngine::addObject(), and addObject().
local_objectid_t SimObjectPool::addObject | ( | SimObjectFactory const & | objFactory | ) | [inline] |
Add a new instance of the specified object.
Definition at line 136 of file SimObjectPool.h.
References addObject(), SimObjectFactory::create(), SimObjectFactory::getObjectTypeID(), and SimObject::setAllocator().
SimObject * SimObjectPool::getObject | ( | object_type_t | otype, | |
local_objectid_t | oid | |||
) |
Get a pointer to the specified objects.
Returns a pointer to the object identified by [otype,oid] tuple. The parameters should be in the right range because they are not checked!
Definition at line 61 of file SimObjectPool.cpp.
References pool.
Referenced by SingleThreadSimEngine::addObject(), SingleThreadSimEngine::getObject(), SingleThreadSimEngine::one_way_link(), and SingleThreadSimEngine::two_way_link().
A call to this function makes sure that all objects contained in the pool are self-consistent.
dtHasChanged | Flag which idicates whether the simulation time step has changed |
Definition at line 46 of file SimObjectPool.cpp.
References pool.
Referenced by SingleThreadSimEngine::reset().
int SimObjectPool::numOfTypes | ( | ) | [inline] |
Return the number of different object types stored.
Definition at line 34 of file SimObjectPool.h.
References pool.
Referenced by SingleThreadSimEngine::initialize(), and SingleThreadSimEngine::reset().
int SimObjectPool::numOfObjects | ( | object_type_t | type | ) | [inline] |
Returns the number of a specified type of objects.
Definition at line 142 of file SimObjectPool.h.
References pool.
object_type_t SimObjectPool::getLastTypeId | ( | ) | [inline] |
Return the type ID with the higest value.
Definition at line 150 of file SimObjectPool.h.
References pool.
SimObjectIterator SimObjectPool::beginObject | ( | object_type_t | type | ) | [inline] |
Returns an iterator for looping over all objects of the given type.
type | Integer ID specifying the type of objects |
Definition at line 91 of file SimObjectPool.h.
References pool.
Referenced by SingleThreadSimEngine::advance(), SingleThreadSimEngine::initialize(), and SingleThreadSimEngine::reset().
SimObjectIterator SimObjectPool::endObject | ( | object_type_t | type | ) | [inline] |
End iterator corresponding to beginObject( eid, type ).
Definition at line 102 of file SimObjectPool.h.
References pool.
Referenced by SingleThreadSimEngine::advance(), SingleThreadSimEngine::initialize(), and SingleThreadSimEngine::reset().
local_objectid_t SimObjectPool::addObject | ( | SimObject * | o, | |
object_type_t | type | |||
) | [protected] |
Adds object in the element based on the type it belongs, the object is assigned local_id.
Definition at line 24 of file SimObjectPool.cpp.
References pool.
eng_type_pool_t SimObjectPool::pool [protected] |
Definition at line 120 of file SimObjectPool.h.
Referenced by addObject(), beginObject(), endObject(), getLastTypeId(), getObject(), numOfObjects(), numOfTypes(), SimObjectPool(), updateObjects(), and ~SimObjectPool().