src_other/tuplebase/ZTSWatcher.h

00001 /*  @(#) $Id: ZTSWatcher.h,v 1.11 2007/07/15 20:29:53 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2005 Andrew Green and Learning in Motion, Inc.
00005 http://www.zoolib.org
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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__

Generated on Thu Jul 26 11:21:59 2007 for ZooLib by  doxygen 1.4.7