ZTBSpec Class Reference
[TuplebaseTuplesoupTuplestore]

Represents criteria to be matched against tuples. More...

#include <ZTBSpec.h>

List of all members.

Canonical methods

 ZTBSpec ()
 Constructs a spec that will match no tuple.
 ZTBSpec (const ZTBSpec &iOther)
 Copy-construct from iOther.
ZTBSpecoperator= (const ZTBSpec &iOther)
 Assign from iOther.
 ~ZTBSpec ()
 Destructor.

Constructors

 ZTBSpec (bool iAny)
 Construct a spec that matches any (iAny == true) or no tuple.
 ZTBSpec (const Criterion &iCriterion)
 Construct a spec which appropriately matches a single property of a tuple.
 ZTBSpec (const ZTuplePropName &iPropName, ERel iRel, const ZTupleValue &iTV)
 ZTBSpec (const ZTuplePropName &iPropName, ERel iRel, int iStrength, const ZTupleValue &iTV)
 ZTBSpec (const ZTuplePropName &iPropName, Comparator iComparator, const ZTupleValue &iTV)
 ZTBSpec (const CriterionSect &iCriterionSect)
 Directly construct a spec which checks an intersection of criteria.

Conversion and assignment

 ZTBSpec (const ZTuple &iTuple)
 Construct from tuple-ized representation.
 ZTBSpec (const ZStreamR &iStreamR)
 Construct from serialized representation.
ZTuple AsTuple () const
 Return tuple-ized representation.
void ToStream (const ZStreamW &iStreamW) const
 Write serialized representation.

Combining operators

ZTBSpec operator & (const ZTBSpec &iOther) const
 Return a ZTBSpec being the intersection of this and iOther.
ZTBSpecoperator &= (const ZTBSpec &iOther)
 Update this to be the intersection of this and iOther.
ZTBSpec operator| (const ZTBSpec &iOther) const
 Return a ZTBSpec being the union of this and iOther.
ZTBSpecoperator|= (const ZTBSpec &iOther)
 Update this to be the union of this and iOther.

Pseudo constructors

Each returns a ZTBSpec that will match tuples satisfying the desired constraint. They're basically more readable wrappers for the ZTBSpec constructor taking a property name, comparator and ZTupleValue. Because ZTupleValue has conversion constructors taking the various supported types we don't suffer combinatorial explosion.

static ZTBSpec sAny ()
 Any tuple.
static ZTBSpec sNone ()
 No tuple.
static ZTBSpec sHas (const ZTuplePropName &iPropName)
 Tuples which have a property iPropName.
static ZTBSpec sHas (const ZTuplePropName &iPropName, ZType iType)
 Tuples which have a property iPropName of type iType.
static ZTBSpec sLacks (const ZTuplePropName &iPropName)
 Tuples which do not have a property iPropName.
static ZTBSpec sLacks (const ZTuplePropName &iPropName, ZType iType)
 Tuples which do not have a property iPropName or it is not of type iType.
static ZTBSpec sEquals (const ZTuplePropName &iPropName, const ZTupleValue &iValue)
 Tuples whose property iPropName has the value iValue.
static ZTBSpec sNotEqual (const ZTuplePropName &iPropName, const ZTupleValue &iValue)
 Tuples whose property iPropName is not the value iValue.
static ZTBSpec sLess (const ZTuplePropName &iPropName, const ZTupleValue &iValue)
 Tuples whose property iPropName is less than the value iValue.
static ZTBSpec sLessEqual (const ZTuplePropName &iPropName, const ZTupleValue &iValue)
 Tuples whose property iPropName is less than or equal to the value iValue.
static ZTBSpec sGreater (const ZTuplePropName &iPropName, const ZTupleValue &iValue)
 Tuples whose property iPropName is greater than the value iValue.
static ZTBSpec sGreaterEqual (const ZTuplePropName &iPropName, const ZTupleValue &iValue)
 Tuples whose property iPropName is greater than or equal to the value iValue.
static ZTBSpec sStringContains (const ZTuplePropName &iPropName, const std::string &iString, int iStrength)
 Tuples whose string property iPropName contains iString.
static ZTBSpec sVectorContains (const ZTuplePropName &iPropName, const ZTupleValue &iValue)
 Tuples whose vector property iPropName contains a value matching iValue.
static ZTBSpec sRegex (const ZTuplePropName &iPropName, const std::string &iRegex, int iStrength)
 Tuples whose string property iPropName matches the regex iRegex.

Public Types

typedef std::vector< CriterionCriterionSect
 List of Criterion, all of which must match a tuple.
typedef std::vector< CriterionSectCriterionUnion
 List of CriterionSect, one or more of which must match a tuple.
enum  ERel
 Enum for designation of a relationship.

Public Member Functions

bool Matches (const ZTuple &iTuple) const
 Return true if the spec matches iTuple.
bool IsAny () const
 Returns true if the spec will match any tuple.
bool IsNone () const
 Returns true if the spec will match no tuple.

Classes

class  Comparator
 Holds a <ZTBSpec::ERel, strength> pair. More...
class  Criterion
 Holds a <property name, ZTBSpec::Comparator, ZTupleValue> triple. More...


Detailed Description

Represents criteria to be matched against tuples.

See also:
Tuplebase

Tuplesoup

Tuplestore

Note:
Despite its name ZTBSpec, like ZTBQuery, knows nothing about tuplebases, tuplesoups or tuplestores. It's simply a way to create and manage a suite of criteria against which a tuple can be checked to determine if they're satisfied. As such it probably ought to be called ZTupleSpec or ZTSpec.
A ZTBSpec is constructed by providing a property name and a Criterion against which the named property of a candidate tuple should be tested. A ZTBSpec can also be constructed by intersecting two ZTBSpecs, or by unioning two ZTBSpecs.

A Criterion holds a property name, a comparator, and for binary comparators a value to be passed to it. The simplest comparators are Has and Lacks. They are unary, and simply check that the candidate tuple has, or lacks, a property with that name. All other comparators are binary, and check a candidate tuple's named property against a particular value.

The group documentation Tuplebase discusses in more detail how to construct ZTBSpecs from primitive values and comparators, and then to combine them using intersection (operator&) and union (operator|).

The underlying representation is a single ZTBSpec::CriterionUnion, which itself holds a list of ZTBSpec::CriterionSect, which holds a list of Criterion; it's the union of intersections of criteria.

A ZTBSpec::CriterionSect matches a tuple if all of its Criterion match the tuple, so if its list is empty then it matches any tuple.

A ZTBSpec::CriterionUnion matches a tuple if at least one of its ZTBSpec::CriterionSect matches the tuple. So a ZTBSpec::CriterionUnion containing no ZTBSpec::CriterionSect will match no tuples. A ZTBSpec::CriterionUnion containing a single ZTBSpec::CriterionSect which itself contains no Criterion will match any tuple.

The default ZTBSpec constructor creates a 'none' ZTBSpec, as does ZTBSpec::sNone, and ZTBSpec(bool iAny) with iAny = false.

An 'any' ZTBSpec can be constructed by calling ZTBSpec::sAny, or ZTBSpec(bool iAny) with iAny = true.

Some useful identities:


Constructor & Destructor Documentation

ZTBSpec::ZTBSpec ( const Criterion iCriterion  )  [explicit]

Construct a spec which appropriately matches a single property of a tuple.

Creates a spec which returns true from ZTBSpec::Matches when that candidate tuple's satisfies Criterion iCriterion.

ZTBSpec::ZTBSpec ( const ZTuplePropName &  iPropName,
ERel  iRel,
const ZTupleValue iTV 
)

Creates a spec which returns true from ZTBSpec::Matches when the candidate tuple's property named iPropName satisfies relationship iRel with respect to iTV.

ZTBSpec::ZTBSpec ( const ZTuplePropName &  iPropName,
ERel  iRel,
int  iStrength,
const ZTupleValue iTV 
)

Creates a spec which returns true from ZTBSpec::Matches when the candidate tuple's property named iPropName satisfies relationship iRel with strength iStrength with respect to iTV.

ZTBSpec::ZTBSpec ( const ZTuplePropName &  iPropName,
Comparator  iComparator,
const ZTupleValue iTV 
)

Creates a spec which returns true from ZTBSpec::Matches when the candidate tuple's property named iPropName satisfies Comparator iComparator with respect to iTV.

ZTBSpec::ZTBSpec ( const CriterionSect iCriterionSect  )  [explicit]

Directly construct a spec which checks an intersection of criteria.

Creates a spec which returns true from ZTBSpec::Matches when that candidate tuple's satisfies CriterionSect iCriterionSect.


The documentation for this class was generated from the following files:
Generated on Thu Jul 26 11:22:09 2007 for ZooLib by  doxygen 1.4.7