Classes | Public Member Functions | Friends

CdcAdaptersSet Class Reference

This class implements the IdcAdaptersSet interface, it stores all the adapters that in use by one user. More...

#include <DcAdaptersSet.h>

Inheritance diagram for CdcAdaptersSet:
IdcAdaptersSet

List of all members.

Classes

class  CdcAdapterNode
 Class for one node in the adapters list.

Public Member Functions

 CdcAdaptersSet ()
 Constructor - Does nothing.
virtual ~CdcAdaptersSet ()
 Destructor - Does nothing.
void Login ()
 Start the Release thread.
void Logout ()
 release all unused adapters, and close the Release thread.
virtual uint GetAdapter (BufferHolder name)
 This function tries to find an (ID of) adapter by the name 'name'.
virtual void ReleaseAdapter (uint AID, bool check_free=false)
 This function releases (delete) an adapter.
void AdapterDone (uint AID)
 When an engine exits (done with a script) it calls this function on every adapter it has (got with GetAdapter and didn't release).
virtual BufferHolder Read (unsigned int AID, BufferHolder address) throw (BufferHolder)
 This is the function that calls the adapter Read function.
virtual bool Write (uint AID, BufferHolder address, BufferHolder value) throw (BufferHolder)
 This is the function that calls the adapter Write function.

Friends

int DcRelease (void *pParam)
 This is a global friend function.

Detailed Description

This class implements the IdcAdaptersSet interface, it stores all the adapters that in use by one user.

It works closely with the CdcAdaptersBank that allocates these adapters. However this class is the one that destroys the adapters. When an engine needs to work with an adapter, it gets it's ID from this class, and call Read and/or Write with this ID. When the engine is done it either releases the adapters or calls Done on the adapters IDs.

As Adapter Set works just with the scripting engines, it does not use CdcString. Scripting engines does not know CdcString. It uses STL string.

This class is thread safe, as user can have more then one thread going in the same time. An adapter however, can be in use of just one thread at a time.

Author:
Erez Bibi
Version:
2.0

Definition at line 56 of file DcAdaptersSet.h.


Constructor & Destructor Documentation

CdcAdaptersSet::CdcAdaptersSet (  ) [inline]

Constructor - Does nothing.

Definition at line 105 of file DcAdaptersSet.h.

virtual CdcAdaptersSet::~CdcAdaptersSet (  ) [inline, virtual]

Destructor - Does nothing.

Definition at line 111 of file DcAdaptersSet.h.


Member Function Documentation

void CdcAdaptersSet::AdapterDone ( uint  AID )

When an engine exits (done with a script) it calls this function on every adapter it has (got with GetAdapter and didn't release).

If the adapter is not "Storable", the class will release (delete) it. If the adapter is "Storable", the class will mark it as free, set the tStartIdle time (for the release idles thread), but keep the adapter in its adapters map.

Parameters:
AIDThe ID of the adapter an engine is done with.

Definition at line 118 of file DcAdaptersSet.cpp.

uint CdcAdaptersSet::GetAdapter ( BufferHolder  name ) [virtual]

This function tries to find an (ID of) adapter by the name 'name'.

It looks first in the class adapters map. If it finds an adapter with the same name that is free, it returns it's ID, and marks it as not free. This adapter will always be a non multi-engine adapter, otherwise it will not be saved as free adapter. If it finds a taken adapter in the map and the adapter is non multi-engine, it returns 0. If it doesn't find an adapter in the map, or it finds a taken one but it is a multi-engine adapter, it tries to get the adapter from the Adapters Bank. The adapters bank might return a new adapter or not.

Parameters:
nameThe desired adapter name.
Returns:
(uint) The adapter ID or 0 if cannot get this adapter.

Implements IdcAdaptersSet.

Definition at line 51 of file DcAdaptersSet.cpp.

void CdcAdaptersSet::Login (  )

Start the Release thread.

DcAdaptersSet.cpp: implementation of the CdcAdaptersSet class.

for documentation see the header file.

Definition at line 27 of file DcAdaptersSet.cpp.

void CdcAdaptersSet::Logout (  )

release all unused adapters, and close the Release thread.

Definition at line 39 of file DcAdaptersSet.cpp.

BufferHolder CdcAdaptersSet::Read ( unsigned int  AID,
BufferHolder  address 
) throw (BufferHolder) [virtual]

This is the function that calls the adapter Read function.

This function does not lock the class Mutex.

Parameters:
AIDThe adapter ID.
addressThe address (or name) to read from.
Exceptions:
(BufferHolder)Just pass an exception from the adapter.
Returns:
(BufferHolder) Holds the result string (or an empty string).

Implements IdcAdaptersSet.

Definition at line 138 of file DcAdaptersSet.cpp.

void CdcAdaptersSet::ReleaseAdapter ( uint  AID,
bool  check_free = false 
) [virtual]

This function releases (delete) an adapter.

The function notify the Adapters Bank that it deletes this adapter. This notification is relevant for the Bank, just if it marked this adapter as taken.

Parameters:
AIDThe adapter ID.
check_freeIs a flag to indicate to this function not to release the adapter if it is taken by another thread.

Definition at line 101 of file DcAdaptersSet.cpp.

bool CdcAdaptersSet::Write ( uint  AID,
BufferHolder  address,
BufferHolder  value 
) throw (BufferHolder) [virtual]

This is the function that calls the adapter Write function.

This function does not lock the class Mutex.

Parameters:
AIDThe adapter ID.
addressThe address (or name) to write to.
valueThe string to write to this address (Optional).
Exceptions:
(BufferHolder)Just pass an exception from the adapter.
Returns:
(bool) True on success.

Definition at line 147 of file DcAdaptersSet.cpp.


Friends And Related Function Documentation

int DcRelease ( void *  pParam ) [friend]

This is a global friend function.

This function runs as a separate thread, has access to all the private members of the class and in charge of releasing adapters that have not been used for sometime. The time is defined in the parameters file for each adapter. Adapter does not has to have a release time.

Definition at line 157 of file DcAdaptersSet.cpp.


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