summaryrefslogtreecommitdiffstats
path: root/obj-types.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-29 09:14:10 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-29 09:14:10 +0000
commit4412b88148a21d54ba1c2f88ba894b6223986b9a (patch)
tree07c18ea553bf5060d2ca1b431164d5a36b725d73 /obj-types.h
parent3d0f49a82e46fdffd8bb2c653ccb46ddd516e112 (diff)
downloadrsyslog-4412b88148a21d54ba1c2f88ba894b6223986b9a.tar.gz
rsyslog-4412b88148a21d54ba1c2f88ba894b6223986b9a.tar.xz
rsyslog-4412b88148a21d54ba1c2f88ba894b6223986b9a.zip
changed obj base object's calling interface to use the new obj_if_t
interface structure
Diffstat (limited to 'obj-types.h')
-rw-r--r--obj-types.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/obj-types.h b/obj-types.h
index 79781e44..23c2d761 100644
--- a/obj-types.h
+++ b/obj-types.h
@@ -60,9 +60,10 @@ typedef enum { /* IDs of known object "types/classes" */
OBJvm = 11,
OBJsysvar = 12,
OBJvmstk = 13,
- OBJexpr = 14 /* remeber to UPDATE OBJ_NUM_IDS (below) if you add one! */
+ OBJobj = 14, /* the base object itself - somewhat tricky, but required... */
+ OBJexpr = 15 /* remeber to UPDATE OBJ_NUM_IDS (below) if you add one! */
} objID_t;
-#define OBJ_NUM_IDS 15
+#define OBJ_NUM_IDS 16
typedef enum { /* IDs of base methods supported by all objects - used for jump table, so
* they must start at zero and be incremented. -- rgerahrds, 2008-01-04
@@ -156,15 +157,24 @@ typedef struct obj { /* the dummy struct that each derived class can be casted t
rsRetVal (*Set##prop)(obj##_t *pThis, dataType)
/* class initializer */
#define PROTOTYPEObjClassInit(objName) rsRetVal objName##ClassInit(void)
-#define BEGINObjClassInit(objName, objVers) \
+/* below: objName must be the object name (e.g. vm, strm, ...) and ISCORE must be
+ * 1 if the module is a statically linked core module and 0 if it is a
+ * dynamically loaded one. -- rgerhards, 2008-02-29
+ */
+#define OBJ_IS_CORE_MODULE 1
+#define OBJ_IS_LOADABLE_MODULE 0
+#define BEGINObjClassInit(objName, objVers, objType) \
rsRetVal objName##ClassInit(void) \
{ \
DEFiRet; \
- CHKiRet(objInfoConstruct(&pObjInfoOBJ, OBJ##objName, (uchar*) #objName, objVers, \
+ if(objType == OBJ_IS_CORE_MODULE) { \
+ CHKiRet(objGetObjInterface(&obj)); /* this provides the root pointer for all other queries */ \
+ } \
+ CHKiRet(obj.InfoConstruct(&pObjInfoOBJ, OBJ##objName, (uchar*) #objName, objVers, \
(rsRetVal (*)(void*))objName##Construct, (rsRetVal (*)(void*))objName##Destruct));
#define ENDObjClassInit(objName) \
- objRegisterObj(OBJ##objName, pObjInfoOBJ); \
+ obj.RegisterObj(OBJ##objName, pObjInfoOBJ); \
finalize_it: \
RETiRet; \
}
@@ -220,25 +230,25 @@ finalize_it: \
* processing.
* rgerhards, 2008-01-30
*/
-#define BEGINobjDestruct(obj) \
- rsRetVal obj##Destruct(obj##_t **ppThis) \
+#define BEGINobjDestruct(OBJ) \
+ rsRetVal OBJ##Destruct(OBJ##_t **ppThis) \
{ \
DEFiRet; \
int iCancelStateSave; \
- obj##_t *pThis;
+ OBJ##_t *pThis;
-#define CODESTARTobjDestruct(obj) \
+#define CODESTARTobjDestruct(OBJ) \
ASSERT(ppThis != NULL); \
pThis = *ppThis; \
- ISOBJ_TYPE_assert(pThis, obj); \
+ ISOBJ_TYPE_assert(pThis, OBJ); \
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave);
-#define ENDobjDestruct(obj) \
+#define ENDobjDestruct(OBJ) \
goto finalize_it; /* prevent compiler warning ;) */ \
/* no more code here! */ \
finalize_it: \
if(pThis != NULL) { \
- objDestructObjSelf((obj_t*) pThis); \
+ obj.DestructObjSelf((obj_t*) pThis); \
free(pThis); \
*ppThis = NULL; \
} \