00001 #ifndef QPID_CLIENT_MESSAGEREPLAYTRACKER_H
00002 #define QPID_CLIENT_MESSAGEREPLAYTRACKER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "AsyncSession.h"
00025 #include "Message.h"
00026
00027 #include <list>
00028 #include <string>
00029
00030 namespace qpid {
00031 namespace client {
00032
00037 class MessageReplayTracker
00038 {
00039 public:
00040 MessageReplayTracker(uint flushInterval);
00041 void send(const Message& message, const std::string& destination = "");
00042 void init(AsyncSession session);
00043 void replay(AsyncSession session);
00044 void setFlushInterval(uint interval);
00045 uint getFlushInterval();
00046 void checkCompletion();
00047
00048 template <class F> void foreach(F& f) {
00049 for (std::list<ReplayRecord>::const_iterator i = buffer.begin(); i != buffer.end(); i++) {
00050 f(i->message);
00051 }
00052 }
00053
00054 private:
00055 struct ReplayRecord
00056 {
00057 Completion status;
00058 Message message;
00059 std::string destination;
00060
00061 ReplayRecord(const Message& message, const std::string& destination);
00062 void send(MessageReplayTracker&);
00063 bool isComplete();
00064 };
00065
00066 AsyncSession session;
00067 uint flushInterval;
00068 uint count;
00069 std::list<ReplayRecord> buffer;
00070 };
00071 }}
00072
00073 #endif