SpatialOps
SpatialOps::SpatFldPtr< FieldT > Class Template Reference

Wrapper for pointers to SpatialField objects. Provides reference counting. More...

#include <SpatialFieldStore.h>

Inheritance diagram for SpatialOps::SpatFldPtr< FieldT >:

Public Member Functions

 SpatFldPtr (FieldT *const field)
 Construct a SpatFldPtr. More...
 
 SpatFldPtr (FieldT *const field, const bool builtFromStore)
 Constructor for use from the SpatialFieldStore class only. More...
 
 SpatFldPtr (FieldT *const field, const bool builtFromStore, const short int deviceIndex)
 Constructor for use from SpatialFieldStore only and ONLY for masquerade fields. This is specifically so that we can wrap or allocate a double on an external device while pretending it is a full spatial field. More...
 
 SpatFldPtr (const SpatFldPtr< FieldT > &p)
 Copy constructor.
 
 SpatFldPtr ()
 Skeletal constructor.
 
SpatFldPtroperator= (const SpatFldPtr &p)
 Assignment operator.
 
SpatFldPtroperator= (FieldT *const f)
 Assignment operator.
 
void detach ()
 

Detailed Description

template<typename FieldT>
class SpatialOps::SpatFldPtr< FieldT >

Wrapper for pointers to SpatialField objects. Provides reference counting.

Author
James C. Sutherland
Date
June, 2007

The SpatFldPtr class provides reference counted pointer management for SpatialField objects. Furthermore, it can be used in conjunction with the SpatialFieldStore class to obtain temporary (scratch) SpatialField objects. It also supports binary operations among SpatFldPtr objects - an extension to the SpatialField class, which doesn't support binary operators since the issue of creating intermediate/temporary objects is dangerous.

You should NOT dereference SpatFldPtr objects and store those references. That is VERY dangerous and can lead to memory corruption.

Note that the underlying SpatialField object will not be owned by this class. The real functionality provided here is to allow an interface to the SpatialFieldStore so that when a SpatFldPtr is created from there, it may be reference-counted so that when the last one is destroyed it returns control of the memory back to the SpatialFieldStore. You can create SpatFldPtr objects from an existing SpatialField, but the SpatFldPtr will not assume ownership of the memory.

Definition at line 75 of file SpatialFieldStore.h.

Constructor & Destructor Documentation

◆ SpatFldPtr() [1/3]

template<typename FieldT>
SpatialOps::SpatFldPtr< FieldT >::SpatFldPtr ( FieldT *const  field)

Construct a SpatFldPtr.

Parameters
fieldThe field to wrap. This constructor should be used if you want to wrap an existing SpatialField for use as a SpatFldPtr. Ownership of this pointer is transfered.

Definition at line 293 of file SpatialFieldStore.h.

◆ SpatFldPtr() [2/3]

template<typename FieldT>
SpatialOps::SpatFldPtr< FieldT >::SpatFldPtr ( FieldT *const  field,
const bool  builtFromStore 
)

Constructor for use from the SpatialFieldStore class only.

Parameters
fieldThe field to wrap. Ownership is transfered.
builtFromStoreif true, then SpatFldPtr will return the memory it owns to the SpatialFieldStore class once the last reference is destroyed. If false then this will simply alias a FieldT object.

Definition at line 305 of file SpatialFieldStore.h.

◆ SpatFldPtr() [3/3]

template<typename FieldT>
SpatialOps::SpatFldPtr< FieldT >::SpatFldPtr ( FieldT *const  field,
const bool  builtFromStore,
const short int  deviceIndex 
)

Constructor for use from SpatialFieldStore only and ONLY for masquerade fields. This is specifically so that we can wrap or allocate a double on an external device while pretending it is a full spatial field.

Parameters
fieldpointer to wrap
builtFromStoredo we build it
deviceIndexdevice index for memory lookup

Member Function Documentation

◆ detach()

template<typename FieldT >
void SpatialOps::SpatFldPtr< FieldT >::detach ( )

Dissociate the field that this SpatFldPtr points to from this object, potentially releasing the memory that it points to as well.

Definition at line 395 of file SpatialFieldStore.h.


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