5 #include <libutl/FlagsMI.h> 36 return getFlag(flg_owner);
43 setFlag(flg_owner, owner);
58 virtual bool eval(
const Object*
object)
const = 0;
125 if ((_rtc ==
nullptr) || (
object ==
nullptr))
return false;
126 return object->_isA(_rtc);
198 setObject(
object.
clone());
207 if (isOwner())
delete _object;
208 _object =
const_cast<Object*
>(object);
302 if (isOwner())
delete _lhs;
303 _lhs =
const_cast<Object*
>(lhs);
320 if (isOwner())
delete _rhs;
321 _rhs =
const_cast<Object*
>(rhs);
332 _lhs = _rhs =
nullptr;
407 _ordering = ordering.clone();
415 _ordering = ordering;
464 if ((_object ==
nullptr) || (
object ==
nullptr))
return false;
465 return !utl::cast<Predicate>(_object)->eval(
object);
520 return lhs()->eval(
object) && rhs()->eval(
object);
527 return utl::cast<Predicate>(_lhs);
534 return utl::cast<Predicate>(_rhs);
589 return lhs()->eval(
object) || rhs()->eval(
object);
596 return utl::cast<Predicate>(_lhs);
603 return utl::cast<Predicate>(_rhs);
659 return (cmp(
object) == 0);
715 return (cmp(
object) < 0);
772 return (cmp(
object) <= 0);
828 return (cmp(
object) > 0);
889 return (cmp(
object) >= 0);
930 return utl::Or(lhs, rhs,
false);
bool isOwner() const
Get the ownership flag.
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
T * clone(const T *object)
Create a clone of the given object.
bool operator()(const Object *object) const
Another way of writing eval.
void serialize(bool &b, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a boolean.
EqualTo(const Object *object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
Or(const Predicate *lhs, const Predicate *rhs, bool owner=true)
Constructor.
LessThan(const Object *object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
void deInit()
De-initialize UTL++.
const Object * getLHS() const
Get the left-hand-side parameter.
Object comparison abstraction.
const Predicate * rhs() const
Get the right-hand-side predicate.
Less-Than-Or-Equal-To predicate.
virtual bool eval(const Object *object) const
The object satisfies the predicate iff it is greater than the associated object.
LessThanOrEqualTo(const Object &object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
Abstraction for two-parameter predicates.
void setOrdering(Ordering *ordering)
Set the ordering.
default representation (via getSerializeMode())
const Predicate * lhs() const
Get the left-hand-side predicate.
Store information about a class.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
void setRHS(const Object *rhs)
Set the right-hand-side parameter.
Mix-in to provide 64-bits for space-efficient storage of up to 64 boolean flags.
void clear()
See Object::clear().
GreaterThan(const Object &object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
utl::Or operator||(const utl::Predicate &lhs, const utl::Predicate &rhs)
(Predicate || Predicate) constructs an instance of the Or predicate.
virtual bool eval(const Object *object) const
Determine whether the given object is derived from the class.
const Predicate * rhs() const
Get the right-hand-side predicate.
ComparisonPredicate(const Object &object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
void setRHS(const Object &lhs)
Set the right-hand-side parameter (make a copy if isOwner() = true).
Abstraction for comparison predicates.
Abstraction for single-parameter predicates.
virtual bool eval(const Object *object) const
The object satisfies the predicate iff it satisfies both the sub-predicates.
virtual bool eval(const Object *object) const
The object satisfies the predicate iff it is less than or equal to the associated object...
utl::Not operator!(const utl::Predicate &pred)
(! Predicate) constructs an instance of the Not predicate.
void setOrdering(const Ordering &ordering)
Set the ordering to a copy of the given ordering.
const Object * getObject() const
Get the parameter.
void setObject(const Object *object)
Set the parameter.
const Ordering * ordering() const
Get the ordering.
LessThanOrEqualTo(const Object *object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
Logical predicate abstraction.
virtual bool eval(const Object *object) const
The object satisfies the predicate iff it is equal to the associated object.
void clear()
See Object::clear.
GreaterThanOrEqualTo(const Object *object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
GreaterThan(const Object *object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
#define UTL_CLASS_DECL_ABC(DC, BC)
Declaration of standard UTL++ functionality for an abstract base class (ABC).
EqualTo(const Object &object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
int compareNullable(const Object *lhs, const Object *rhs, const Ordering *ordering=nullptr)
Compare two objects.
unsigned int uint_t
Unsigned integer.
void setOwner(bool owner)
Set the ownership flag.
Or(const Predicate &lhs, const Predicate &rhs, bool owner=true)
Constructor.
const Predicate * lhs() const
Get the left-hand-side predicate.
GreaterThanOrEqualTo(const Object &object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
IsA(const RunTimeClass *rtc)
Constructor.
virtual bool eval(const Object *object) const
The object satisfies the predicate iff it is less than the associated object.
void setObject(const Object &object)
Set the parameter (make a copy if isOwner() = true).
void setLHS(const Object *lhs)
Set the left-hand-side parameter.
int cmp(const Object *object) const
Compare the given object with self's object.
void setLHS(const Object &lhs)
Set the left-hand-side parameter (make a copy if isOwner() = true).
ComparisonPredicate(const Object *object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
utl::And operator &&(const utl::Predicate &lhs, const utl::Predicate &rhs)
(Predicate && Predicate) constructs an instance of the And predicate.
Greater-Than-Or-Equal-To predicate.
Root of UTL++ class hierarchy.
int compare(bool lhs, bool rhs)
Compare two boolean values.
virtual bool eval(const Object *object) const
The object satisfies the predicate iff it satisfies at least one of the sub-predicates.
virtual bool eval(const Object *object) const
The object satisfies the predicate iff it is greater than or equal to the associated object...
void init()
Initialize UTL++.
const Object * getRHS() const
Get the right-hand-side parameter.
And(const Predicate *lhs, const Predicate *rhs, bool owner=true)
Constructor.
And(const Predicate &lhs, const Predicate &rhs, bool owner=true)
Constructor.
LessThan(const Object &object, bool owner=true, const Ordering *ordering=nullptr)
Constructor.
virtual bool eval(const Object *object) const
Evaluate the predicate for the given object.