A non-const Field/List wrapper with possible data conversion. More...
Public Types | |
typedef Container< Type > | FieldType |
The adapted field type. Same as element_type. More... | |
Public Types inherited from refPtr< Container< Type > > | |
typedef Container< Type > | element_type |
Type of object being managed or referenced. More... | |
typedef Container< Type > * | pointer |
Pointer to type of object being managed or referenced. More... | |
typedef Foam::refCount::zero | refCount |
Null reference counter class. More... | |
Public Member Functions | |
PrecisionAdaptor ()=default | |
Default construct, setting content later. More... | |
PrecisionAdaptor (Container< InputType > &input, const bool doCopy=true) | |
Construct from Container<InputType>, copying input if required (and requested) More... | |
~PrecisionAdaptor () | |
Destructor, copies back content changes (as required) More... | |
bool | active () const noexcept |
Is precision adaption being used (non-passive adaptor)? More... | |
void | commit () |
Commit adapted content changes back to original input (as required) More... | |
void | set (Container< InputType > &input, const bool doCopy=true) |
Set adaptor for different input, copying input as required. More... | |
Public Member Functions inherited from refPtr< Container< Type > > | |
constexpr | refPtr () noexcept |
Construct with no managed pointer. More... | |
constexpr | refPtr (std::nullptr_t) noexcept |
Implicit construct from literal nullptr: no managed pointer. More... | |
constexpr | refPtr (Container< Type > *p) noexcept |
Construct, taking ownership of the pointer. More... | |
constexpr | refPtr (const Container< Type > &obj) noexcept |
Implicit construct for a const reference to an object. More... | |
refPtr (refPtr< Container< Type > > &&rhs) noexcept | |
Move construct, transferring ownership. More... | |
refPtr (const refPtr< Container< Type > > &rhs) | |
Copy construct (shallow copy) More... | |
refPtr (const refPtr< Container< Type > > &rhs, bool reuse) | |
Copy/move construct. Optionally reusing pointer. More... | |
refPtr (std::unique_ptr< Container< Type > > &&rhs) noexcept | |
Move construct from unique_ptr, transferring ownership. More... | |
refPtr (const autoPtr< Container< Type > > &)=delete | |
No copy construct from autoPtr, also avoids implicit cast to object or pointer. More... | |
refPtr (autoPtr< Container< Type > > &&rhs) noexcept | |
Move construct from autoPtr, transferring ownership. More... | |
refPtr (const tmp< Container< Type > > &rhs, bool reuse) | |
Reference tmp contents or transfer ownership if requested/possible. More... | |
refPtr (const tmp< Container< Type > > &rhs) | |
Reference the tmp contents. More... | |
refPtr (tmp< Container< Type > > &&rhs) | |
Move construct from tmp, transfer ownership if possible. More... | |
~refPtr () noexcept | |
Destructor: deletes managed pointer. More... | |
bool | good () const noexcept |
True if pointer/reference is non-null. More... | |
bool | is_const () const noexcept |
If the stored/referenced content is const. More... | |
bool | is_pointer () const noexcept |
True if this is a managed pointer (not a reference) More... | |
bool | is_reference () const noexcept |
True if this is a reference (not a pointer) More... | |
bool | movable () const noexcept |
True if this is a non-null managed pointer. More... | |
Container< Type > * | get () noexcept |
Return pointer without nullptr checking. More... | |
const Container< Type > * | get () const noexcept |
Return const pointer without nullptr checking. More... | |
const Container< Type > & | cref () const |
Return const reference to the object or to the contents of a (non-null) managed pointer. More... | |
void | cref (const refPtr< Container< Type > > &other) noexcept |
Clear existing and set (const) reference from other. More... | |
void | cref (const Container< Type > &obj) noexcept |
Clear existing and set (const) reference. More... | |
void | cref (const Container< Type > *p) noexcept |
Clear existing and set (const) reference to pointer content. More... | |
void | cref (const autoPtr< Container< Type > > &)=delete |
Avoid inadvertent casting (to object or pointer) More... | |
void | cref (const tmp< Container< Type > > &)=delete |
Avoid inadvertent casting (to object) More... | |
Container< Type > & | ref () const |
Return non-const reference to the contents of a non-null managed pointer. More... | |
void | ref (Container< Type > &obj) noexcept |
Clear existing and set (non-const) reference. More... | |
void | ref (Container< Type > *p) noexcept |
Clear existing and set (non-const) reference to pointer content. More... | |
void | ref (const autoPtr< Container< Type > > &)=delete |
Avoid inadvertent casting (to object or pointer) More... | |
void | ref (const tmp< Container< Type > > &)=delete |
Avoid inadvertent casting (object) More... | |
Container< Type > & | constCast () const |
Return non-const reference to the object or to the contents of a (non-null) managed pointer, with an additional const_cast. More... | |
refPtr< Container< Type > > | shallowClone () const noexcept |
Return a shallow copy as a wrapped reference, preserving the const/non-const status. More... | |
Container< Type > * | release () noexcept |
Release ownership and return the pointer. A no-op for reference objects (returns nullptr). More... | |
Container< Type > * | ptr () const |
Return managed pointer for reuse, or clone() the object reference. More... | |
void | clear () const noexcept |
If object pointer points to valid object: delete object and set pointer to nullptr. More... | |
void | reset (Container< Type > *p=nullptr) noexcept |
Delete managed pointer and set to new given pointer. More... | |
void | reset (refPtr< Container< Type > > &&other) noexcept |
Clear existing and transfer ownership. More... | |
void | reset (const autoPtr< Container< Type > > &)=delete |
No reset from autoPtr reference (potentially confusing) More... | |
void | reset (autoPtr< Container< Type > > &&other) noexcept |
Clear existing and transfer ownership from autoPtr. More... | |
void | reset (std::unique_ptr< Container< Type > > &&other) |
Clear existing and transfer ownership from unique_ptr. More... | |
void | reset (tmp< Container< Type > > &rhs, bool reuse) |
Reference tmp contents or transfer pointer ownership if possible. More... | |
void | swap (refPtr< Container< Type > > &other) noexcept |
Swaps the managed object with other. More... | |
const Container< Type > & | operator* () const |
Return const reference to the object. More... | |
Container< Type > & | operator* () |
Return reference to the managed object. More... | |
const Container< Type > * | operator-> () const |
Dereferences (const) pointer to the managed object. More... | |
Container< Type > * | operator-> () |
Dereferences (non-const) pointer to the managed object. More... | |
const Container< Type > & | operator() () const |
Return const reference to the object - same as cref() method. More... | |
operator bool () const noexcept | |
True if pointer/reference is non-null. Same as good() More... | |
operator const Container< Type > & () const | |
Cast to underlying data type, using the cref() method. More... | |
void | operator= (const refPtr< Container< Type > > &other) |
Transfer ownership of managed pointer. More... | |
void | operator= (refPtr< Container< Type > > &&other) noexcept |
Clear existing and transfer ownership. More... | |
void | operator= (Container< Type > *p)=delete |
No copy assignment from plain pointer (uncontrolled access) More... | |
void | operator= (std::nullptr_t) noexcept |
Reset via assignment from literal nullptr. More... | |
void | operator= (const autoPtr< Container< Type > > &)=delete |
No copy assignment from autoPtr (can have unintended behaviour) More... | |
void | operator= (autoPtr< Container< Type > > &&other) noexcept |
Transfer ownership by move assignment from autoPtr. More... | |
void | operator= (std::unique_ptr< Container< Type > > &&other) |
Transfer ownership by move assignment from unique_ptr. More... | |
void | operator= (const tmp< Container< Type > > &)=delete |
No copy assignment from tmp. More... | |
void | operator= (tmp< Container< Type > > &&other) |
Move construct, transferring pointer ownership if possible. More... | |
operator tmp< Container< Type > > () | |
Conversion to tmp, releases pointer or shallow-copies reference. More... | |
bool | valid () const noexcept |
Identical to good(), or bool operator. More... | |
bool | empty () const noexcept |
Deprecated(2020-07) True if a null managed pointer. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from refPtr< Container< Type > > | |
static refPtr< Container< Type > > | New (Args &&... args) |
Construct refPtr with forwarding arguments. More... | |
static refPtr< Container< Type > > | NewFrom (Args &&... args) |
Construct refPtr from derived type with forwarding arguments. More... | |
static word | typeName () |
The type-name, constructed from type-name of T. More... | |
A non-const Field/List wrapper with possible data conversion.
Conversion adaptor for Field/List that either wrap the input as a reference, or creates a temporary pointer and copies the values on construction/destruction.
This provides, for example, automatic conversion between types for linear solvers able to run mixed precision.
Definition at line 210 of file PrecisionAdaptor.H.
typedef Container<Type> FieldType |
The adapted field type. Same as element_type.
Definition at line 251 of file PrecisionAdaptor.H.
|
default |
Default construct, setting content later.
|
inlineexplicit |
Construct from Container<InputType>, copying input if required (and requested)
Definition at line 266 of file PrecisionAdaptor.H.
References Foam::input().
|
inline |
Destructor, copies back content changes (as required)
Definition at line 278 of file PrecisionAdaptor.H.
References refPtr< Container< Type > >::clear(), and PrecisionAdaptor< Type, InputType, Container >::commit().
|
inlinenoexcept |
Is precision adaption being used (non-passive adaptor)?
Definition at line 290 of file PrecisionAdaptor.H.
References refPtr< Container< Type > >::good(), and refPtr< Container< Type > >::is_pointer().
Referenced by PrecisionAdaptor< Type, InputType, Container >::commit().
|
inline |
Commit adapted content changes back to original input (as required)
Definition at line 299 of file PrecisionAdaptor.H.
References PrecisionAdaptor< Type, InputType, Container >::active(), refPtr< Container< Type > >::cref(), refPtr< T >::good(), Foam::input(), and refPtr< T >::ref().
Referenced by PrecisionAdaptor< Type, InputType, Container >::set(), and PrecisionAdaptor< Type, InputType, Container >::~PrecisionAdaptor().
|
inline |
Set adaptor for different input, copying input as required.
Definition at line 313 of file PrecisionAdaptor.H.
References PrecisionAdaptor< Type, InputType, Container >::commit(), refPtr< T >::get(), and Foam::input().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.