MADNESS  version 0.9
Public Types | Public Member Functions | Friends | List of all members
madness::detail::WorldPtr< T > Class Template Reference

A global pointer address, valid anywhere in the world. More...

#include <worldptr.h>

Public Types

typedef unsigned long worldidT
 World ID type. More...
 
typedef T * pointer
 
typedef ptr_traits< T >::reference reference
 

Public Member Functions

 WorldPtr ()
 Default constructor. More...
 
 WorldPtr (World &w, T *p)
 World pointer constructor. More...
 
 WorldPtr (const WorldPtr< T > &other)
 Copy constructor. More...
 
template<typename U >
 WorldPtr (const WorldPtr< U > &other)
 Copy conversion constructor. More...
 
WorldPtr< T > & operator= (const WorldPtr< T > &other)
 Copy assignment operator. More...
 
template<typename U >
WorldPtr< T > & operator= (const WorldPtr< U > &other)
 Copy conversion assignment operator. More...
 
bool is_local () const
 Check that the world pointer references a local pointer. More...
 
bool has_owner () const
 Check that the world pointer has an owner. More...
 
pointer get () const
 Pointer accessor. More...
 
reference operator* () const
 Dereference operator. More...
 
pointer operator-> () const
 Pointer arrow operator. More...
 
 operator bool () const
 Boolean conversion operator. More...
 
bool operator! () const
 Boolean conversion operator. More...
 
template<typename U >
bool operator== (const WorldPtr< U > &other) const
 Equality comparison operator. More...
 
template<typename U >
bool operator!= (const WorldPtr< U > &other) const
 Inequality comparison operator. More...
 
template<typename U >
bool operator< (const WorldPtr< U > &other) const
 Less-than comparison operator. More...
 
Worldget_world () const
 World accessor. More...
 
worldidT get_worldid () const
 World ID accessor. More...
 
ProcessID owner () const
 Rank accessor. More...
 
template<typename U >
void swap (WorldPtr< U > &other)
 Swap the content of this with other. More...
 
template<class Archive >
void load_internal_ (const Archive &ar)
 Serialize/deserialize the world pointer. More...
 
template<class Archive >
void store_internal_ (const Archive &ar) const
 

Friends

template<typename >
class WorldPtr
 
std::ostream & operator<< (std::ostream &out, const WorldPtr< T > &p)
 

Detailed Description

template<typename T>
class madness::detail::WorldPtr< T >

A global pointer address, valid anywhere in the world.

Stores a globally addressable pointer. It can be sent to any process in the world.

Template Parameters
TThe pointer type

Member Typedef Documentation

template<typename T>
typedef T* madness::detail::WorldPtr< T >::pointer
template<typename T>
typedef ptr_traits<T>::reference madness::detail::WorldPtr< T >::reference
template<typename T>
typedef unsigned long madness::detail::WorldPtr< T >::worldidT

World ID type.

Constructor & Destructor Documentation

template<typename T>
madness::detail::WorldPtr< T >::WorldPtr ( )
inline

Default constructor.

Creates a NULL pointer. There is no owner (i.e. the owner is set to -1).

Exceptions
nothing
template<typename T>
madness::detail::WorldPtr< T >::WorldPtr ( World w,
T *  p 
)
inline

World pointer constructor.

Construct a world pointer form a local pointer.

Parameters
wA reference to the local world.
pThe local pointer.
Exceptions
nothing
template<typename T>
madness::detail::WorldPtr< T >::WorldPtr ( const WorldPtr< T > &  other)
inline

Copy constructor.

Parameters
otherThe world pointer to be copied
Exceptions
nothing
template<typename T>
template<typename U >
madness::detail::WorldPtr< T >::WorldPtr ( const WorldPtr< U > &  other)
inline

Copy conversion constructor.

Copy and convert pointer from U* to T* type.

Template Parameters
UThe pointer type of the other pointer
Parameters
otherThe world pointer to be copied
Exceptions
nothing
Note
U* must be implicitly convertible to T* type.

Member Function Documentation

template<typename T>
pointer madness::detail::WorldPtr< T >::get ( ) const
inline

Pointer accessor.

Get the pointer of the world pointer. Note: A default initialized pointer is not considered to be local because it is not associated with a world.

Returns
The local pointer.
Exceptions
MadnessExceptionWhen the pointer references a remote address.
template<typename T>
World& madness::detail::WorldPtr< T >::get_world ( ) const
inline

World accessor.

Returns
A pointer to the world (may be NULL)
Exceptions
MadnessExceptionWhen the pointer world has not been set (i.e. When has_owner()==false)

Referenced by madness::detail::RemoteCounter::get_world().

