vdsHashMap Class Reference
List of all members.Public Member Functions | |
vdsHashMap (vdsSession &session) | |
virtual | ~vdsHashMap () |
void | Close () |
Close a Hash Map. | |
void | Delete (const void *key, size_t keyLength) |
Remove the data item identified by the given key from the hash map. | |
void | Get (const void *key, size_t keyLength, void *buffer, size_t bufferLength, size_t *returnedLength) |
Retrieve the data item identified by the given key from the hash map. | |
int | GetFirst (void *key, size_t keyLength, void *buffer, size_t bufferLength, size_t *retKeyLength, size_t *retDataLength) |
Iterate through the hash map. | |
int | GetNext (void *key, size_t keyLength, void *buffer, size_t bufferLength, size_t *retKeyLength, size_t *retDataLength) |
Iterate through the hash map. | |
void | Insert (const void *key, size_t keyLength, const void *data, size_t dataLength) |
Insert a data element in the hash map. | |
void | Open (const std::string &hashMapName) |
Open an existing hash map (see vdsSession::CreateObject to create a new object). | |
void | Open (const char *hashMapName, size_t nameLengthInBytes) |
Open an existing hash map (see vdsSession::CreateObject to create a new object). | |
void | Replace (const void *key, size_t keyLength, const void *data, size_t dataLength) |
Replace a data element in the hash map. | |
void | Status (vdsObjStatus *pStatus) |
Return the status of the hash map. | |
Private Attributes | |
VDS_HANDLE | m_objectHandle |
Pointer to the vdsaHashMap struct. | |
VDS_HANDLE & | m_sessionHandle |
Reference to the vdsaSession struct (we belong to). |
Constructor & Destructor Documentation
vdsHashMap::vdsHashMap | ( | vdsSession & | session | ) |
virtual vdsHashMap::~vdsHashMap | ( | ) | [virtual] |
Member Function Documentation
void vdsHashMap::Close | ( | ) |
Close a Hash Map.
This function terminates the current access to the hash map in shared memory (the hash map itself is untouched).
- Warning:
- Closing an object does not automatically commit or rollback data items that were inserted or removed. You still must use either vdsSession::Commit or vdsSession::Rollback to end the current unit of work.
- Exceptions:
-
vdsException An abnormal error occured.
void vdsHashMap::Delete | ( | const void * | key, | |
size_t | keyLength | |||
) |
Remove the data item identified by the given key from the hash map.
Data items which were added by another session and are not yet committed will not be seen by this function and cannot be removed. Likewise, destroyed data items (even if not yet committed) are invisible.
The removals only become permanent after a call to vdsSession::Commit.
- Parameters:
-
[in] key The key of the item to be removed. [in] keyLength The length of the key buffer (in bytes).
- Exceptions:
-
vdsException An abnormal error occured.
void vdsHashMap::Get | ( | const void * | key, | |
size_t | keyLength, | |||
void * | buffer, | |||
size_t | bufferLength, | |||
size_t * | returnedLength | |||
) |
Retrieve the data item identified by the given key from the hash map.
Data items which were added by another session and are not yet committed will not be seen by this function. Likewise, destroyed data items (even if not yet committed) are invisible.
- Parameters:
-
[in] key The key of the item to be retrieved. [in] keyLength The length of the key buffer (in bytes). [out] buffer The buffer provided by the user to hold the content of the data item. Memory allocation for this buffer is the responsability of the caller. [in] bufferLength The length of buffer (in bytes). [out] returnedLength The actual number of bytes in the data item.
- Exceptions:
-
vdsException An abnormal error occured.
int vdsHashMap::GetFirst | ( | void * | key, | |
size_t | keyLength, | |||
void * | buffer, | |||
size_t | bufferLength, | |||
size_t * | retKeyLength, | |||
size_t * | retDataLength | |||
) |
Iterate through the hash map.
Data items which were added by another session and are not yet committed will not be seen by the iterator. Likewise, destroyed data items (even if not yet committed) are invisible.
Data items retrieved this way will not be sorted.
- Parameters:
-
[out] key The key buffer provided by the user to hold the content of the key associated with the first element. Memory allocation for this buffer is the responsability of the caller. [in] keyLength The length of the key buffer (in bytes). [out] buffer The buffer provided by the user to hold the content of the first element. Memory allocation for this buffer is the responsability of the caller. [in] bufferLength The length of buffer (in bytes). [out] retKeyLength The actual number of bytes in the key [out] retDataLength The actual number of bytes in the data item.
- Returns:
- 0 on success or VDS_IS_EMPTY if the hash map is empty.
- Exceptions:
-
vdsException An abnormal error occured.
int vdsHashMap::GetNext | ( | void * | key, | |
size_t | keyLength, | |||
void * | buffer, | |||
size_t | bufferLength, | |||
size_t * | retKeyLength, | |||
size_t * | retDataLength | |||
) |
Iterate through the hash map.
Data items which were added by another session and are not yet committed will not be seen by the iterator. Likewise, destroyed data items (even if not yet committed) are invisible.
Evidently, you must call vdsHashMap::GetFirst to initialize the iterator. Not so evident - calling vdsHashMap::Get will reset the iteration to the data item retrieved by this function (they use the same internal storage). If this cause a problem, please let us know.
Data items retrieved this way will not be sorted.
- Parameters:
-
[out] key The key buffer provided by the user to hold the content of the key associated with the data element. Memory allocation for this buffer is the responsability of the caller. [in] keyLength The length of the key buffer (in bytes). [out] buffer The buffer provided by the user to hold the content of the data element. Memory allocation for this buffer is the responsability of the caller. [in] bufferLength The length of buffer (in bytes). [out] retKeyLength The actual number of bytes in the key [out] retDataLength The actual number of bytes in the data item.
- Returns:
- 0 on success or VDS_REACHED_THE_END when the iteration reaches the end of the hash map.
- Exceptions:
-
vdsException An abnormal error occured.
void vdsHashMap::Insert | ( | const void * | key, | |
size_t | keyLength, | |||
const void * | data, | |||
size_t | dataLength | |||
) |
Insert a data element in the hash map.
The additions only become permanent after a call to vdsSession::Commit.
- Parameters:
-
[in] key The key of the item to be inserted. [in] keyLength The length of the key buffer (in bytes). [in] data The data item to be inserted. [in] dataLength The length of data (in bytes).
- Exceptions:
-
vdsException An abnormal error occured.
void vdsHashMap::Open | ( | const char * | hashMapName, | |
size_t | nameLengthInBytes | |||
) |
Open an existing hash map (see vdsSession::CreateObject to create a new object).
- Parameters:
-
[in] hashMapName The fully qualified name of the hash map. [in] nameLengthInBytes The length of hashMapName (in bytes) not counting the null terminator.
- Exceptions:
-
vdsException An abnormal error occured.
void vdsHashMap::Open | ( | const std::string & | hashMapName | ) |
Open an existing hash map (see vdsSession::CreateObject to create a new object).
- Parameters:
-
[in] hashMapName The fully qualified name of the hash map.
- Exceptions:
-
vdsException An abnormal error occured.
void vdsHashMap::Replace | ( | const void * | key, | |
size_t | keyLength, | |||
const void * | data, | |||
size_t | dataLength | |||
) |
Replace a data element in the hash map.
The replacements only become permanent after a call to vdsSession::Commit.
- Parameters:
-
[in] key The key of the item to be replaced. [in] keyLength The length of the key buffer (in bytes). [in] data The new data item that will replace the previous data. [in] dataLength The length of data (in bytes).
- Exceptions:
-
vdsException An abnormal error occured.
void vdsHashMap::Status | ( | vdsObjStatus * | pStatus | ) |
Return the status of the hash map.
- Parameters:
-
[out] pStatus A pointer to the status structure.
- Exceptions:
-
vdsException An abnormal error occured.
Member Data Documentation
VDS_HANDLE vdsHashMap::m_objectHandle [private] |
Pointer to the vdsaHashMap struct.
VDS_HANDLE& vdsHashMap::m_sessionHandle [private] |
Reference to the vdsaSession struct (we belong to).
The documentation for this class was generated from the following file:
- vdsf/vdsHashMap
Last updated on March 23, 2008.