Go to the documentation of this file.00001
00002
00003
00004
00005
00009
00010 #ifndef lgrCheckpointPolicy_H_
00011 #define lgrCheckpointPolicy_H_
00012
00013 #include "lgrCore.h"
00014
00015 #include "absoluteTime.h"
00016 #include "filePosition.h"
00017 #include "observe.h"
00018 #include "virtualConstructor.h"
00019
00020 namespace MAKLogger
00021 {
00022 class DtLgrFileOutput;
00023 class DtPacket;
00024 class DtMessageState;
00025
00028 class DT_DLL_LGRCORE DtCheckpointPolicy
00029 {
00030 public:
00031 DT_PURE_VIRTUAL_CTR(DtCheckpointPolicy,())
00032
00033
00034 virtual ~DtCheckpointPolicy();
00035
00036
00037 enum Policy
00038 {
00039 ByCount,
00040 BySize,
00041 ByTime
00042 };
00043
00044
00045 private:
00047 DtCheckpointPolicy(const DtCheckpointPolicy&);
00049 DtCheckpointPolicy& operator=(const DtCheckpointPolicy&);
00050 public:
00051
00056 virtual bool timeForCheckpoint() const = 0;
00057
00059 virtual void reset() = 0;
00060
00062 virtual void checkpointWritten() = 0;
00063
00066 virtual void packetWritten(const DtPacket&) = 0;
00067
00069 virtual void connectFileOutput(DtMessageState*,DtLgrFileOutput*);
00070
00071 protected:
00072
00073 void onPacketWritten(const DtPacket&);
00074
00076 typedef DtObserverFunctor<DtCheckpointPolicy,DtPacket> PacketObserverFunctor;
00077
00078 PacketObserverFunctor myPacketWrittenObserver;
00079
00080
00081
00082 DtMessageState* myMessageState;
00083 DtLgrFileOutput* myLgrFileOutput;
00084 };
00085
00088 class DT_DLL_LGRCORE DtCheckpointBySize : public DtCheckpointPolicy
00089 {
00090 public:
00091 DT_VIRTUAL_CTR(DtCheckpointBySize,(size_t size))
00092 DT_VIRTUAL_BASE_CTR(DtCheckpointPolicy,(size_t size))
00093
00094
00095 virtual ~DtCheckpointBySize();
00096
00097 private:
00099 DtCheckpointBySize(const DtCheckpointBySize&);
00101 DtCheckpointBySize& operator=(const DtCheckpointBySize&);
00102 public:
00103
00109 virtual bool timeForCheckpoint() const;
00110
00112 virtual void reset();
00113
00115 virtual size_t sizeBetweenCheckpoints() const;
00116
00118 virtual void checkpointWritten();
00119
00121 virtual void packetWritten(const DtPacket&);
00122
00123 protected:
00124
00126 size_t myCheckpointSize;
00127
00129 size_t myCurrentDataSize;
00130 };
00131
00134 class DT_DLL_LGRCORE DtCheckpointByCount : public DtCheckpointPolicy
00135 {
00136 public:
00137 DT_VIRTUAL_CTR(DtCheckpointByCount,(int count))
00138 DT_VIRTUAL_BASE_CTR(DtCheckpointPolicy,(int count))
00139
00140
00141 virtual ~DtCheckpointByCount();
00142
00148 virtual bool timeForCheckpoint() const;
00149
00151 virtual void reset();
00152
00154 virtual void checkpointWritten();
00155
00157 virtual void packetWritten(const DtPacket&);
00158
00159 protected:
00161 int myCheckpointCount;
00162
00164 int myCurrentPacketsCount;
00165 };
00166
00169 class DT_DLL_LGRCORE DtCheckpointByTime : public DtCheckpointPolicy
00170 {
00171 public:
00172 DT_VIRTUAL_CTR(DtCheckpointByTime,(DtRelativeTime time))
00173 DT_VIRTUAL_BASE_CTR(DtCheckpointPolicy,(DtRelativeTime time))
00174
00175
00176 virtual ~DtCheckpointByTime();
00177
00182 virtual bool timeForCheckpoint() const;
00183
00185 virtual void reset();
00186
00188 virtual void checkpointWritten();
00189
00191 virtual void packetWritten(const DtPacket&);
00192
00193 protected:
00194
00197 DtRelativeTime myCheckpointTime;
00198
00199 DtAbsoluteTime myLastCheckpointTime;
00201 DtAbsoluteTime myLastPacketTime;
00202 };
00203 }
00204
00205 #endif