OpenClovis Logo

clCntApi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2012 OpenClovis Solutions Inc. All Rights Reserved.
3  *
4  * This file is available under a commercial license from the
5  * copyright holder or the GNU General Public License Version 2.0.
6  *
7  * The source code for this program is not published or otherwise
8  * divested of its trade secrets, irrespective of what has been
9  * deposited with the U.S. Copyright office.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * For more information, see the file COPYING provided with this
17  * material.
18  */
19 /*******************************************************************************
20  * ModuleName : cnt
21  * File : clCntApi.h
22  *******************************************************************************/
23 
24 /*******************************************************************************
25  * Description :
26  * Clovis Container Library
27  *
28  *
29  *****************************************************************************/
30 
31 
32 /**********************************************************************************/
33 /****************************** CONTAINER APIs ************************************/
34 /**********************************************************************************/
35 /* */
36 /* clCntLlistCreate */
37 /* clCntHashtblCreate */
38 /* clCntRbtreeCreate */
39 /* clCntNodeAddAndNodeGet */
40 /* clCntNodeAdd */
41 /* clCntAllNodesDelete */
42 /* clCntAllNodesForKeyDelete */
43 /* clCntNodeDelete */
44 /* clCntNodeFind */
45 /* clCntFirstNodeGet */
46 /* clCntLastNodeGet */
47 /* clCntNextNodeGet */
48 /* clCntPreviousNodeGet */
49 /* clCntWalk */
50 /* clCntNodeUserKeyGet */
51 /* clCntDataForKeyGet */
52 /* clCntNodeUserDataGet */
53 /* clCntSizeGet */
54 /* clCntKeySizeGet */
55 /* clCntDelete */
56 /* clCntiThreadSafeLlistCreate */
57 /* */
58 /**********************************************************************************/
59 
71 #ifndef _CL_CNT_H_
72 #define _CL_CNT_H_
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
78 #include <clCommon.h>
79 #include <clRuleApi.h>
80 
81 /******************************************************************************
82  * Data Types
83  *****************************************************************************/
88  typedef ClPtrT ClCntHandleT;
89 
93  typedef ClPtrT ClCntNodeHandleT;
97  typedef ClPtrT ClCntDataHandleT;
101  typedef ClPtrT ClCntArgHandleT;
105  typedef ClPtrT ClCntKeyHandleT;
106 
110  typedef enum
111  {
125 
152  CL_IN ClCntKeyHandleT key2);
176  CL_IN ClCntDataHandleT userData);
198  typedef ClUint32T (*ClCntHashCallbackT)(CL_IN ClCntKeyHandleT userKey);
199 
225  CL_IN ClCntDataHandleT userData,
226  CL_IN ClCntArgHandleT userArg,
227  CL_IN ClUint32T dataLength);
228 
285  CL_IN ClCntDeleteCallbackT fpUserDeleteCallback,
286  CL_IN ClCntDeleteCallbackT fpUserDestroyCallback,
287  CL_IN ClCntKeyTypeT containerKeyType,
288  CL_OUT ClCntHandleT* pContainerHandle);
349  CL_IN ClCntDeleteCallbackT fpUserDeleteCallback,
350  CL_IN ClCntDeleteCallbackT fpUserDestroyCallback,
351  CL_IN ClCntKeyTypeT containerKeyType,
352  CL_OUT ClCntHandleT* pContainerHandle);
353 
354 extern ClRcT
355 clCntOrderedLlistCreate(
356  ClCntKeyCompareCallbackT fpKeyCompare,
357  ClCntDeleteCallbackT fpUserDeleteCallback,
358  ClCntDeleteCallbackT fpUserDestroyCallback,
359  ClCntKeyTypeT containerKeyType,
360  ClCntHandleT* pContainerHandle);
361 
422 extern ClRcT
423 clCntHashtblCreate(CL_IN ClUint32T numberOfBuckets,
424  CL_IN ClCntKeyCompareCallbackT fpKeyCompare,
425  CL_IN ClCntHashCallbackT fpHashFunction,
426  CL_IN ClCntDeleteCallbackT fpUserDeleteCallback,
427  CL_IN ClCntDeleteCallbackT fpUserDestroyCallback,
428  CL_IN ClCntKeyTypeT containerKeyType,
429  CL_IN ClCntHandleT* pContainerHandle);
430 
491 extern ClRcT
492 clCntThreadSafeHashtblCreate(CL_IN ClUint32T numberOfBuckets,
493  CL_IN ClCntKeyCompareCallbackT fpKeyCompare,
494  CL_IN ClCntHashCallbackT fpHashFunction,
495  CL_IN ClCntDeleteCallbackT fpUserDeleteCallback,
496  CL_IN ClCntDeleteCallbackT fpUserDestroyCallback,
497  CL_IN ClCntKeyTypeT containerKeyType,
498  CL_OUT ClCntHandleT* pContainerHandle);
499 
559  CL_IN ClCntDeleteCallbackT fpUserDeleteCallback,
560  CL_IN ClCntDeleteCallbackT fpUserDestroyCallback,
561  CL_IN ClCntKeyTypeT containerKeyType,
562  CL_OUT ClCntHandleT* pContainerHandle);
623  CL_IN ClCntDeleteCallbackT fpUserDeleteCallback,
624  CL_IN ClCntDeleteCallbackT fpUserDestroyCallback,
625  CL_IN ClCntKeyTypeT containerKeyType,
626  CL_OUT ClCntHandleT* pContainerHandle);
668  CL_IN ClCntKeyHandleT userKey,
669  CL_IN ClCntDataHandleT userData,
670  CL_IN ClRuleExprT *pExp,
671  CL_IN ClCntNodeHandleT *pNodeHandle);
705 extern ClRcT clCntNodeAdd(CL_IN ClCntHandleT containerHandle,
706  CL_IN ClCntKeyHandleT userKey,
707  CL_IN ClCntDataHandleT userData,
708  CL_IN ClRuleExprT *rbeExpression);
738 extern ClRcT clCntAllNodesDelete(CL_IN ClCntHandleT containerHandle);
773  CL_IN ClCntKeyHandleT userKey);
807 extern ClRcT clCntNodeDelete(CL_IN ClCntHandleT containerHandle,
808  CL_IN ClCntNodeHandleT nodeHandle);
844 extern ClRcT clCntNodeFind(CL_IN ClCntHandleT containerHandle,
845  CL_IN ClCntKeyHandleT userKey,
846  CL_IN ClCntNodeHandleT *pNodeHandle);
847 
848 extern ClRcT clCntNonUniqueKeyFind(ClCntHandleT container, ClCntKeyHandleT key, ClCntDataHandleT givenData,
849  ClInt32T (*cmp)(ClCntDataHandleT data1, ClCntDataHandleT data2),
850  ClCntDataHandleT *pDataHandle);
881 extern ClRcT clCntFirstNodeGet(CL_IN ClCntHandleT containerHandle,
882  CL_OUT ClCntNodeHandleT* pNodeHandle);
914 extern ClRcT clCntLastNodeGet(CL_IN ClCntHandleT containerHandle,
915  CL_OUT ClCntNodeHandleT *pNodeHandle);
948 extern ClRcT clCntNextNodeGet(CL_IN ClCntHandleT containerHandle,
949  CL_IN ClCntNodeHandleT currentNodeHandle,
950  CL_OUT ClCntNodeHandleT *pNextNodeHandle);
984  CL_IN ClCntNodeHandleT currentNodeHandle,
985  CL_OUT ClCntNodeHandleT *pPreviousNodeHandle);
1030 extern ClRcT clCntWalk(CL_IN ClCntHandleT containerHandle,
1031  CL_IN ClCntWalkCallbackT fpUserWalkCallback,
1032  CL_IN ClCntArgHandleT userArg,
1033  CL_IN ClInt32T length);
1034 
1035 extern ClRcT clCntWalkFailSafe(CL_IN ClCntHandleT containerHandle,
1036  CL_IN ClCntWalkCallbackT fpUserWalkCallback,
1037  CL_IN ClCntArgHandleT userArg,
1038  CL_IN ClInt32T length);
1039 
1072  CL_IN ClCntNodeHandleT nodeHandle,
1073  CL_OUT ClCntKeyHandleT *pUserKey);
1110  CL_IN ClCntKeyHandleT userKey,
1111  CL_OUT ClCntDataHandleT *pUserData);
1145  CL_IN ClCntNodeHandleT nodeHandle,
1146  CL_OUT ClCntDataHandleT *pUserDataHandle);
1177 extern ClRcT clCntSizeGet(CL_IN ClCntHandleT containerHandle,
1178  CL_OUT ClUint32T *pSize);
1211 extern ClRcT clCntKeySizeGet(CL_IN ClCntHandleT containerHandle,
1212  CL_IN ClCntKeyHandleT userKey,
1213  CL_OUT ClUint32T* pSize);
1242 extern ClRcT clCntDelete(CL_IN ClCntHandleT containerHandle);
1243 
1244 extern ClRcT clCntNonUniqueKeyDelete(CL_IN ClCntHandleT container, ClCntKeyHandleT key,
1245  ClCntDataHandleT givenData,
1246  ClInt32T (*cmp)(ClCntDataHandleT, ClCntDataHandleT));
1247 
1248 /*************************************************************/
1249 /*
1250  Since the container doesnt have an empty equivalent, we live
1251  with this for the time being:
1252 */
1253 #define CNT_WALK_RC(cnt,rc) do { \
1254  ClRcT oldRc;\
1255  if(rc == CL_IOC_STOP_WALK) {\
1256  rc = CL_OK;\
1257  }\
1258  oldRc = rc;\
1259  if(oldRc != CL_OK) { \
1260  ClUint32T n = 0;\
1261  rc = clCntSizeGet((cnt),&n);\
1262  if(rc != CL_OK || n > 0) { \
1263  rc = oldRc;\
1264  } else { \
1265  rc = CL_OK;\
1266  }\
1267  }\
1268 }while(0)
1269 
1270 #ifdef __cplusplus
1271 }
1272 #endif
1273 
1274 /* _CL_CNT_API_H_ */
1275 #endif
1276 
Typical defines found in any software project.
Header file of RBE related APIs.
ClPtrT ClCntDataHandleT
Handle of the data.
Definition: clCntApi.h:97
ClRcT clCntNodeDelete(CL_IN ClCntHandleT containerHandle, CL_IN ClCntNodeHandleT nodeHandle)
Deletes a specific node from the Container.
ClRcT clCntNodeUserDataGet(CL_IN ClCntHandleT containerHandle, CL_IN ClCntNodeHandleT nodeHandle, CL_OUT ClCntDataHandleT *pUserDataHandle)
Returns the user-data from the node.
ClRcT clCntKeySizeGet(CL_IN ClCntHandleT containerHandle, CL_IN ClCntKeyHandleT userKey, CL_OUT ClUint32T *pSize)
Returns the number of nodes associated with a user-key.
ClInt32T(* ClCntKeyCompareCallbackT)(CL_IN ClCntKeyHandleT key1, CL_IN ClCntKeyHandleT key2)
Compares the two keys.
Definition: clCntApi.h:151
void(* ClCntDeleteCallbackT)(CL_IN ClCntKeyHandleT userKey, CL_IN ClCntDataHandleT userData)
Gets called While destroying the node of the container.
Definition: clCntApi.h:175
ClRcT clCntThreadSafeLlistCreate(CL_IN ClCntKeyCompareCallbackT fpKeyCompare, CL_IN ClCntDeleteCallbackT fpUserDeleteCallback, CL_IN ClCntDeleteCallbackT fpUserDestroyCallback, CL_IN ClCntKeyTypeT containerKeyType, CL_OUT ClCntHandleT *pContainerHandle)
Creates the container doubly linked list with lock variable.
ClRcT clCntNodeUserKeyGet(CL_IN ClCntHandleT containerHandle, CL_IN ClCntNodeHandleT nodeHandle, CL_OUT ClCntKeyHandleT *pUserKey)
Returns the user-key from the node.
ClRcT(* ClCntWalkCallbackT)(CL_IN ClCntKeyHandleT userKey, CL_IN ClCntDataHandleT userData, CL_IN ClCntArgHandleT userArg, CL_IN ClUint32T dataLength)
Gets called While performing container walk operation.
Definition: clCntApi.h:224
ClRcT clCntRbtreeCreate(CL_IN ClCntKeyCompareCallbackT fpKeyCompare, CL_IN ClCntDeleteCallbackT fpUserDeleteCallback, CL_IN ClCntDeleteCallbackT fpUserDestroyCallback, CL_IN ClCntKeyTypeT containerKeyType, CL_OUT ClCntHandleT *pContainerHandle)
Creates the container red black tree.
ClRcT clCntAllNodesForKeyDelete(CL_IN ClCntHandleT containerHandle, CL_IN ClCntKeyHandleT userKey)
ClRcT clCntDataForKeyGet(CL_IN ClCntHandleT containerHandle, CL_IN ClCntKeyHandleT userKey, CL_OUT ClCntDataHandleT *pUserData)
Returns the user-data associated with a specified key.
ClRcT clCntFirstNodeGet(CL_IN ClCntHandleT containerHandle, CL_OUT ClCntNodeHandleT *pNodeHandle)
Returns the first node from the Container.
ClPtrT ClCntNodeHandleT
Handle of the container Node.
Definition: clCntApi.h:93
ClPtrT ClCntArgHandleT
Handle of the argument which will be passed to callback functions.
Definition: clCntApi.h:101
ClPtrT ClCntHandleT
Handle of the container.
Definition: clCntApi.h:88
ClRcT clCntThreadSafeHashtblCreate(CL_IN ClUint32T numberOfBuckets, CL_IN ClCntKeyCompareCallbackT fpKeyCompare, CL_IN ClCntHashCallbackT fpHashFunction, CL_IN ClCntDeleteCallbackT fpUserDeleteCallback, CL_IN ClCntDeleteCallbackT fpUserDestroyCallback, CL_IN ClCntKeyTypeT containerKeyType, CL_OUT ClCntHandleT *pContainerHandle)
Creates a thread safe hash table.
ClRcT clCntNodeAddAndNodeGet(CL_IN ClCntHandleT containerHandle, CL_IN ClCntKeyHandleT userKey, CL_IN ClCntDataHandleT userData, CL_IN ClRuleExprT *pExp, CL_IN ClCntNodeHandleT *pNodeHandle)
Adds a new node to Container and returns the node handle.
ClUint32T(* ClCntHashCallbackT)(CL_IN ClCntKeyHandleT userKey)
Gets called While doing hash table related operations.
Definition: clCntApi.h:198
ClRcT clCntNextNodeGet(CL_IN ClCntHandleT containerHandle, CL_IN ClCntNodeHandleT currentNodeHandle, CL_OUT ClCntNodeHandleT *pNextNodeHandle)
Returns the next node from the Container.
ClRcT clCntNodeAdd(CL_IN ClCntHandleT containerHandle, CL_IN ClCntKeyHandleT userKey, CL_IN ClCntDataHandleT userData, CL_IN ClRuleExprT *rbeExpression)
Adds a new node to Container.
ClCntKeyTypeT
This enum describes type of the container.
Definition: clCntApi.h:111
ClRcT clCntHashtblCreate(CL_IN ClUint32T numberOfBuckets, CL_IN ClCntKeyCompareCallbackT fpKeyCompare, CL_IN ClCntHashCallbackT fpHashFunction, CL_IN ClCntDeleteCallbackT fpUserDeleteCallback, CL_IN ClCntDeleteCallbackT fpUserDestroyCallback, CL_IN ClCntKeyTypeT containerKeyType, CL_IN ClCntHandleT *pContainerHandle)
Creates the hash table.
ClRcT clCntAllNodesDelete(CL_IN ClCntHandleT containerHandle)
Deletes all the nodes from the Container.
ClRcT clCntLlistCreate(CL_IN ClCntKeyCompareCallbackT fpKeyCompare, CL_IN ClCntDeleteCallbackT fpUserDeleteCallback, CL_IN ClCntDeleteCallbackT fpUserDestroyCallback, CL_IN ClCntKeyTypeT containerKeyType, CL_OUT ClCntHandleT *pContainerHandle)
Creates the container doubly linked list.
ClRcT clCntNodeFind(CL_IN ClCntHandleT containerHandle, CL_IN ClCntKeyHandleT userKey, CL_IN ClCntNodeHandleT *pNodeHandle)
Finds a specific node in the Container.
ClRcT clCntSizeGet(CL_IN ClCntHandleT containerHandle, CL_OUT ClUint32T *pSize)
Returns the size of the Container.
ClRcT clCntThreadSafeRbtreeCreate(CL_IN ClCntKeyCompareCallbackT fpKeyCompare, CL_IN ClCntDeleteCallbackT fpUserDeleteCallback, CL_IN ClCntDeleteCallbackT fpUserDestroyCallback, CL_IN ClCntKeyTypeT containerKeyType, CL_OUT ClCntHandleT *pContainerHandle)
Creates the thread safe container red black tree.
ClRcT clCntPreviousNodeGet(CL_IN ClCntHandleT containerHandle, CL_IN ClCntNodeHandleT currentNodeHandle, CL_OUT ClCntNodeHandleT *pPreviousNodeHandle)
Returns the previous node from the Container.
ClRcT clCntWalk(CL_IN ClCntHandleT containerHandle, CL_IN ClCntWalkCallbackT fpUserWalkCallback, CL_IN ClCntArgHandleT userArg, CL_IN ClInt32T length)
Walks through the Container.
ClPtrT ClCntKeyHandleT
Handle of the key handle.
Definition: clCntApi.h:105
ClRcT clCntDelete(CL_IN ClCntHandleT containerHandle)
Destroys the Container.
ClRcT clCntLastNodeGet(CL_IN ClCntHandleT containerHandle, CL_OUT ClCntNodeHandleT *pNodeHandle)
Returns the last node from the Container.
@ CL_CNT_INVALID_KEY_TYPE
Invalid container type.
Definition: clCntApi.h:123
@ CL_CNT_UNIQUE_KEY
Container contains unique key.
Definition: clCntApi.h:115
@ CL_CNT_NON_UNIQUE_KEY
Container contains non unique key.
Definition: clCntApi.h:119
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
#define CL_OUT
CL_OUT macro assists in clearly defining arguments of an API, but has no actual meaning.
Definition: clCommon.h:110
#define CL_IN
CL_IN macro assists in clearly defining arguments of an API, but has no actual meaning.
Definition: clCommon.h:106
Rule to filter data.Expression definition.
Definition: clRuleApi.h:241

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen