src_other/tuplebase/ZTupleIndex.h

00001 /*  @(#) $Id: ZTupleIndex.h,v 1.21 2007/02/14 23:28:03 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2003 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 __ZTupleIndex__
00026 #define __ZTupleIndex__
00027 #include "zconfig.h"
00028 
00029 #include "ZTBSpec.h"
00030 
00031 #include <deque>
00032 #include <list>
00033 #include <set>
00034 #include <vector>
00035 
00036 #ifndef ZCONFIG_TupleIndex_Debug
00037 #       define ZCONFIG_TupleIndex_Debug 3
00038 #endif
00039 
00040 class ZStrimW;
00041 
00042 // =================================================================================================
00043 #pragma mark -
00044 #pragma mark * ZTupleIndex
00045 
00046 class ZTupleIndex
00047         {
00048 public:
00049         static const uint64 kMaxID = 0xFFFFFFFFFFFFFFFFULL;
00050 
00051         virtual ~ZTupleIndex();
00052 
00053         virtual void Add(uint64 iID, const ZTuple* iTuple) = 0;
00054 
00055         virtual void Remove(uint64 iID, const ZTuple* iTuple) = 0;
00056 
00057         virtual void Find(const std::set<uint64>& iSkipIDs,
00058                 std::vector<const ZTBSpec::Criterion*>& ioCriteria, std::vector<uint64>& oIDs) = 0;
00059 
00060         virtual size_t CanHandle(const ZTBSpec::CriterionSect& iCriterionSect) = 0;
00061 
00062         void Find(const ZTBSpec::CriterionSect& iCriterionSect, const std::set<uint64>& iSkipIDs,
00063                 std::vector<const ZTBSpec::Criterion*>& oUncheckedCriteria, std::vector<uint64>& oIDs);
00064 
00065         virtual void WriteDescription(const ZStrimW& s);
00066 
00067         static bool sMatchIndices(const ZTBSpec::CriterionUnion& iCriterionUnion,
00068                 const std::vector<ZTupleIndex*>& iIndices, std::vector<ZTupleIndex*>& oIndices);
00069 
00070         static bool sGatherMergeConstraints(const ZTuplePropName& iPropName,
00071                 vector<const ZTBSpec::Criterion*>& ioCriteria,
00072                 const ZTupleValue*& oValueEqual,
00073                 const ZTupleValue*& oBestValueLess, const ZTupleValue*& oBestValueLessEqual,
00074                 const ZTupleValue*& oBestValueGreater, const ZTupleValue*& oBestValueGreaterEqual);
00075         };
00076 
00077 // =================================================================================================
00078 #pragma mark -
00079 #pragma mark * ZTupleIndexFactory
00080 
00081 class ZTupleIndexFactory : public ZRefCounted
00082         {
00083 public:
00084         virtual ~ZTupleIndexFactory();
00085         virtual ZTupleIndex* Make() = 0;
00086         };
00087 
00088 #endif // __ZTupleIndex__

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