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 #ifndef __ZTSWatcher__
00026 #define __ZTSWatcher__
00027 #include "zconfig.h"
00028
00029 #include "ZCompat_NonCopyable.h"
00030 #include "ZMemoryBlock.h"
00031 #include "ZTBQuery.h"
00032
00033 #include <map>
00034 #include <set>
00035 #include <vector>
00036
00037 class ZMemoryBlock;
00038
00039
00040 #pragma mark -
00041 #pragma mark * ZTSWatcher
00042
00043 class ZTSWatcher : public ZRefCountedWithFinalization, ZooLib::NonCopyable
00044 {
00045 protected:
00046 ZTSWatcher();
00047
00048 public:
00049 virtual bool AllocateIDs(size_t iCount, uint64& oBaseID, size_t& oCountIssued) = 0;
00050
00051 struct AddedQueryCombo
00052 {
00053 public:
00054 AddedQueryCombo()
00055 {}
00056
00057 AddedQueryCombo(size_t iSize)
00058 : fMemoryBlock(iSize)
00059 {}
00060
00061 inline bool operator<(const AddedQueryCombo& iOther) const
00062 { return fRefcon < iOther.fRefcon; }
00063
00064 int64 fRefcon;
00065 bool fPrefetch;
00066 ZMemoryBlock fMemoryBlock;
00067 ZTBQuery fTBQuery;
00068 };
00069
00070 virtual bool Sync(
00071 const uint64* iRemovedIDs, size_t iRemovedIDsCount,
00072 const uint64* iAddedIDs, size_t iAddedIDsCount,
00073 const int64* iRemovedQueries, size_t iRemovedQueriesCount,
00074 const AddedQueryCombo* iAddedQueries, size_t iAddedQueriesCount,
00075 std::vector<uint64>& oAddedIDs,
00076 std::vector<uint64>& oChangedTupleIDs, std::vector<ZTuple>& oChangedTuples,
00077 const uint64* iWrittenTupleIDs, const ZTuple* iWrittenTuples, size_t iWrittenTuplesCount,
00078 std::map<int64, std::vector<uint64> >& oChangedQueries) = 0;
00079
00080 typedef void (*Callback_t)(void* iRefcon);
00081 virtual void SetCallback(Callback_t iCallback, void* iRefcon) = 0;
00082 };
00083
00084 #endif // __ZTSWatcher__