TBag

List of predecestors:
TObj
Files:
collect.h, collect.cpp
Desc. & Idea Warnings Methods Atributes Operators Specials


Description

This class is intended as a member of global kernel info (GKI). It's a tool for storing incomming LKIs. It is in fact a matrix of size (number of processes)x(number of different IDs of LKI). You can store them, retrieve statistics about number of arrived LKI and their up-to-date status. You can retrieve special LKI or sequentialy retrieve all of them. This class is intended to be overriden if smarter behavior is required.

Up.gif (1072 bytes)


Warnings

None.

Up.gif (1072 bytes)


Methods

Public:
TBag(uint inprcss,int* ipids,uint inkis,uint* iids)
TBag(BYTE** rawbytes,uint len,BOOL subclass=FALSE)
virtual ~TBag();

virtual char* Dump()
virtual uint GetSerSize(BOOL subclass=FALSE)
virtual uint Serialize(BYTE **rawbytes,BOOL subclass=FALSE)

virtual BOOL Store(uint id,int pid,TKernelInfo* ki)
virtual TKernelInfo* Get(uint id,int pid)
virtual TKernelInfo* GetFirst(uint* id=NULL,int* pid=NULL)
virtual TKernelInfo* GetNext(uint* id=NULL,int* pid=NULL)

virtual BOOL IsFull()
virtual void ClearAll()
virtual void Clear(uint id,int pid)
virtual uint GetArrived() (see attribute arrived)
void SetOwner(TGlobalKI& gki) (see attribute owner)
Protected:
Private:


TBag(uint inprcss,int* ipids,uint inkis,uint* iids)

Constructor of class. As arguments you have to specify the PIDs of processes and IDs of local kernel infos you will store in the bag.

Arguments:

inprcss ... number of processes from which you will await the LKIs
pids ... pointer to array of pids (its size is inprcss) of these processes
inkis ... number of different LKIs (with unique ID) you are awaiting
iids ... pointer to array of these IDs (its size is inkis)

Returns:

nothing

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


virtual BOOL Store(uint id,int pid,TKernelInfo* ki)

Using this method you can store the incomming LKI into the bag.

Arguments:

id ... ID of new LKI
pid ... PID of process that have sent the new LKI
ki ... pointer to the new LKI (the object is not copied, so do not destroy it after it is stored)

Returns:

TRUE if everything's OK

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


virtual TKernelInfo* Get(uint id,int pid)

Using this method you can retrieve specific stored LKI.

Arguments:

id ... ID of requested LKI
pid ... PID of process that have sent the requested LKI

Returns:

pointer to the requested LKI (the object is not copied, so do not destroy it)

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


virtual TKernelInfo* GetFirst(uint* id=NULL,int* pid=NULL)
virtual TKernelInfo* GetFirstNext(uint* id=NULL,int* pid=NULL)

These methods are intended for the sequential search of the bag. At the first time use once method GetFirst() and then use method GetNext till it returns NULL. This way you retrieve all stored LKI from the bag.
If you specify id and pid arguments, you will obtain in them ID of returned KI and its sender's PID.
An example:
uint id;
int pid;
TKernelInfo *ki = GetFirst(&id,&pid);
while(!ki) {
//do something with *ki,id or pid
ki = GetNext(&id,&pid);
}

Arguments:

id ... space for ID of returned LKI
pid ... space for PID of process that have sent the returned LKI

Returns:

pointer to the first stored LKI from the bag (the object is not copied, so do not destroy it)
or NULL if there is no stored LKI in the bag
if id or pid was not equal to NULL, the proper values of returned LKI are stored in them

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


virtual BOOL IsFull()

Using this method you can find out if the bag is already full e.g. all LKIs from all processes have arrived.

Arguments:

none

Returns:

TRUE if the bag is full

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


virtual void ClearAll()

This method destroys all stored LKIs in the bag.

Arguments:

none

Returns:

nothing

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


virtual void Clear(uint id,int pid)

This method destroys specified stored LKIs in the bag.

Arguments:

id ... ID of LKI to be destroyed
pid ... PID of process that have sent the LKI to be destroyed

Returns:

nothing

arrow3u.gif (362 bytes) Up.gif (1072 bytes)




Atributes

Public:
int *pids
uint nprcss

uint nkis
uint *ids

TKernelInfo **kis
Protected:
uint arrived
uint current
TGlobalKI *owner
Private:


int *pids
uint nprcss

These attributes specify an array of PIDs of processes form which you are awaiting LKIs.
pids is the pointer to this array and nprcss is the number of PIDs in it.

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


uint nkis
uint *ids

These attributes specify an array of IDs of LKIs which you ar awaiting.
ids is the pointer to this array and nkis is the number of IDs in it.

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


TKernelInfo **kis

This is a pointer to the matrix of KIs (in fact only pointers to them). It is the bag itself. The size of matrix is (nprcss)x(nkis). The order of rows and columns corresponds with arrays pids and ids.

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


uint arrived

This attribute specify number of LKIs that have already arrived and are stored in the bag.

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


uint current

This attribute stores the current position in matrix during the sequential search by methods GetFirst(), GetNext().

arrow3u.gif (362 bytes) Up.gif (1072 bytes)


TGlobalKI *owner

This attribute specify the global kernel info owning this TBag object.

arrow3u.gif (362 bytes) Up.gif (1072 bytes)




Operators

Public:
Protected:
Private:




Specials

None.

Up.gif (1072 bytes)