00001 /*---------------------------------------------------------------------------- 00002 Name: XmlBlasterAccessUnparsed.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: This combines the sync xmlBlaster access (XmlBlasterConnectionUnparsed.h) 00006 with the pure callback implementation (CallbackServerUnparsed.h) 00007 and adds threading to allow simultaneous access and callbacks. 00008 00009 Include this header in your client code. 00010 00011 The returned strings are not parsed, we need another layer 00012 doing XML parsing with expat. 00013 This library is thread safe, multiple client connections may 00014 be established in parallel. 00015 Author: "Marcel Ruff" <xmlBlaster@marcelruff.info> 00016 Date: 05/2003 00017 See: http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.html 00018 -----------------------------------------------------------------------------*/ 00019 #ifndef _XmlBlasterAccessUnparsed_H 00020 #define _XmlBlasterAccessUnparsed_H 00021 00022 #ifdef __cplusplus 00023 #ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */ 00024 extern "C" { 00025 #endif 00026 #endif 00027 00028 #include <util/msgUtil.h> 00029 #include <util/Properties.h> 00030 #include <XmlBlasterConnectionUnparsed.h> 00031 #include <CallbackServerUnparsed.h> 00032 00033 #ifdef XB_USE_PTHREADS 00034 # ifdef _WINDOWS 00035 # include <pthreads/pthread.h> /* Our pthreads.h: For logging output of thread ID, for Windows and WinCE downloaded from http://sources.redhat.com/pthreads-win32 */ 00036 # else 00037 # include <pthread.h> /* The original pthreads.h from the OS */ 00038 # endif 00039 #endif 00040 00041 /* The following comment is used by doxygen for the main html page: */ 00075 /* 00076 NOTE: The struct name and the later typedef name are identical, we need this 00077 to allow in C++ SocketDriver.h a forward declaration of the XmlBlasterAccessUnparsed* 00078 pointer (to avoid inclusion of this complete header) 00079 */ 00080 struct XmlBlasterAccessUnparsed; 00081 00082 typedef XMLBLASTER_C_bool (*UpdateFp)(MsgUnitArr *msg, void *userData, XmlBlasterException *xmlBlasterException); 00083 00084 /* Declare function pointers to use in struct to simulate object oriented access */ 00085 typedef char *( * XmlBlasterAccessUnparsedConnect)(struct XmlBlasterAccessUnparsed *xb, const char * const qos, UpdateFp update, XmlBlasterException *exception); 00086 typedef bool ( * XmlBlasterAccessUnparsedInitialize)(struct XmlBlasterAccessUnparsed *xa, UpdateFp update, XmlBlasterException *exception); 00087 typedef bool ( * XmlBlasterAccessUnparsedDisconnect)(struct XmlBlasterAccessUnparsed *xb, const char * qos, XmlBlasterException *exception); 00088 typedef char *( * XmlBlasterAccessUnparsedPublish)(struct XmlBlasterAccessUnparsed *xb, MsgUnit *msgUnit, XmlBlasterException *exception); 00089 typedef QosArr *( * XmlBlasterAccessUnparsedPublishArr)(struct XmlBlasterAccessUnparsed *xb, MsgUnitArr *msgUnitArr, XmlBlasterException *exception); 00090 typedef void ( * XmlBlasterAccessUnparsedPublishOneway)(struct XmlBlasterAccessUnparsed *xb, MsgUnitArr *msgUnitArr, XmlBlasterException *exception); 00091 typedef char *( * XmlBlasterAccessUnparsedSubscribe)(struct XmlBlasterAccessUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception); 00092 typedef QosArr *( * XmlBlasterAccessUnparsedUnSubscribe)(struct XmlBlasterAccessUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception); 00093 typedef QosArr *( * XmlBlasterAccessUnparsedErase)(struct XmlBlasterAccessUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception); 00094 typedef MsgUnitArr *( * XmlBlasterAccessUnparsedGet)(struct XmlBlasterAccessUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception); 00095 typedef char *( * XmlBlasterAccessUnparsedPing)(struct XmlBlasterAccessUnparsed *xb, const char * const qos, XmlBlasterException *exception); 00096 typedef bool ( * XmlBlasterAccessUnparsedIsConnected)(struct XmlBlasterAccessUnparsed *xb); 00097 00098 typedef void ( * XmlBlasterAccessGenericFp)(); 00099 00116 typedef struct Dll_Export XmlBlasterAccessUnparsed { 00117 /* public: */ 00118 int argc; 00119 const char * const *argv; 00120 Properties *props; 00121 void *userObject; 00122 XmlBlasterAccessGenericFp userFp; 00146 XmlBlasterAccessUnparsedConnect connect; 00155 XmlBlasterAccessUnparsedInitialize initialize; 00164 XmlBlasterAccessUnparsedDisconnect disconnect; 00176 XmlBlasterAccessUnparsedPublish publish; 00188 XmlBlasterAccessUnparsedPublishArr publishArr; 00202 XmlBlasterAccessUnparsedPublishOneway publishOneway; 00215 XmlBlasterAccessUnparsedSubscribe subscribe; 00216 XmlBlasterAccessUnparsedUnSubscribe unSubscribe; 00217 XmlBlasterAccessUnparsedErase erase; 00218 XmlBlasterAccessUnparsedGet get; 00219 XmlBlasterAccessUnparsedPing ping; 00225 XmlBlasterAccessUnparsedIsConnected isConnected; 00226 XMLBLASTER_LOG_LEVEL logLevel; 00227 XmlBlasterLogging log; 00228 void *logUserP; 00229 /* private: */ 00230 XmlBlasterConnectionUnparsed *connectionP; 00231 CallbackServerUnparsed *callbackP; 00232 bool isInitialized; 00233 bool isShutdown; 00254 UpdateFp clientsUpdateFp; 00255 00256 bool callbackMultiThreaded; 00257 bool lowLevelAutoAck; 00258 long responseTimeout; 00259 pthread_t callbackThreadId; 00260 char threadCounter; 00261 pthread_mutex_t writenMutex; 00262 pthread_mutex_t readnMutex; 00263 } XmlBlasterAccessUnparsed; 00264 00279 Dll_Export extern XmlBlasterAccessUnparsed *getXmlBlasterAccessUnparsed(int argc, const char* const* argv); 00280 00284 Dll_Export extern void freeXmlBlasterAccessUnparsed(XmlBlasterAccessUnparsed *xmlBlasterAccess); 00285 00291 Dll_Export extern const char *xmlBlasterAccessUnparsedUsage(char *usage); 00292 00293 #ifdef __cplusplus 00294 #ifndef XMLBLASTER_C_COMPILE_AS_CPP 00295 } 00296 #endif 00297 #endif 00298 00299 #endif /* _XmlBlasterAccessUnparsed_H */ 00300