template<typename T>
worldidT madness::detail::WorldPtr< T >::get_worldid ( ) const
inline

World ID accessor.

Returns
The world ID of the world that the pointer belongs to.
Exceptions
nothing

Referenced by madness::detail::RemoteCounter::get_worldid(), and madness::detail::WorldPtr< madness::detail::RemoteCounterBase >::load_internal_().

template<typename T>
bool madness::detail::WorldPtr< T >::has_owner ( ) const
inline

Check that the world pointer has an owner.

Returns
true when the pointer has a valid owner
Exceptions
nothing

Referenced by madness::detail::RemoteCounter::has_owner().

template<typename T>
bool madness::detail::WorldPtr< T >::is_local ( ) const
inline
template<typename T>
template<class Archive >
void madness::detail::WorldPtr< T >::load_internal_ ( const Archive &  ar)
inline

Serialize/deserialize the world pointer.

Serialize/deserialize the world pointer for remote communication or write to disk.

Template Parameters
ArchiveThe archive object type.

Referenced by madness::archive::ArchiveLoadImpl< Archive, detail::WorldPtr< T > >::load().

template<typename T>
madness::detail::WorldPtr< T >::operator bool ( ) const
inline

Boolean conversion operator.

Returns
true when the pointer is non-null and false otherwise
Exceptions
nothing
template<typename T>
bool madness::detail::WorldPtr< T >::operator! ( ) const
inline

Boolean conversion operator.

Returns
true when the pointer is null and false otherwise
Exceptions
nothing
template<typename T>
template<typename U >
bool madness::detail::WorldPtr< T >::operator!= ( const WorldPtr< U > &  other) const
inline

Inequality comparison operator.

Template Parameters
UAnother pointer type
Returns
true when the pointers refer to different addresses or different nodes or different worlds.
Exceptions
nothing
template<typename T>
reference madness::detail::WorldPtr< T >::operator* ( ) const
inline

Dereference operator.

Dereference the local pointer.

Returns
A reference to the local pointer
Exceptions
MadnessExceptionWhen the pointer references a remote address, or when the pointer is NULL.
template<typename T>
pointer madness::detail::WorldPtr< T >::operator-> ( ) const
inline

Pointer arrow operator.

Access members of the pointer

Returns
The local pointer
Exceptions
MadnessExceptionWhen the pointer references a remote address, or when the pointer is NULL.
template<typename T>
template<typename U >
bool madness::detail::WorldPtr< T >::operator< ( const WorldPtr< U > &  other) const
inline

Less-than comparison operator.

This operator does a lexicographical comparison of world ID, rank, and pointer (in that order).

Template Parameters
UAnother pointer type
Returns
true when the lexicographical comparison of world ID, rank, and pointer is true, and false otherwise.
Exceptions
nothing
template<typename T>
WorldPtr<T>& madness::detail::WorldPtr< T >::operator= ( const WorldPtr< T > &  other)
inline

Copy assignment operator.

Parameters
otherThe world pointer to be copied
Returns
A reference to this object
Exceptions
nothing
template<typename T>
template<typename U >
WorldPtr<T>& madness::detail::WorldPtr< T >::operator= ( const WorldPtr< U > &  other)
inline

Copy conversion assignment operator.

Copy and convert pointer from U* to T* type.

Template Parameters
UThe pointer type of the other pointer
Parameters
otherThe world pointer to be copied
Returns
A reference to this object
Exceptions
nothing
Note
U* must be implicitly convertible to T* type.
template<typename T>
template<typename U >
bool madness::detail::WorldPtr< T >::operator== ( const WorldPtr< U > &  other) const
inline

Equality comparison operator.

Template Parameters
UAnother pointer type
Returns
true when the pointers refer to the same address from the same node in the same world.
Exceptions
nothing
template<typename T>
ProcessID madness::detail::WorldPtr< T >::owner ( ) const
inline

Rank accessor.

If the pointer is not associated with

Returns
The rank of the process that owns the pointer
Exceptions
nothing

Referenced by madness::detail::RemoteCounter::owner().

template<typename T>
template<class Archive >
void madness::detail::WorldPtr< T >::store_internal_ ( const Archive &  ar) const
inline
template<typename T>
template<typename U >
void madness::detail::WorldPtr< T >::swap ( WorldPtr< U > &  other)
inline

Swap the content of this with other.

Template Parameters
UThe other world pointer type
Exceptions
nothing
Note
U* must be implicitly convertible to T* type.

Referenced by madness::detail::swap().

Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  out,
const WorldPtr< T > &  p 
)
friend
template<typename T>
template<typename >
friend class WorldPtr
friend

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