00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00046
00047 #ifndef __B2BITS_Engine_V12_FIXMessage_h__
00048 #define __B2BITS_Engine_V12_FIXMessage_h__
00049
00050 #include <string>
00051 #include <vector>
00052 #include <set>
00053
00054 #include "B2BITS_V12_Defines.h"
00055 #include "B2BITS_PubEngineDefines.h"
00056 #include "B2BITS_TagValue.h"
00057 #include "B2BITS_AutoPtr.h"
00058
00059 namespace Engine
00060 {
00062 class FIXMessageEx;
00063
00065 struct FIXFieldValue;
00066
00068 class SecurityAttributes;
00069
00071 class FIXGroup;
00072
00074 class V12_API FIXMessage: public virtual TagValue
00075 {
00076 public:
00078 FIXMessage();
00079
00081 virtual ~FIXMessage();
00082
00087 virtual const std::string* getSender() const = 0;
00088
00093 virtual void setSender(const std::string& senderCompID) = 0;
00094
00099 virtual const std::string* getTarget() const = 0;
00100
00105 virtual void setTarget(const std::string& targetCompID) = 0;
00106
00111 virtual const int getSeqNum() const = 0;
00112
00117 virtual const std::string* getType() const = 0;
00118 virtual AsciiString type() const { return *getType(); }
00119
00126 virtual bool setSeqNum(int msgSeqNum) = 0;
00127
00132 virtual int getHeartBeatInterval() const = 0;
00133
00140 virtual bool setHeartBeatInterval(int hbi) = 0;
00141
00148 virtual bool isOriginal() const = 0;
00149
00154 virtual bool isBusinessMsgRejectMsg() const = 0;
00155
00160 virtual bool isSessionLevelRejectMsg() const = 0;
00161
00166 virtual bool isAdministrativeMsg() const = 0;
00167
00173 virtual const std::string *toString(char substChar = ' ') const = 0;
00174
00182 virtual const char* toRaw(int* size) const = 0;
00183
00193 virtual const char* getBuffer(int* size,
00194 SecurityAttributes* sa = NULL) const = 0;
00195
00199 virtual FIXVersion getVer() const = 0;
00200
00204 virtual FIXVersion getApplicationVersion() const = 0;
00205
00209 virtual FIXVersion getSessionVersion() const = 0;
00210
00214 virtual void release()const = 0;
00215
00225 static void release(FIXMessage const* msg);
00226
00228 void *operator new(size_t size);
00229
00231 void operator delete(void *obj);
00232
00233
00235 virtual FIXMessageEx* extend() = 0;
00236
00238 virtual FIXMessageEx const* extend() const = 0;
00239 };
00240
00244 void V12_API removeCustomFields(FIXMessage *msg);
00245 }
00246
00247 namespace Utils{
00248
00250 template <>
00251 class AutoPtr<Engine::FIXMessage>
00252 {
00253 public:
00255 typedef void (Engine::FIXMessage::*ReleaseMethod)()const;
00256
00258 AutoPtr() : releaseMethod_(NULL), ptr_(NULL) { }
00259
00263 AutoPtr(const Engine::FIXMessage *ptr, ReleaseMethod releaseMethod) : releaseMethod_(releaseMethod), ptr_(ptr)
00264 {
00265 }
00266
00268 AutoPtr(AutoPtr<Engine::FIXMessage> & ptr)
00269 {
00270 reset(ptr.ptr_, ptr.releaseMethod_);
00271
00272 ptr.ptr_ = NULL;
00273 ptr.releaseMethod_ = NULL;
00274 }
00275
00277 AutoPtr & operator=(AutoPtr<Engine::FIXMessage> & ptr)
00278 {
00279 reset(ptr.ptr_, ptr.releaseMethod_);
00280
00281 ptr.ptr_ = NULL;
00282 ptr.releaseMethod_ = NULL;
00283
00284 return *this;
00285 }
00286
00288 ~AutoPtr()
00289 {
00290 if (ptr_ != NULL)
00291 (ptr_->*releaseMethod_)();
00292 }
00293
00296 Engine::FIXMessage *release()
00297 {
00298 releaseMethod_ = NULL;
00299
00300 Engine::FIXMessage *ptr = const_cast<Engine::FIXMessage *>(ptr_);
00301 ptr_ = NULL;
00302
00303 return ptr;
00304 }
00305
00309 void reset(const Engine::FIXMessage *ptr, ReleaseMethod releaseMethod)
00310 {
00311 if (ptr_ != NULL)
00312 (ptr_->*releaseMethod_)();
00313
00314 ptr_ = ptr;
00315 releaseMethod_ = releaseMethod;
00316 }
00317
00320 Engine::FIXMessage *get() const
00321 {
00322 return const_cast<Engine::FIXMessage *>(ptr_);
00323 }
00324
00326 Engine::FIXMessage & operator*()
00327 {
00328 return *const_cast<Engine::FIXMessage *>(ptr_);
00329 }
00330
00332 Engine::FIXMessage** operator&()
00333 {
00334 return const_cast<Engine::FIXMessage **>(&ptr_);
00335 }
00336
00338 Engine::FIXMessage *operator->()
00339 {
00340 return get();
00341 }
00342
00343 private:
00345 ReleaseMethod releaseMethod_;
00346
00348 const Engine::FIXMessage *ptr_;
00349 };
00350
00351 }
00352
00353 #endif