Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

MangoPtr::SharedValidity Class Reference

#include <SharedValidity.hh>

Inheritance diagram for MangoPtr::SharedValidity:

Inheritance graph
List of all members.

Detailed Description

A validator that can be shared (by several (objects, functions, etc).

A validator is either in a "true" or in a "false" state. It does not say what it is that is being validated. It is up to the user to maintain the association between an object's validity and the validator's state. Many objects can use the same validator. If the state of the validator is changed by one object, all other users see the new state if they query the SharedValidity via isValid().

Note that SharedValidity is an ADT. It cannot be created or destroyed. Rather, it is designed to provide all functionality that subclasses may desire, and be derived from with some of its protected methods publicized as appropriate. Some methods are public, like isValid() and swap(), since they don't change the state of the system. Some of those public methods are for debugging only and are only available if NDEBUG is -Defined.

Implementation note: The class is optimized to delay the cost of using a validator instance as long as possible. For instance, by default a validator is false, so no counter is allocated. A counter is allocated the first time it is shared.

Oliver Schoenborn
Mar 2002

Definition at line 31 of file SharedValidity.hh.

Public Methods

bool isValid () const
 Return true if representing valid value, false otherwise.

bool isShared () const
 Return true if this validator is being shared by other validators.

void swap (SharedValidity &rhs)
 Swap two shared validators; strong-exception safe.

Protected Methods

 SharedValidity ()
 Default: create unshared, false validator.

 SharedValidity (bool)
 Create a validator and set its validity value at construction.

 SharedValidity (const SharedValidity &)
 Share a validator.

SharedValidity & operator= (const SharedValidity &)
 Make *this equal to another SharedValidity.

 ~SharedValidity ()
 Free resources.

void reset (bool)
 Renew a validator.

void setValid (bool)
 Change the state of the validator.

Constructor & Destructor Documentation

MangoPtr::SharedValidity::SharedValidity bool    valid [inline, protected]

Create a validator and set its validity value at construction.

valid  initial value of validator (true for valid, false otherwise)

Definition at line 98 of file SharedValidity.hh.

References MangoPtr::NullPtr, and setValid().

MangoPtr::SharedValidity::SharedValidity const SharedValidity &    vv [inline, protected]

Share a validator.

This automatically increments the reference count. Though vv is const, its reference count is therefore also changed (since it is shared).

vv  the validator to copy

Definition at line 117 of file SharedValidity.hh.

References MangoPtr::isNotNull().

Member Function Documentation

SharedValidity & MangoPtr::SharedValidity::operator= const SharedValidity &    vv [inline, protected]

Make *this equal to another SharedValidity.

It is self-assignment safe, i.e. nothing is done if vv is *this. Also, it is safe is vv is already one that *this is sharing validity with.

vv  the shared validator to copy from
ref to *this

Reimplemented in MangoPtr::ValidityChecker.

Definition at line 133 of file SharedValidity.hh.

References MangoPtr::isNotNull().

void MangoPtr::SharedValidity::reset bool    valid [inline, protected]

Renew a validator.

This resets the validator as though it had just been created, ie unshared and false. Other validators that were sharing this state are NOT affected.

valid  state of validator

Definition at line 220 of file SharedValidity.hh.

References MangoPtr::isNotNull(), isShared(), MangoPtr::nullify(), and setValid().

Referenced by MangoPtrPrivateNamespace::PtrUsageSharing::unlinkNew(), and MangoPtr::Owned< CntrType, oshiptype >::~Owned().

void MangoPtr::SharedValidity::setValid bool    valid [inline, protected]

Change the state of the validator.

This creates the reference counter if only if necessary.

valid  set validity flag to true or false

Reimplemented in MangoPtr::ValidityOwner.

Definition at line 199 of file SharedValidity.hh.

References MangoPtr::isNull(), and isValid().

Referenced by reset(), and SharedValidity().

The documentation for this class was generated from the following file:
Generated on Tue Nov 12 20:44:03 2002 for Mango-ptr Library by doxygen1.2.18