00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXCPPXSDELEMENT_H_
00029 #define _RTXCPPXSDELEMENT_H_
00030
00031 #include "rtxsrc/rtxCppContext.h"
00032 #include "rtxsrc/rtxCppMsgBufIF.h"
00033
00041 class EXTERNRTX OSXSDGlobalElement {
00042 protected:
00049 OSCtxtPtr mpContext;
00050
00055 OSMessageBufferIF* mpMsgBuf;
00056
00061 OSXSDGlobalElement () : mpMsgBuf (0), mpContext (new OSContext()) {}
00062
00069 OSXSDGlobalElement (OSContext& ctxt) : mpContext (&ctxt), mpMsgBuf (0) {}
00070
00077 void setMsgBuf (OSMessageBufferIF& msgBuf);
00078
00079 public:
00089 OSXSDGlobalElement (OSMessageBufferIF& msgBuf) : mpMsgBuf(&msgBuf) {
00090 mpContext = msgBuf.getContext();
00091 }
00092
00100 OSXSDGlobalElement (const OSXSDGlobalElement& o) :
00101 mpContext (o.mpContext), mpMsgBuf (o.mpMsgBuf) { }
00102
00107 virtual ~OSXSDGlobalElement () {}
00108
00113 inline int decode () { return decodeFrom (*mpMsgBuf); }
00114
00122 virtual int decodeFrom (OSMessageBufferIF& msgBuf) { return 0; }
00123
00128 inline int encode () { return encodeTo (*mpMsgBuf); }
00129
00137 virtual int encodeTo (OSMessageBufferIF& msgBuf) { return 0; }
00138
00143 inline OSCTXT* getCtxtPtr () {
00144 return (!mpContext.isNull ()) ? mpContext->getPtr() : 0;
00145 }
00146
00156 inline void* memAlloc (size_t numocts) {
00157 return rtxMemAlloc (getCtxtPtr(), numocts);
00158 }
00159
00170 inline void* memRealloc (void* ptr, size_t oldnumocts, size_t numocts) {
00171 return rtxMemRealloc (getCtxtPtr(), ptr, oldnumocts, numocts);
00172 }
00173
00182 inline void memFreePtr (void* ptr) {
00183 rtxMemFreePtr (getCtxtPtr(), ptr);
00184 }
00185
00192 inline void setDefaultNamespace (const OSUTF8CHAR* uri) {
00193 setNamespace (0, uri);
00194 }
00195
00203 inline void setNamespace (const OSUTF8CHAR* prefix, const OSUTF8CHAR* uri) {
00204 mpMsgBuf->setNamespace (prefix, uri);
00205 }
00206
00207 } ;
00208
00209 #endif