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  {
124  } ClCntKeyTypeT;
125 
151 typedef ClInt32T (*ClCntKeyCompareCallbackT)(CL_IN ClCntKeyHandleT key1,
152  CL_IN ClCntKeyHandleT key2);
175 typedef void (*ClCntDeleteCallbackT)(CL_IN ClCntKeyHandleT userKey,
176  CL_IN ClCntDataHandleT userData);
198  typedef ClUint32T (*ClCntHashCallbackT)(CL_IN ClCntKeyHandleT userKey);
199 
224  typedef ClRcT (*ClCntWalkCallbackT)(CL_IN ClCntKeyHandleT userKey,
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);
667 extern ClRcT clCntNodeAddAndNodeGet(CL_IN ClCntHandleT containerHandle,
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);
772 extern ClRcT clCntAllNodesForKeyDelete(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);
983 extern ClRcT clCntPreviousNodeGet(CL_IN ClCntHandleT containerHandle,
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 
1071 extern ClRcT clCntNodeUserKeyGet(CL_IN ClCntHandleT containerHandle,
1072  CL_IN ClCntNodeHandleT nodeHandle,
1073  CL_OUT ClCntKeyHandleT *pUserKey);
1109 extern ClRcT clCntDataForKeyGet(CL_IN ClCntHandleT containerHandle,
1110  CL_IN ClCntKeyHandleT userKey,
1111  CL_OUT ClCntDataHandleT *pUserData);
1144 extern ClRcT clCntNodeUserDataGet(CL_IN ClCntHandleT containerHandle,
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 

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