PSCF v1.1
|
Template for a value that can be set or declared null (i.e., unknown). More...
#include <Setable.h>
Public Member Functions | |
Setable () | |
Default constructor. More... | |
Setable (const Setable< T > &other) | |
Copy constructor. More... | |
Setable (const T &value) | |
Construct from T value (explicit). More... | |
Setable< T > & | operator= (const Setable< T > &other) |
Assignment from another Setable<T> object. More... | |
Setable< T > & | operator= (const T &value) |
Assignment from T value. More... | |
void | set (const T &value) |
Set the value and mark as set. More... | |
void | unset () |
Unset the value (mark as unknown). More... | |
bool | isSet () const |
Is this object set (is the value known)? More... | |
const T & | value () const |
Return value (if set). More... | |
bool | isValid (MPI::Intracomm &communicator) const |
Test consistency of states on different processors. More... | |
Template for a value that can be set or declared null (i.e., unknown).
Type T must be copy-constructable and have an assignment (=) operator.
Convention for MPI programs: In parallel MPI programs in which a value for a variable is calculated by a reduce operation and is set only on a master processor, a default value should be set on all other processors whenever the true value is set on the master. This indicates on all processors that the value is known, though it may only be available on the master processor. Similarly, when a value is unset, the unset() function should be called on all processors. This convention allows the isSet() function to be used on all processors to query whether the value is known, which may be then be used to decide when to initiate a recomputation that may require computation on all processors. This convention is imposed by the isValid() function, which requires that isSet have the same value on all processors within a communicator (i.e., all true or all false).
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
Assignment from T value.
Equivalent to set(value). Sets the value and marks it as set.
value | T value on RHS of assignment |
Definition at line 95 of file Setable.h.
References Util::Setable< T >::value().
|
inline |
Set the value and mark as set.
value | value to be assigned. |
Definition at line 107 of file Setable.h.
References Util::Setable< T >::value().
|
inline |
|
inline |
|
inline |
Return value (if set).
Throws an Exception if value is not set.
Definition at line 132 of file Setable.h.
References UTIL_THROW.
Referenced by Util::Setable< T >::operator=(), and Util::Setable< T >::set().
bool Util::Setable< T >::isValid | ( | MPI::Intracomm & | communicator | ) | const |
Test consistency of states on different processors.
If valid, return true, else throws an Exception. The state is valid if the value of isSet is the same on all processors.
Definition at line 163 of file Setable.h.
References UTIL_THROW.