Simpatico  v1.10
List of all members | Public Member Functions
Util::Setable< T > Class Template Reference

Detailed Description

template<class T>
class Util::Setable< T >

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).

Definition at line 38 of file Setable.h.

#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...
 

Constructor & Destructor Documentation

template<class T>
Util::Setable< T >::Setable ( )
inline

Default constructor.

Definition at line 46 of file Setable.h.

template<class T>
Util::Setable< T >::Setable ( const Setable< T > &  other)
inline

Copy constructor.

Parameters
otherSetable object being copied.

Definition at line 56 of file Setable.h.

template<class T>
Util::Setable< T >::Setable ( const T &  value)
inlineexplicit

Construct from T value (explicit).

Parameters
valuevalue of wrapped object

Definition at line 66 of file Setable.h.

Member Function Documentation

template<class T>
Setable<T>& Util::Setable< T >::operator= ( const Setable< T > &  other)
inline

Assignment from another Setable<T> object.

Parameters
otherobject on RHS of assignment

Definition at line 76 of file Setable.h.

template<class T>
Setable<T>& Util::Setable< T >::operator= ( const T &  value)
inline

Assignment from T value.

Equivalent to set(value). Sets the value and marks it as set.

Parameters
valueT value on RHS of assignment
Returns
this object

Definition at line 95 of file Setable.h.

template<class T>
void Util::Setable< T >::set ( const T &  value)
inline
template<class T>
void Util::Setable< T >::unset ( )
inline
template<class T>
bool Util::Setable< T >::isSet ( ) const
inline
template<class T>
const T& Util::Setable< T >::value ( ) const
inline
template<typename T >
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::Setable< T >::isSet(), and UTIL_THROW.

Referenced by DdMd::Potential::isValid(), DdMd::AtomStorage::isValid(), and Util::Setable< Util::Tensor >::value().


The documentation for this class was generated from the following file: