This class implements the IdcAdaptersSet interface, it stores all the adapters that in use by one user. More...
#include <DcAdaptersSet.h>
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. |
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.
Definition at line 56 of file DcAdaptersSet.h.
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.
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.
AID | The 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.
name | The desired adapter name. |
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.
AID | The adapter ID. |
address | The address (or name) to read from. |
(BufferHolder) | Just pass an exception from the adapter. |
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.
AID | The adapter ID. |
check_free | Is 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.
AID | The adapter ID. |
address | The address (or name) to write to. |
value | The string to write to this address (Optional). |
(BufferHolder) | Just pass an exception from the adapter. |
Definition at line 147 of file DcAdaptersSet.cpp.
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.