TGlobalKI

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


Description

This is the prototype class of global kernel info. It waits for certain number of differnet LKIs from different processes to be collected. It can also contain some global information computed from the pieces of local information contained in incomming LKIs. It contains the bag for storing these LKIs.

Up.gif (1072 bytes)


Warnings

This GKI is not generic in the following sense: it awaits LKIs from all spawned child processes. Also the amount and kind of LKIs cannot differ by the process. If you need different behavior you have to override this class.

Up.gif (1072 bytes)


Methods

Public:
TGlobalKI(uint iid,int period)
TGlobalKI(BYTE** rawbytes,uint len,BOOL subclass=FALSE)
virtual ~TGlobalKI();

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

virtual BOOL IsReady()
virtual BOOL Init()
virtual TKernelInfo* CreateKI(uint id,BYTE** rawbytes,uint len)
virtual void Compute()
virtual BOOL Add(uint kid,int pid,BYTE** rawbytes,uint len)
virtual BOOL IsWaitingFor(uint kid,int pid)
virtual void Spoil()

BOOL InitBag(uint nkis,uint* ids,int period)
Protected:
Private:


TGlobalKI(uint iid,int period)

Constructor of the class.

Arguments:

iid ... the ID of this KI
period ... in this period should be the LKIs resent from each child process

Returns:

nothing

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


virtual BOOL IsReady()

This method specify if the GKI is ready to by sent or not. If you do not override this method then GKI is ready when all LKIs have arrived (the bag is full).

Arguments:

none

Returns:

TRUE if all LKIs have arrived

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


virtual BOOL Init()

This abstract method is intended to initialize the GKI and its bag. Override this function and call InitBag() within it.

Arguments:

none

Returns:

TRUE if everything's OK

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


virtual TKernelInfo* CreateKI(uint id,BYTE** rawbytes,uint len)

This abstract method should implement deserialization of all awaiting LKIs. In other words, create (deserialize) object of the proper class that correspond with the given ID.

Arguments:

id ... ID of LKI that should be deserialized
rawbytes ... points to pointer to the serialized LKI
len ... length of the serialized LKI

Returns:

pointer to the deserialized object or NULL

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


virtual void Compute()

This method is intended for computation of some global information from LKIs stored in the bag.

Arguments:

none

Returns:

nothing

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


virtual BOOL Add(uint kid,int pid,BYTE** rawbytes,uint len)

This method is called when new LKI arrives.

Arguments:

kid ... ID of the incomming LKI
pid ... PID of the process that have sent the incomming LKI
rawbytes ... points to pointer to the serialized LKI
len ... length of the serialized LKI

Returns:

TRUE if the LKI was successfully stored into the bag

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


virtual BOOL IsWaitingFor(uint kid,int pid)

This method decides, if the bag was registered to the specified LKI and is awaiting it..

Arguments:

kid ... ID of the LKI
pid ... PID of the process that send the LKI

Returns:

TRUE if the bag was registered to the specified LKI

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


virtual void Spoil()

This method is intended to discard GKI after it's retrieval by some upper layer. In default implementation it calls method TBag::ClearAll() to remove all LKIs from its bag. We suggest to call this method after each succesfull retrieval of GKI.

Arguments:

none

Returns:

nothing

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


BOOL InitBag(uint nkis,uint* ids,int period)

This method prepares the bag for collecting LKIs. You have to specify which LKI you want to collect. Then the request for them is registered in all child processes.

Arguments:

nkis ... number of different LKIs you want to collect
ids ... array of length specified by nkis, containig IDs of these LKIs
period ... updating period of each LKI (the number of loops performed by local GA before resending LKI)

Returns:

TRUE if everything's OK

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




Atributes

Public:
TBag *bag
Protected:
int lperiod
Private:


TBag *bag

This attribute points to the bag, containig arrived LKIs. (see class TBag)

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


int lperiod

This attribute contains the period, collection of this GKI was registered with.

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




Operators

Public:
Protected:
Private:




Specials

None.

Up.gif (1072 bytes)