IBM Tivoli Software IBM Tivoli Software

[ Bottom of Page | Previous Page | Next Page | Contents | Index ]


Mapping tables

Method CreateMap

Syntax
Object.CreateMap( ) As Integer
Returns
The handle of a new mapping table.
Description
This method creates a new mapping table and returns a handle to it.
Remarks
To avoid memory leaks, call the DestroyMap method when the mapping table is no longer required.
Error code
S_OK

Method SetMapNumElement

Syntax
Object.SetMapNumElement(hndl As Integer, key As String, val As Double)
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
key
The key to store.
val
The numeric value to store.
Description
This method inserts the key-val pair in the mapping table associated with the given handle.
Error codes

TMWSERVICE_E_MAP_HANDLE_NOT_FOUND
S_OK

Method SetMapStrElement

Syntax
Object.SetMapStrElement(hndl As Integer, key As String, val As String)
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
key
The key to store.
val
The string value to store.
Description
This method inserts the key-val pair in the mapping table associated with the given handle.
Error codes

TMWSERVICE_E_MAP_HANDLE_NOT_FOUND
S_OK

Method GetMapNumValue

Syntax
Object.GetMapNumValue (hndl As Integer, key As String) As Double
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
key
The key to lookup.
Returns
The numeric value associated with the given key.
Description
This method retrieves the value associated with the key in the mapping table linked with the given handle.
Error codes

TMWSERVICE_E_MAP_HANDLE_NOT_FOUND
TMWSERVICE_E_MAP_KEY_NOT_FOUND S_OK

Method GetMapStrValue

Syntax
Object.GetMapStrValue(hndl As Integer, key As String) As String
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
key
The key to lookup.
Returns
The string value associated with the given key.
Description
This method retrieves the value associated with the key in the mapping table linked to the given handle.
Error codes

TMWSERVICE_E_MAP_HANDLE_NOT_FOUND
TMWSERVICE_E_MAP_KEY_NOT_FOUND
S_OK

Method RemoveMapElement

Syntax
Object.RemoveMapElement(hndl As Integer, key As String)
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
key
The key to remove from the mapping table.
Description
This method removes the value associated with the key in the mapping table linked to the given handle.
Error codes
TMWSERVICE_E_MAP_HANDLE_NOT_FOUND S_OK

Method RemoveMapAll

Syntax
Object.RemoveMapAll(hndl As Integer)
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
Description
This method removes all the elements contained in the mapping table associated with the handle hndl, but it does not destroy the mapping table.
Remarks
This method does not free all the resources used by a mapping table. If you want to make them available, call the DestroyMap method.
Error codes
TMWSERVICE_E_MAP_HANDLE_NOT_FOUND S_OK

Method ExistsMapElement

Syntax
Object.ExistsMapElement(hndl As Integer, key As String) 
As Boolean A. Service Object Method Library
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
key
The key to check whether an element exists.
Returns
TRUE if the key exists in the given mapping table, or FALSE if it does not exist.
Description
This method checks whether the given key is contained in the mapping table associated with the given handle.
Error codes
TMWSERVICE_E_MAP_HANDLE_NOT_FOUND S_OK

Method DestroyMap

Syntax
Object.DestroyMap(hndl As Integer)
Parameters
hndl
The handle of a mapping table returned by a call to CreateMap.
Remarks
Call the DestroyMap to free the resources used by a mapping table.
Description
This method destroys a the mapping table associated with the handle hndl.
Error codes
TMWSERVICE_E_MAP_HANDLE_NOT_FOUND S_OK

Example

Table 19. Basic Object Method mapping examples
Visual Basic example:

Dim hPropTable As Integer
hPropTable = Svc.CreateMap()

Svc.SetMapNumElement(hPropTable, "NumAttr", 1)
Svc.SetMapStrElement(hPropTable, "StrAttr", "stringVal")

Dim numAttr As Double
numAttr = Svc.GetMapNumValue(hPropTable, "NumAttr")

Dim strAttr As String
strAttr = Svc.GetMapStrValue(hPropTable, "StrAttr")

Svc.RemoveMapElement(hPropTable, "NumAttr")
If Svc.ExistsMapElement(hPropTable, "NumAttr") Then
'Error
End If

Svc.RemoveMapAll(hPropTable)
Svc.DestroyMap(hPropTable)

JavaScript example:

var hPropTable;
hPropTable = Svc.CreateMap();

Svc.SetMapNumElement(hPropTable, "NumAttr", 1);
Svc.SetMapStrElement(hPropTable, "StrAttr", "stringVal");

var numAttr;
numAttr = Svc.GetMapNumValue(hPropTable, "NumAttr");

var strAttr;
strAttr = Svc.GetMapStrValue(hPropTable, "StrAttr");

Svc.RemoveMapElement(hPropTable, "NumAttr");
if( Svc.ExistsMapElement(hPropTable, "NumAttr") ){
//Error
}

Svc.RemoveMapAll(hPropTable);
Svc.DestroyMap(hPropTable);


[ Top of Page | Previous Page | Next Page | Contents | Index ]