#include <SharedValidity.hh>
Inheritance diagram for MangoPtr::SharedValidity:
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.
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. |
|
Create a validator and set its validity value at construction.
Definition at line 98 of file SharedValidity.hh. References MangoPtr::NullPtr, and setValid(). |
|
Share a validator. This automatically increments the reference count. Though vv is const, its reference count is therefore also changed (since it is shared).
Definition at line 117 of file SharedValidity.hh. References MangoPtr::isNotNull(). |
|
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.
Reimplemented in MangoPtr::ValidityChecker. Definition at line 133 of file SharedValidity.hh. References MangoPtr::isNotNull(). |
|
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.
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(). |
|
Change the state of the validator. This creates the reference counter if only if necessary.
Reimplemented in MangoPtr::ValidityOwner. Definition at line 199 of file SharedValidity.hh. References MangoPtr::isNull(), and isValid(). Referenced by reset(), and SharedValidity(). |