43 #ifndef TEUCHOS_ARRAY_RCP_DECL_HPP
44 #define TEUCHOS_ARRAY_RCP_DECL_HPP
48 #include "Teuchos_Exceptions.hpp"
49 #include "Teuchos_ArrayViewDecl.hpp"
165 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
193 inline ArrayRCP( ENull null_arg =
null );
241 template<
class Dealloc_T>
353 inline T*
get()
const;
592 inline void assign(Iter first, Iter last);
783 inline TEUCHOS_DEPRECATED
int count()
const;
797 inline void debug_assert_not_null ()
const {
798 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
804 debug_assert_in_range (
size_type lowerOffset_in,
807 (void) lowerOffset_in;
809 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
814 inline void debug_assert_valid_ptr()
const {
822 #ifndef DOXYGEN_COMPILE
828 const RCPNodeHandle& node );
829 T* access_private_ptr()
const;
830 RCPNodeHandle& nonconst_access_private_node();
831 const RCPNodeHandle& access_private_node()
const;
847 typedef Teuchos_Ordinal
Ordinal;
859 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
867 inline ArrayRCP (ENull null_arg =
null);
871 template<
class Dealloc_T>
874 inline explicit ArrayRCP (size_type
size,
const T& val = T ());
882 inline const T*
get()
const;
884 inline const T&
operator[] (size_type offset)
const;
895 inline iterator
begin()
const;
896 inline iterator
end()
const;
908 inline size_type
size()
const;
914 inline void resize (
const size_type n,
const T& val = T ());
915 inline void clear ();
935 inline TEUCHOS_DEPRECATED
int count()
const;
940 size_type lowerOffset_;
941 size_type upperOffset_;
943 inline void debug_assert_not_null()
const {
944 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
950 debug_assert_in_range (size_type lowerOffset_in,
951 size_type size_in)
const
953 (void) lowerOffset_in; (void) size_in;
954 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
959 inline void debug_assert_valid_ptr()
const {
967 #ifndef DOXYGEN_COMPILE
974 const T* access_private_ptr()
const;
992 typedef Teuchos_Ordinal
Ordinal;
1017 typedef Teuchos_Ordinal
Ordinal;
1044 template<
typename T>
1061 bool owns_mem =
true
1070 template<
class T,
class Dealloc_T>
1075 Dealloc_T dealloc,
bool owns_mem
1128 template<
class T,
class Embedded>
1134 const Embedded &embedded,
1135 bool owns_mem =
true
1149 template<
class T,
class Embedded>
1155 const Embedded &embedded,
1156 bool owns_mem =
true
1171 template<
class T,
class Embedded>
1177 const Embedded &embedded,
1178 bool owns_mem =
true
1269 template<
class T1,
class T2>
1277 template<
class T1,
class T2>
1285 template<
class T1,
class T2>
1293 template<
class T1,
class T2>
1301 template<
class T1,
class T2>
1309 template<
class T1,
class T2>
1335 template<
class T2,
class T1>
1351 template<
class T2,
class T1>
1371 template<
class T2,
class T1>
1400 template<
class T2,
class T1>
1463 template<
class T1,
class T2>
1465 const T1 &extra_data,
const std::string& name,
1467 bool force_unique =
true );
1489 template<
class T1,
class T2>
1518 template<
class T1,
class T2>
1546 template<
class T1,
class T2>
1579 template<
class T1,
class T2>
1593 template<
class Dealloc_T,
class T>
1614 template<
class Dealloc_T,
class T>
1632 template<
class Dealloc_T,
class T>
1657 template<
class Dealloc_T,
class T>
1667 template<
class TOrig,
class Embedded,
class T>
1677 template<
class TOrig,
class Embedded,
class T>
Reference-counted pointer class and non-member templated function implementations.
Partial specialization of ArrayRCP for const T.
Reference-counted smart pointer for managing arrays.
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.
T & reference
Type of a (nonconstant) reference to an array element.
Embedded & getNonconstEmbeddedObj(const ArrayRCP< T > &p)
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(),...
size_type lowerOffset() const
Return the lower offset to valid data.
ArrayRCP< T > persistingView(size_type lowerOffset, size_type size) const
Return a persisting view of a contiguous range of elements.
ArrayRCP< T > arcpWithEmbeddedObjPostDestroy(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, const Embedded &embedded, bool owns_mem=true)
Create an ArrayRCP with and also put in an embedded object.
void set_has_ownership()
Give this and other ArrayRCP<> objects ownership of the underlying referenced array to delete it.
T1 & get_extra_data(ArrayRCP< T2 > &p, const std::string &name)
Get a non-const reference to extra data associated with a ArrayRCP object.
T * get() const
Get the raw C++ pointer to the underlying object.
ArrayRCP< T > & operator-=(size_type offset)
Pointer integer increment (i.e. ptr-=offset).
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
const T & const_reference
Type of a (constant) reference to an array element.
const ArrayRCP< T > & assert_not_null() const
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this.
Ordinal size_type
Type representing the number of elements in an ArrayRCP or view thereof.
Ordinal difference_type
Type representing the difference between two size_type values.
iterator begin() const
Return an iterator to beginning of the array of data.
ArrayRCP< T > arcp(typename ArrayRCP< T >::size_type size)
Allocate a new array just given a dimension.
std::random_access_iterator_tag iterator_category
Category of ArrayRCP's iterator type.
bool has_ownership() const
Returns true if this has ownership of object pointed to by this->get() in order to deallocate it.
bool operator!=(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare two ArrayRCP objects for inequality (by pointers).
Teuchos_Ordinal Ordinal
Integer index type used throughout ArrayRCP.
T * iterator
Nonconstant iterator type used if bounds checking is disabled.
ArrayRCP< T > arcpFromArrayView(const ArrayView< T > &av)
Get an ArrayRCP object out of an ArrayView object.
ArrayRCP< T > & operator=(const ArrayRCP< T > &r_ptr)
Assignment operator: Makes *this reference the input array.
ArrayRCP(ENull null_arg=null)
Default constructor; initialize to an empty array.
bool is_null() const
True if the underlying pointer is null, else false.
ArrayRCP< T2 > arcp_reinterpret_cast(const ArrayRCP< T1 > &p1)
Reinterpret cast of underlying ArrayRCP type from T1* to T2*.
ArrayRCP< const T > getConst() const
Return object for only const access to data.
const Dealloc_T * get_optional_dealloc(const ArrayRCP< T > &p)
Return a pointer to the underlying non-const deallocator object if it exists.
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.
const Dealloc_T & get_dealloc(const ArrayRCP< T > &p)
Return a const reference to the underlying deallocator object.
bool operator==(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare two ArrayRCP objects for equality (by pointers).
bool is_null(const ArrayRCP< T > &p)
Returns true if p.get()==NULL.
bool operator>=(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using >=.
ArrayRCP< T > & operator+=(size_type offset)
Pointer integer increment (i.e. ptr+=offset).
void clear()
Resize to zero.
ArrayRCP< T > operator+(size_type offset) const
Pointer integer increment (i.e. ptr+offset).
T value_type
Type of each array element.
ArrayRCP< T2 > arcp_const_cast(const ArrayRCP< T1 > &p1)
Const cast of underlying ArrayRCP type from const T* to T*.
ArrayRCP< T > create_strong() const
Create a new strong RCP object from another (weak) RCP object.
Dealloc_T * get_optional_nonconst_dealloc(const ArrayRCP< T > &p)
Return a pointer to the underlying const deallocator object if it exists.
iterator end() const
Return an iterator to past the end of the array of data.
ArrayRCP< T > arcp(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, Dealloc_T dealloc, bool owns_mem)
Wraps a preallocated array of data and uses a templated deallocation strategy object to define deleti...
void deepCopy(const ArrayView< const T > &av)
Deep copy the elements from one ArrayView object into this 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.
bool shares_resource(const ArrayRCP< T2 > &r_ptr) const
Returns true if the smart pointers share the same underlying reference-counted object.
T & operator[](size_type offset) const
Random object access.
ArrayView< T > operator()() const
Return a nonpersisting view of *this.
ArrayRCP< T > create_weak() const
Create a new weak reference from another (strong) reference.
ArrayRCP< T > arcpWithEmbeddedObj(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, const Embedded &embedded, bool owns_mem=true)
Create an ArrayRCP with and also put in an embedded object.
const T * const_iterator
Constant iterator type used if bounds checking is disabled.
const ArrayRCP< T > & assert_valid_ptr() const
If the object pointer is non-null, assert that it is still valid.
TEUCHOS_DEPRECATED int count() const
Returns strong_count() [deprecated].
T element_type
Type of each array element.
bool operator<(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using <.
ArrayRCP< T > arcp(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, bool owns_mem=true)
Wraps a preallocated array of data with the assumption to call the array version of delete.
std::ostream & operator<<(std::ostream &out, const ArrayRCP< T > &p)
Output stream inserter.
bool operator==(const ArrayRCP< T > &p, ENull)
Returns true if p.get()==NULL.
int strong_count() const
Return the number of active RCP<> objects that have a "strong" reference to the underlying reference-...
size_type upperOffset() const
Return the upper offset to valid data.
ArrayRCP< T > operator-(size_type offset) const
Pointer integer decrement (i.e. ptr-offset).
bool is_valid_ptr() const
Return whether the underlying object pointer is still valid.
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(...
ArrayRCP< T > & operator--()
Prefix decrement of pointer (i.e. –ptr).
void resize(const size_type n, const T &val=T())
Resize and append new elements if necessary.
ArrayRCP< T > arcpCloneNode(const ArrayRCP< T > &a)
Allocate a new ArrayRCP object with a new RCPNode with memory pointing to the initial node.
size_type size() const
The total number of entries in the array.
ArrayRCP< T2 > arcp_reinterpret_cast_nonpod(const ArrayRCP< T1 > &p1, const T2 &val=T2())
Reinterpret cast of underlying ArrayRCP type from T1* to T2* where T2 is a non-POD (non-plain-old-dat...
T * iterator_type
Type of an ArrayRCP's iterator.
void assign(size_type n, const T &val)
Resize and assign n elements of val.
~ArrayRCP()
Destructor, that decrements the reference count.
ERCPStrength strength() const
Strength of the pointer.
ArrayRCP< T > arcpClone(const ArrayView< const T > &v)
Allocate a new array by cloning data from an input array view.
T * release()
Release the ownership of the underlying array.
Dealloc_T & get_nonconst_dealloc(const ArrayRCP< T > &p)
Return a non-const reference to the underlying deallocator object.
ArrayRCP< T >::difference_type operator-(const ArrayRCP< T > &p1, const ArrayRCP< T > &p2)
Return the difference of two ArrayRCP objects.
const ArrayRCP< T > & assert_in_range(size_type lowerOffset, size_type size) const
Throws NullReferenceError if this->get()==NULL orthis->get()!=NULL, throws RangeError if (lowerOffset...
bool nonnull(const ArrayRCP< T > &p)
Returns true if p.get()!=NULL.
T * pointer
Type of a (raw) (nonconstant) pointer to an array element.
T * operator->() const
Pointer (->) access to members of underlying object for current position.
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() function ...
bool operator>(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using >.
ArrayRCP< T2 > arcp_implicit_cast(const ArrayRCP< T1 > &p1)
Implicit case the underlying ArrayRCP type from T1* to T2*.
ArrayRCP< T > arcpWithEmbeddedObjPreDestroy(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, const Embedded &embedded, bool owns_mem=true)
Create an ArrayRCP with and also put in an embedded object.
ArrayView< T > view(size_type lowerOffset, size_type size) const
Return a nonpersisting view of a contiguous range of elements.
T * const_pointer
Type of a (raw) (constant) pointer to an array element.
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.
ArrayRCP< const T > arcp(const RCP< const std::vector< T > > &v)
Wrap a const std::vector<T> object as an ArrayRCP<const T> object.
ArrayRCP< T > arcp(const RCP< std::vector< T > > &v)
Wrap an std::vector<T> object as an ArrayRCP<T> object.
ArrayRCP< T > & operator++()
Prefix increment of pointer (i.e. ++ptr).
bool operator<=(const ArrayRCP< T1 > &p1, const ArrayRCP< T2 > &p2)
Compare the two ArrayRCP objects' pointers using <=.
bool operator!=(const ArrayRCP< T > &p, ENull)
Returns true if p.get()!=NULL.
T & operator*() const
Dereference the underlying object for the current pointer position.
int weak_count() const
Return the number of active RCP<> objects that have a "weak" reference to the underlying reference-co...
const Embedded & getEmbeddedObj(const ArrayRCP< T > &p)
Get a const reference to an embedded object that was set by calling arcpWithEmbeddedObjPreDestroy(),...
int total_count() const
Total count (strong_count() + weak_count()).
Partial specialization of ArrayView for const T.
Base traits class for getting a properly initialized null pointer.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists.
Handle class that manages the RCPNode's reference counting.
Smart reference counting pointer class for automatic garbage collection.
ERCPStrength
Used to specify if the pointer is weak or strong.
ERCPNodeLookup
Used to determine if RCPNode lookup is performed or not.
EPrePostDestruction
Used to specify a pre or post destruction of extra data.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...