idMan Class Reference

#include <idMan.h>

List of all members.

Public Member Functions

 idMan (uint16 begin, uint16 max_end, uint16 startcount=0)
 ~idMan ()
void clearAll ()
uint16 getNewID ()
bool reserveID (uint16 id)
void clearID (uint16 id)
bool isIDUsed (uint16 id)
void save (ODataSource *ods)
bool load (IDataSource *ids, uint32 version)

Private Member Functions

void expand ()

Private Attributes

uint16 begin
uint16 end
uint16 max_end
uint16 startcount
uint16 usedcount
std::vector< uint16ids
uint16 first
uint16 last


Detailed Description

Definition at line 40 of file idMan.h.


Constructor & Destructor Documentation

idMan::idMan ( uint16  begin,
uint16  max_end,
uint16  startcount = 0 
)

Parameters:
begin start of the range of available IDs
max_end end of the range of available IDs
startcount number of IDs to make available initially (0 = all)

Definition at line 25 of file idMan.cpp.

References begin, clearAll(), end, ids, max_end, and startcount.

idMan::~idMan (  ) 

Definition at line 40 of file idMan.cpp.


Member Function Documentation

void idMan::clearAll (  ) 

clear all IDs, reset size to the startcount

Definition at line 45 of file idMan.cpp.

References begin, end, first, ids, last, max_end, startcount, and usedcount.

Referenced by idMan(), ObjectManager::reset(), and Kernel::reset().

void idMan::clearID ( uint16  id  ) 

release an id

Definition at line 163 of file idMan.cpp.

References first, ids, isIDUsed(), last, and usedcount.

Referenced by ObjectManager::clearObjId(), UCMachine::freeList(), UCMachine::freeString(), UCMachine::freeStringList(), load(), Kernel::removeProcess(), and Kernel::runProcesses().

void idMan::expand (  )  [private]

double the amount of available IDs (up to the maximum passed to the constructor)

Definition at line 96 of file idMan.cpp.

References begin, end, first, ids, max_end, and perr.

Referenced by getNewID(), and reserveID().

uint16 idMan::getNewID (  ) 

get a free ID

Returns:
a free ID, or 0 if none are available

Definition at line 62 of file idMan.cpp.

References begin, end, expand(), first, ids, last, max_end, perr, and usedcount.

Referenced by ObjectManager::assignActorObjId(), UCMachine::assignList(), ObjectManager::assignObjId(), Kernel::assignPID(), and UCMachine::assignString().

bool idMan::isIDUsed ( uint16  id  )  [inline]

check if an ID is in use

Definition at line 75 of file idMan.h.

References begin, end, ids, and last.

Referenced by clearID(), ObjectManager::ConCmd_objectInfo(), ObjectManager::loadObject(), and reserveID().

bool idMan::load ( IDataSource ids,
uint32  version 
)

Definition at line 203 of file idMan.cpp.

References begin, clearID(), end, first, ids, last, max_end, IDataSource::read2(), startcount, and usedcount.

Referenced by ObjectManager::load(), Kernel::load(), UCMachine::loadLists(), and UCMachine::loadStrings().

bool idMan::reserveID ( uint16  id  ) 

mark a given ID as used, expanding if necessary. Note: reserveID is O(n), so don't use too often.

Returns:
false if the ID was already used or is out of range

Definition at line 119 of file idMan.cpp.

References begin, end, expand(), first, ids, isIDUsed(), last, max_end, prev, and usedcount.

Referenced by ObjectManager::assignActorObjId(), ObjectManager::assignObjId(), ObjectManager::reserveObjId(), and ObjectManager::reset().

void idMan::save ( ODataSource ods  ) 

Definition at line 188 of file idMan.cpp.

References begin, end, first, ids, max_end, startcount, usedcount, and ODataSource::write2().

Referenced by ObjectManager::save(), Kernel::save(), UCMachine::saveLists(), and UCMachine::saveStrings().


Member Data Documentation

uint16 idMan::begin [private]

start of the available range of IDs

Definition at line 42 of file idMan.h.

Referenced by clearAll(), expand(), getNewID(), idMan(), isIDUsed(), load(), reserveID(), and save().

uint16 idMan::end [private]

current end of the range

Definition at line 43 of file idMan.h.

Referenced by clearAll(), expand(), getNewID(), idMan(), isIDUsed(), load(), reserveID(), and save().

uint16 idMan::first [private]

the first ID in the free list

Definition at line 50 of file idMan.h.

Referenced by clearAll(), clearID(), expand(), getNewID(), load(), reserveID(), and save().

std::vector<uint16> idMan::ids [private]

the 'next' field in a list of free IDs

Definition at line 49 of file idMan.h.

Referenced by clearAll(), clearID(), expand(), getNewID(), idMan(), isIDUsed(), load(), reserveID(), and save().

uint16 idMan::last [private]

the last ID in the last list

Definition at line 51 of file idMan.h.

Referenced by clearAll(), clearID(), getNewID(), isIDUsed(), load(), and reserveID().

uint16 idMan::max_end [private]

end of the available range

Definition at line 44 of file idMan.h.

Referenced by clearAll(), expand(), getNewID(), idMan(), load(), reserveID(), and save().

uint16 idMan::startcount [private]

number of IDs to make available initially

Definition at line 45 of file idMan.h.

Referenced by clearAll(), idMan(), load(), and save().

uint16 idMan::usedcount [private]

number of IDs currently in use

Definition at line 47 of file idMan.h.

Referenced by clearAll(), clearID(), getNewID(), load(), reserveID(), and save().


The documentation for this class was generated from the following files:
Generated on Fri Jul 27 22:29:22 2007 for pentagram by  doxygen 1.4.7