#include <Teuchos_ArrayRCPDecl.hpp>
Public Types | |
Public types | |
| typedef std::random_access_iterator_tag | iterator_category |
| | |
| typedef T * | iterator_type |
| | |
| typedef T | value_type |
| | |
| typedef T & | reference |
| | |
| typedef T * | pointer |
| | |
| typedef ptrdiff_t | difference_type |
| | |
| typedef T | element_type |
| | |
| typedef Teuchos_Index | Ordinal |
| | |
Public Member Functions | |
Constructors/Destructors/Initializers | |
| ArrayRCP (ENull null_arg=null) | |
Initialize ArrayRCP<T> to NULL. | |
| ArrayRCP (const ArrayRCP< T > &r_ptr) | |
Initialize from another ArrayRCP<T> object. | |
| ~ArrayRCP () | |
| Removes a reference to a dynamically allocated array and possibly deletes the array if owned. | |
| ArrayRCP< T > & | operator= (const ArrayRCP< T > &r_ptr) |
| Copy the pointer to the referenced array and increment the reference count. | |
Object/Pointer Access Functions | |
| bool | is_null () const |
| Returns true if the underlying pointer is null. | |
| T * | operator-> () const |
Pointer (->) access to members of underlying object for current position. | |
| T & | operator * () const |
| Dereference the underlying object for the current pointer position. | |
| T * | get () const |
| Get the raw C++ pointer to the underlying object. | |
| T * | getRawPtr () const |
| Get the raw C++ pointer to the underlying object. | |
| T & | operator[] (Ordinal offset) const |
| Random object access. | |
Pointer Arithmetic Functions | |
| ArrayRCP< T > & | operator++ () |
| Prefix increment of pointer (i.e. ++ptr). | |
| ArrayRCP< T > | operator++ (int) |
| Postfix increment of pointer (i.e. ptr++). | |
| ArrayRCP< T > & | operator-- () |
| Prefix deincrement of pointer (i.e. --ptr). | |
| ArrayRCP< T > | operator-- (int) |
| Postfix deincrement of pointer (i.e. ptr--). | |
| ArrayRCP< T > & | operator+= (Ordinal offset) |
| Pointer integer increment (i.e. ptr+=offset). | |
| ArrayRCP< T > & | operator-= (Ordinal offset) |
| Pointer integer increment (i.e. ptr-=offset). | |
| ArrayRCP< T > | operator+ (Ordinal offset) const |
| Pointer integer increment (i.e. ptr+offset). | |
| ArrayRCP< T > | operator- (Ordinal offset) const |
| Pointer integer deincrement (i.e. ptr-offset). | |
Standard Container-Like Functions | |
| const_iterator | begin () const |
| Return an iterator to beginning of the array of data. | |
| const_iterator | end () const |
| Return an iterator to past the end of the array of data. | |
ArrayRCP Views | |
| ArrayRCP< const T > | getConst () const |
| Return object for only const access to data. | |
| ArrayRCP< T > | persistingView (Ordinal lowerOffset, Ordinal size) const |
| Return a persisting view of a contiguous range of elements. | |
Size and extent query functions | |
| Ordinal | lowerOffset () const |
| Return the lower offset to valid data. | |
| Ordinal | upperOffset () const |
| Return the upper offset to valid data. | |
| Ordinal | size () const |
The total number of items in the managed array (i.e. upperOffset()-lowerOffset()+1). | |
ArrayView views | |
| ArrayView< T > | view (Ordinal lowerOffset, Ordinal size) const |
| Return view of a contiguous range of elements. | |
| ArrayView< T > | operator() (Ordinal lowerOffset, Ordinal size) const |
| Return a view of a contiguous range of elements (calls view(offset,size)). | |
| ArrayView< T > | operator() () const |
| Return an ArrayView of *this. | |
| operator ArrayView () const | |
| Perform an implicit conversion to a ArrayView<T> (calls operator()()). | |
| operator ArrayRCP () const | |
| Convert from ArrayRCP<T> to ArrayRCP<const T>. | |
Reference counting | |
| ERCPStrength | strength () const |
| Strength of the pointer. | |
| bool | is_valid_ptr () const |
| Return if the underlying object pointer is still valid or not. | |
| int | strong_count () const |
Return the number of active RCP<> objects that have a "strong" reference to the underlying reference-counted object. | |
| int | weak_count () const |
Return the number of active RCP<> objects that have a "weak" reference to the underlying reference-counted object. | |
| int | total_count () const |
| Total count (strong_count() + weak_count()). | |
| void | set_has_ownership () |
Give this and other ArrayRCP<> objects ownership of the underlying referenced array to delete it. | |
| bool | has_ownership () const |
Returns true if this has ownership of object pointed to by this->get() in order to delete it. | |
| T * | release () |
| Release the ownership of the underlying array. | |
| ArrayRCP< T > | create_weak () const |
| Create a new weak RCP object from another RCP object. | |
| template<class T2> | |
| bool | shares_resource (const ArrayRCP< T2 > &r_ptr) const |
| Returns true if the smart pointers share the same underlying reference-counted object. | |
Assertion Functions. | |
| const ArrayRCP< T > & | assert_not_null () const |
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this. | |
| const ArrayRCP< T > & | assert_in_range (Ordinal lowerOffset, Ordinal size) const |
Throws NullReferenceError if this->get()==NULL orthis->get()!=NULL, throws RangeError if (lowerOffset < this->lowerOffset() || this->upperOffset() < upperOffset, otherwise returns reference to *this. | |
| const ArrayRCP< T > & | assert_valid_ptr () const |
| If the object pointer is non-null, assert that it is still valid. | |
Deprecated | |
| int | count () const |
Returns strong_count() [deprecated]. | |
Related Functions | |
| (Note that these are not member functions.) | |
| ArrayRCP< T > | arcp (const RCP< Array< T > > &v) |
Wrap an Array<T> object as an ArrayRCP<T> object. | |
| ArrayRCP< const T > | arcp (const RCP< const Array< T > > &v) |
Wrap a const Array<T> object as an ArrayRCP<const T> object. | |
| ArrayRCP< T > | arcp (T *p, typename ArrayRCP< T >::Ordinal lowerOffset, typename ArrayRCP< T >::Ordinal size, bool owns_mem=true) |
| Wraps a preallocated array of data with the assumption to call the array version of delete. | |
| ArrayRCP< T > | arcp (T *p, typename ArrayRCP< T >::Ordinal lowerOffset, typename ArrayRCP< T >::Ordinal size, Dealloc_T dealloc, bool owns_mem) |
| Wraps a preallocated array of data and uses a templated deallocation strategy object to define deletion . | |
| ArrayRCP< T > | arcp (typename ArrayRCP< T >::Ordinal size) |
| Allocate a new array just given a dimension. | |
| ArrayRCP< T > | arcpClone (const ArrayView< const T > &v) |
| Allocate a new array by cloning data from an input array view. | |
| ArrayRCP< T > | arcpWithEmbeddedObjPreDestroy (T *p, typename ArrayRCP< T >::Ordinal lowerOffset, typename ArrayRCP< T >::Ordinal size, const Embedded &embedded, bool owns_mem=true) |
| Create an ArrayRCP with and also put in an embedded object. | |
| ArrayRCP< T > | arcpWithEmbeddedObjPostDestroy (T *p, typename ArrayRCP< T >::Ordinal lowerOffset, typename ArrayRCP< T >::Ordinal size, const Embedded &embedded, bool owns_mem=true) |
| Create an ArrayRCP with and also put in an embedded object. | |
| ArrayRCP< T > | arcpWithEmbeddedObj (T *p, typename ArrayRCP< T >::Ordinal lowerOffset, typename ArrayRCP< T >::Ordinal size, const Embedded &embedded, bool owns_mem=true) |
| Create an ArrayRCP with and also put in an embedded object. | |
| ArrayRCP< T > | arcp (const RCP< std::vector< T > > &v) |
Wrap an std::vector<T> object as an ArrayRCP<T> object. | |
| ArrayRCP< const T > | arcp (const RCP< const std::vector< T > > &v) |
Wrap a const std::vector<T> object as an ArrayRCP<const T> object. | |
| RCP< std::vector< T > > | get_std_vector (const ArrayRCP< T > &ptr) |
Get an std::vector<T> object out of an ArrayRCP<T> object that was created using the arcp() above to wrap the std::vector in the first place.. | |
| RCP< const std::vector< T > > | get_std_vector (const ArrayRCP< const T > &ptr) |
Get a const std::vector<T> object out of an ArrayRCP<const T> object that was created using the arcp() above to wrap the std::vector in the first place. | |
| bool | is_null (const ArrayRCP< T > &p) |
Returns true if p.get()==NULL. | |
| bool | operator== (const ArrayRCP< T > &p, ENull) |
Returns true if p.get()==NULL. | |
| bool | operator!= (const ArrayRCP< T > &p, ENull) |
Returns true if p.get()!=NULL. | |
| bool | operator== (const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2) |
| | |
| bool | operator!= (const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2) |
| | |
| bool | operator< (const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2) |
| | |
| bool | operator<= (const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2) |
| | |
| bool | operator> (const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2) |
| | |
| bool | operator>= (const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2) |
| | |
| ArrayRCP< T >::difference_type | operator- (const ArrayRCP< T > &p1, const ArrayRCP< T > &p2) |
| Returns difference of two ArrayRCP object. | |
| ArrayRCP< T2 > | arcp_const_cast (const ArrayRCP< T1 > &p1) |
Const cast of underlying ArrayRCP type from const T* to T*. | |
| ArrayRCP< T2 > | arcp_reinterpret_cast (const ArrayRCP< T1 > &p1) |
Reinterpret cast of underlying ArrayRCP type from T1* to T2*. | |
| ArrayRCP< T2 > | arcp_implicit_cast (const ArrayRCP< T1 > &p1) |
Implicit case the underlying ArrayRCP type from T1* to T2*. | |
| void | set_extra_data (const T1 &extra_data, const std::string &name, const Ptr< ArrayRCP< T2 > > &p, EPrePostDestruction destroy_when=POST_DESTROY, bool force_unique=true) |
Set extra data associated with a ArrayRCP object. | |
| T1 & | get_extra_data (ArrayRCP< T2 > &p, const std::string &name) |
Get a non-const reference to extra data associated with a ArrayRCP object. | |
| const T1 & | get_extra_data (const ArrayRCP< T2 > &p, const std::string &name) |
Get a const reference to extra data associated with a ArrayRCP object. | |
| T1 * | get_optional_extra_data (ArrayRCP< T2 > &p, const std::string &name) |
Get a pointer to non-const extra data (if it exists) associated with a ArrayRCP object. | |
| const T1 * | get_optional_extra_data (const ArrayRCP< T2 > &p, const std::string &name) |
Get a pointer to const extra data (if it exists) associated with a ArrayRCP object. | |
| Dealloc_T & | get_nonconst_dealloc (const ArrayRCP< T > &p) |
Return a non-const reference to the underlying deallocator object. | |
| const Dealloc_T & | get_dealloc (const ArrayRCP< T > &p) |
Return a const reference to the underlying deallocator object. | |
| const Dealloc_T * | get_optional_dealloc (const ArrayRCP< T > &p) |
Return a pointer to the underlying non-const deallocator object if it exists. | |
| Dealloc_T * | get_optional_nonconst_dealloc (const ArrayRCP< T > &p) |
Return a pointer to the underlying const deallocator object if it exists. | |
| const Embedded & | getEmbeddedObj (const ArrayRCP< T > &p) |
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(), arcpWithEmbeddedObjPostDestory(), or arcpWithEmbeddedObj(). | |
| Embedded & | getNonconstEmbeddedObj (const ArrayRCP< T > &p) |
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(), arcpWithEmbeddedObjPostDestory(), or arcpWithEmbeddedObj(). | |
| std::ostream & | operator<< (std::ostream &out, const ArrayRCP< T > &p) |
| Output stream inserter. | |
This is a reference-counted class similar to RCP except that it is designed to use reference counting to manage an array of objects that use value semantics. Managing an array of objects is very different from managing a pointer to an individual, possibly polymorphic, object. For example, while implicit conversions from derived to base types is a good thing when dealing with pointers to single objects, it is a very bad thing when working with arrays of objects. Therefore, this class contains those capabilities of raw pointers that are good dealing with arrays of objects but excludes those that are bad, such as implicit conversions from derived to base types.
Note that all access will be checked at runtime to avoid reading invalid memory if HAVE_TEUCHOS_ARRAY_BOUNDSCHECK is defined which it is if --enable-teuchos-abc is given to the configure script. In order to be able to check access, every ArrayRCP must be constructed given a range. When HAVE_TEUCHOS_ARRAY_BOUNDSCHECK is defined, this class simply does not give up a raw pointer or raw reference to any internally referenced object if that object does not fall with the range of valid data.
Type T requirements:
Teuchos::TypeNameTraits<T> specialization ToDo: Finish documentation!
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
||||||||||
|
Initialize This allows clients to write code like: ArrayRCP<int> p = null; ArrayRCP<int> p; NULL |
|
||||||||||
|
Initialize from another
After construction, This form of the copy constructor is required even though the below more general templated version is sufficient since some compilers will generate this function automatically which will give an incorrect implementation. Postconditions:
|
|
|||||||||
|
Removes a reference to a dynamically allocated array and possibly deletes the array if owned.
Deallocates array if |
|
||||||||||
|
Copy the pointer to the referenced array and increment the reference count.
If Postconditions:
|
|
|||||||||
|
Returns true if the underlying pointer is null.
|
|
|||||||||
|
Pointer ( Preconditions:
|
|
|||||||||
|
Dereference the underlying object for the current pointer position. Preconditions:
|
|
|||||||||
|
Get the raw C++ pointer to the underlying object. Preconditions:
|
|
|||||||||
|
Get the raw C++ pointer to the underlying object. Preconditions:
|
|
||||||||||
|
Random object access. Preconditions:
|
|
|||||||||
|
Prefix increment of pointer (i.e. ++ptr).
Does nothing if Postconditions:
|
|
||||||||||
|
Postfix increment of pointer (i.e. ptr++).
Does nothing if Postconditions:
|
|
|||||||||
|
Prefix deincrement of pointer (i.e. --ptr).
Does nothing if Postconditions:
|
|
||||||||||
|
Postfix deincrement of pointer (i.e. ptr--).
Does nothing if Postconditions:
|
|
||||||||||
|
Pointer integer increment (i.e. ptr+=offset).
Does nothing if Postconditions:
|
|
||||||||||
|
Pointer integer increment (i.e. ptr-=offset).
Does nothing if Postconditions:
|
|
||||||||||
|
Pointer integer increment (i.e. ptr+offset).
Returns a null pointer if Postconditions:
Note that since implicit conversion of |
|
||||||||||
|
Pointer integer deincrement (i.e. ptr-offset).
Returns a null pointer if Postconditions:
Note that since implicit conversion of |
|
|||||||||
|
Return an iterator to beginning of the array of data.
If Postconditions: |
|
|||||||||
|
Return an iterator to past the end of the array of data.
If Postconditions:
|
|
|||||||||
|
Return object for only const access to data.
This function should only compile successfully if the type |
|
||||||||||||||||
|
Return a persisting view of a contiguous range of elements. Preconditions:
Postconditions:
|
|
|||||||||
|
Return the lower offset to valid data.
|
|
|||||||||
|
Return the upper offset to valid data.
|
|
|||||||||
|
The total number of items in the managed array (i.e.
|
|
||||||||||||||||
|
Return view of a contiguous range of elements. Preconditions:
Postconditions:
|
|
||||||||||||||||
|
Return a view of a contiguous range of elements (calls view(offset,size)).
|
|
|||||||||
|
Return an ArrayView of *this. NOTE: This will return a null ArrayView if this->size() == 0. |
|
|||||||||
|
Perform an implicit conversion to a ArrayView<T> (calls operator()()).
|
|
|||||||||
|
Convert from ArrayRCP<T> to ArrayRCP<const T>.
|
|
|||||||||
|
Strength of the pointer. Return values:
|
|
|||||||||
|
Return if the underlying object pointer is still valid or not. The underlying object will not be valid if the strong count has gone to zero but the weak count thas not.
NOTE: Null is a valid object pointer. If you want to know if there is a non-null object and it is valid then |
|
|||||||||
|
Return the number of active
|
|
|||||||||
|
Return the number of active
|
|
|||||||||
|
Total count (strong_count() + weak_count()).
|
|
|||||||||
|
Give
See Postconditions:
|
|
|||||||||
|
Returns true if
See
|
|
|||||||||
|
Release the ownership of the underlying array.
After this function is called then the client is responsible for deleting the returned pointer no matter how many
Note that this function does not have the exact same semantics as does Postconditions:
|
|
|||||||||
|
Create a new weak RCP object from another RCP object. ToDo: Explain this! Preconditons:
Postconditons:
|
|
||||||||||||||
|
Returns true if the smart pointers share the same underlying reference-counted object.
This method does more than just check if |
|
|||||||||
|
Throws
|
|
||||||||||||||||
|
Throws
|
|
|||||||||
|
If the object pointer is non-null, assert that it is still valid.
If
If In this context, null is a valid object. |
|
|||||||||
|
Returns
|
|
||||||||||
|
Wrap an
|
|
||||||||||
|
Wrap a
|
| ||||||||||||