AURobotServers  4
Public Member Functions | Protected Attributes | List of all members
UResPool Class Reference

#include <urespool.h>

Public Member Functions

bool addResource (UResBase *resource)
 
int getResCnt ()
 
int getResFunc (int ressIndex)
 
UResBasegetResource (int resIndex)
 
UResBasegetResource (const char *resID)
 
bool handleReplay ()
 
void print (const char *preString)
 
void print (const char *preString, char *buff, int buffCnt)
 
UResBaseremoveResourceFunc (int funcIndex)
 
UResBaseremoveResourceIndex (int resIndex)
 
void saveSettings ()
 
void stop (bool andWait)
 
 UResPool ()
 
 ~UResPool ()
 

Protected Attributes

UResBaseres [MAX_RESOURCE_POINTERS]
 
int resCnt
 

Detailed Description

Resource pool for server. It holds the resource pointer, and the resource name and the function responcible for the resource.

Author
Christian Andersen

Constructor & Destructor Documentation

UResPool::UResPool ( )

Constructor

References resCnt.

UResPool::~UResPool ( )

Destructor

Member Function Documentation

bool UResPool::addResource ( UResBase resource)

Add a resource. Returns true if resource is added. Returns false if no more space.

References MAX_RESOURCE_POINTERS, res, and resCnt.

Referenced by UCmdExe::addResource(), and UCmdExe::UCmdExeInit().

int UResPool::getResCnt ( )
inline
int UResPool::getResFunc ( int  ressIndex)

Get owner index of this resource

References UResBase::getResFuncIdx(), res, and resCnt.

Referenced by getResCnt(), and UCmdExe::resourcesUpdate().

UResBase * UResPool::getResource ( int  resIndex)

Get resource with this index. Returns also a pointer to the resource ID string.

References res, and resCnt.

Referenced by UCmdExe::addNewRessources(), UCmdExe::deleteFunction(), UCmdExe::getStaticResource(), UCmdExe::isResourceOwner(), UCmdExe::resourcesUpdate(), and UCmdExe::resourcesUpdated().

UResBase * UResPool::getResource ( const char *  resID)

Get resource based on ID string. Returns resource pointer if found. Returns NULL if not found.

References UResBase::isA(), res, and resCnt.

bool UResPool::handleReplay ( )

Handle any pending replay update and allow other resources to update to the same replay time.

Returns
true if a replay were pending and serviced.

References UReplay::isReplay(), UReplay::replayTimeAdvancePending, UReplay::replayTimeNow, UReplay::replayToTime(), res, and resCnt.

Referenced by getResCnt(), and UCmdExe::run().

void UResPool::print ( const char *  preString)

Print short status

Referenced by getResCnt(), UCmdExe::printRess(), and UCmdExe::sysModuleCmd().

void UResPool::print ( const char *  preString,
char *  buff,
int  buffCnt 
)

Print status to string buffer. Prestring is added at the start and at max 'bufCnt' characters are written.

References UCmdExe::getResClassID(), UResBase::getResID(), UResBase::getResVersion(), UResBase::isA(), UResBase::print(), res, and resCnt.

UResBase * UResPool::removeResourceFunc ( int  funcIndex)

remove a resource by function index. Returns a pointer to the removed resource. One function index may own more than one resource, so call this function until a NULL is returned to remove all owned resources. Returns NULL is no resource with this index exist

References UResBase::getResFuncIdx(), res, and resCnt.

Referenced by UCmdExe::deleteFunction().

UResBase * UResPool::removeResourceIndex ( int  resIndex)

remove a resource by resource index. Returns a pointer to the removed resource. Returns NULL is no resource with index exist

References res, and resCnt.

void UResPool::saveSettings ( )

Tell all resources to save settings as needed

References res, resCnt, and UResBase::saveSettings().

Referenced by getResCnt(), and UCmdExe::unloadAllModules().

void UResPool::stop ( bool  andWait)

Tell all resources to stop all running threads

References res, resCnt, UResBase::stop(), and Wait().

Referenced by getResCnt(), and UCmdExe::unloadAllModules().

Member Data Documentation

UResBase* UResPool::res[MAX_RESOURCE_POINTERS]
protected
int UResPool::resCnt
protected

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