Go to the previous, next section.
#include <nihcl/LookupKey.h>
Class
LookupKey
serves as a base class for derived classes such as
Assoc
and
AssocInt
that provide associations between
key objects
and
value objects. An instance of class
LookupKey
holds a pointer to the key object of an association, defines the virtual function
key()
for accessing the key object of the association, and declares the virtual function
value()
(which derived classes must implement) for accessing the value object of the association.
Class
LookupKey
implements the virtual member functions
compare()
,
isEqual()
, and
hash()
by applying the corresponding operation to the key object. Since a
LookupKey
behaves the same as the key object with respect to these functions, you can substitute a
LookupKey
in place of its key object for any of these operations.
LookupKey(Object&
newKey
=*nil)
LookupKey
, initializing its key object pointer to
newKey.
virtual Object* key() const
LookupKey
.
virtual Object* key(Object&
newKey)
LookupKey
to
newKey, and returns the
previous
key object pointer.
virtual Object* value()
virtual const Object* value() const
LookupKey
.
LookupKey::value()
is implemented as a
derivedClassResponsibility()
.
virtual Object* value(Object&
newValue)
LookupKey
to
newValue, and returns the
previous
value object pointer.
LookupKey::value(Object&)
is implemented as a
derivedClassResponsibility()
.
virtual unsigned hash() const
hash()
to the key object of this
LookupKey
.
virtual int compare(const Object&
ob) const
compare()
to the argument object
ob
with the key object of this
LookupKey
as the argument to
compare()
; that is,
LookupKey::compare()
is implemented as:
int LookupKey::compare(const Object& ob) const { return -ob.compare(*akey); }
The comparison is done this way to permit
ob
to be a
LookupKey
.
virtual bool isEqual(const Object&
ob) const
isEqual()
to the argument object
ob
with the key object of this
LookupKey
as the argument to
isEqual()
; that is,
LookupKey::isEqual()
is implemented as:
bool LookupKey::isEqual(const Object& ob) const { return ob.isEqual(*akey); }
The comparison is done this way to permit
ob
to be a
LookupKey
.
virtual void deepenShallowCopy()
deepCopy()
to the key object pointer of this
LookupKey
, replacing the key object pointer by the pointer to its copy.
virtual void dumpOn(ostream&
strm
=cerr) const
LookupKey
on the output stream
strm. Prints the class name of this
LookupKey
, prints a
`[', applies
dumpOn()
to this
LookupKey
's key object, prints
`=>', applies
dumpOn()
to this
LookupKey
's value object, and prints
`]\n'.
virtual void printOn(ostream&
strm
=cout) const
LookupKey
on the output stream
strm. Applies
dumpOn()
to this
LookupKey
's key object, prints
`=>', and applies
dumpOn()
to this
LookupKey
's value object.
virtual void storer(OIOofd&
fd) const
virtual void storer(OIOout&
strm) const
LookupKey
to
fd
or
strm
by applying
storeOn()
to the key object.
Go to the previous, next section.