10 #ifndef TEUCHOS_ARRAY_RCP_DECL_HPP
11 #define TEUCHOS_ARRAY_RCP_DECL_HPP
15 #include "Teuchos_Exceptions.hpp"
16 #include "Teuchos_ArrayViewDecl.hpp"
132 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
208 template<
class Dealloc_T>
320 inline T*
get()
const;
559 inline void assign(Iter first, Iter last);
757 inline void debug_assert_not_null ()
const {
758 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
764 debug_assert_in_range (
size_type lowerOffset_in,
767 (void) lowerOffset_in;
769 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
774 inline void debug_assert_valid_ptr()
const {
782 #ifndef DOXYGEN_COMPILE
788 const RCPNodeHandle& node );
789 T* access_private_ptr()
const;
790 RCPNodeHandle& nonconst_access_private_node();
791 const RCPNodeHandle& access_private_node()
const;
807 typedef Teuchos_Ordinal
Ordinal;
819 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
831 template<
class Dealloc_T>
832 inline ArrayRCP (
const T* p, size_type lowerOffset, size_type size,
833 Dealloc_T dealloc,
bool has_ownership);
834 inline explicit ArrayRCP (size_type size,
const T& val = T ());
842 inline const T*
get()
const;
844 inline const T&
operator[] (size_type offset)
const;
855 inline iterator
begin()
const;
856 inline iterator
end()
const;
868 inline size_type
size()
const;
874 inline void resize (
const size_type n,
const T& val = T ());
875 inline void clear ();
898 size_type lowerOffset_;
899 size_type upperOffset_;
901 inline void debug_assert_not_null()
const {
902 #ifdef TEUCHOS_REFCOUNTPTR_ASSERT_NONNULL
908 debug_assert_in_range (size_type lowerOffset_in,
909 size_type size_in)
const
911 (void) lowerOffset_in; (void) size_in;
912 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
917 inline void debug_assert_valid_ptr()
const {
925 #ifndef DOXYGEN_COMPILE
930 ArrayRCP (
const T* p, size_type lowerOffset,
932 const T* access_private_ptr()
const;
950 typedef Teuchos_Ordinal
Ordinal;
975 typedef Teuchos_Ordinal
Ordinal;
1002 template<
typename T>
1019 bool owns_mem =
true
1028 template<
class T,
class Dealloc_T>
1033 Dealloc_T dealloc,
bool owns_mem
1086 template<
class T,
class Embedded>
1088 arcpWithEmbeddedObjPreDestroy(
1092 const Embedded &embedded,
1093 bool owns_mem =
true
1107 template<
class T,
class Embedded>
1109 arcpWithEmbeddedObjPostDestroy(
1113 const Embedded &embedded,
1114 bool owns_mem =
true
1129 template<
class T,
class Embedded>
1131 arcpWithEmbeddedObj(
1135 const Embedded &embedded,
1136 bool owns_mem =
true
1227 template<
class T1,
class T2>
1235 template<
class T1,
class T2>
1243 template<
class T1,
class T2>
1244 bool operator<( const ArrayRCP<T1> &p1,
const ArrayRCP<T2> &p2 );
1251 template<
class T1,
class T2>
1252 bool operator<=( const ArrayRCP<T1> &p1,
const ArrayRCP<T2> &p2 );
1259 template<
class T1,
class T2>
1267 template<
class T1,
class T2>
1293 template<
class T2,
class T1>
1309 template<
class T2,
class T1>
1329 template<
class T2,
class T1>
1358 template<
class T2,
class T1>
1421 template<
class T1,
class T2>
1422 void set_extra_data(
1423 const T1 &extra_data,
const std::string& name,
1425 bool force_unique =
true );
1447 template<
class T1,
class T2>
1448 T1& get_extra_data(
ArrayRCP<T2>& p,
const std::string& name );
1476 template<
class T1,
class T2>
1477 const T1& get_extra_data(
const ArrayRCP<T2>& p,
const std::string& name );
1504 template<
class T1,
class T2>
1505 T1* get_optional_extra_data(
ArrayRCP<T2>& p,
const std::string& name );
1537 template<
class T1,
class T2>
1538 const T1* get_optional_extra_data(
const ArrayRCP<T2>& p,
const std::string& name );
1551 template<
class Dealloc_T,
class T>
1552 Dealloc_T& get_nonconst_dealloc(
const ArrayRCP<T>& p );
1572 template<
class Dealloc_T,
class T>
1573 const Dealloc_T& get_dealloc(
const ArrayRCP<T>& p );
1590 template<
class Dealloc_T,
class T>
1591 const Dealloc_T* get_optional_dealloc(
const ArrayRCP<T>& p );
1615 template<
class Dealloc_T,
class T>
1616 Dealloc_T* get_optional_nonconst_dealloc(
const ArrayRCP<T>& p );
1625 template<
class TOrig,
class Embedded,
class T>
1626 const Embedded& getEmbeddedObj(
const ArrayRCP<T>& p );
1635 template<
class TOrig,
class Embedded,
class T>
1636 Embedded& getNonconstEmbeddedObj(
const ArrayRCP<T>& p );
1647 std::ostream& operator<<( std::ostream& out, const ArrayRCP<T>& p );
1653 #endif // TEUCHOS_ARRAY_RCP_DECL_HPP
const T * const_iterator
Constant iterator type used if bounds checking is disabled.
std::random_access_iterator_tag iterator_category
Category of ArrayRCP's iterator type.
ArrayRCP< T > create_weak() const
Create a new weak reference from another (strong) reference.
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...
ArrayRCP(ENull null_arg=null)
Default constructor; initialize to an empty array.
ArrayRCP< T > persistingView(size_type lowerOffset, size_type size) const
Return a persisting view of a contiguous range of elements.
Partial specialization of ArrayRCP for const T.
Ordinal difference_type
Type representing the difference between two size_type values.
ArrayRCP< T > & operator++()
Prefix increment of pointer (i.e. ++ptr).
ArrayRCP< T > & operator+=(size_type offset)
Pointer integer increment (i.e. ptr+=offset).
int weak_count() const
Return the number of active RCP<> objects that have a "weak" reference to the underlying reference-co...
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
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.
size_type upperOffset() const
Return the upper offset to valid data.
ArrayRCP< T > & operator--()
Prefix decrement of pointer (i.e. –ptr).
T * release()
Release the ownership of the underlying array.
ArrayRCP< const T > getConst() const
Return object for only const access to data.
ENull
Used to initialize a RCP object to NULL using an implicit conversion!
void clear()
Resize to zero.
size_type size() const
The total number of entries in the array.
Ordinal size_type
Type representing the number of elements in an ArrayRCP or view thereof.
~ArrayRCP()
Destructor, that decrements the reference count.
ERCPStrength strength() const
Strength of the pointer.
bool shares_resource(const ArrayRCP< T2 > &r_ptr) const
Returns true if the smart pointers share the same underlying reference-counted object.
bool is_valid_ptr() const
Return whether the underlying object pointer is still valid.
const ArrayRCP< T > & assert_not_null() const
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this.
T element_type
Type of each array element.
T * operator->() const
Pointer (->) access to members of underlying object for current position.
void resize(const size_type n, const T &val=T())
Resize and append new elements if necessary.
T * const_pointer
Type of a (raw) (constant) pointer to an array element.
Teuchos_Ordinal Ordinal
Integer index type used throughout ArrayRCP.
ArrayRCP< T > create_strong() const
Create a new strong RCP object from another (weak) RCP object.
T value_type
Type of each array element.
ArrayRCP< T > operator+(size_type offset) const
Pointer integer increment (i.e. ptr+offset).
void deepCopy(const ArrayView< const T > &av)
Deep copy the elements from one ArrayView object into this object.
size_type lowerOffset() const
Return the lower offset to valid data.
int total_count() const
Total count (strong_count() + weak_count()).
ERCPStrength
Used to specify if the pointer is weak or strong.
T & operator*() const
Dereference the underlying object for the current pointer position.
Base traits class for getting a properly initialized null pointer.
T * iterator_type
Type of an ArrayRCP's iterator.
const T & const_reference
Type of a (constant) reference to an array element.
T * pointer
Type of a (raw) (nonconstant) pointer to an array element.
void set_has_ownership()
Give this and other ArrayRCP<> objects ownership of the underlying referenced array to delete it...
Handle class that manages the RCPNode's reference counting.
ArrayView< T > operator()() const
Return a nonpersisting view of *this.
ERCPNodeLookup
Used to determine if RCPNode lookup is performed or not.
EPrePostDestruction
Used to specify a pre or post destruction of extra data.
int strong_count() const
Return the number of active RCP<> objects that have a "strong" reference to the underlying reference-...
ArrayRCP< T > & operator=(const ArrayRCP< T > &r_ptr)
Assignment operator: Makes *this reference the input array.
ArrayRCP< T > operator-(size_type offset) const
Pointer integer decrement (i.e. ptr-offset).
Smart reference counting pointer class for automatic garbage collection.
T & operator[](size_type offset) const
Random object access.
T * iterator
Nonconstant iterator type used if bounds checking is disabled.
iterator end() const
Return an iterator to past the end of the array of data.
Partial specialization of ArrayView for const T.
T & reference
Type of a (nonconstant) reference to an array element.
bool is_null() const
True if the underlying pointer is null, else false.
Reference-counted pointer class and non-member templated function implementations.
const ArrayRCP< T > & assert_valid_ptr() const
If the object pointer is non-null, assert that it is still valid.
iterator begin() const
Return an iterator to beginning of the array of data.
bool has_ownership() const
Returns true if this has ownership of object pointed to by this->get() in order to deallocate it...
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
void assign(size_type n, const T &val)
Resize and assign n elements of val.
Reference-counted smart pointer for managing arrays.
ArrayView< T > view(size_type lowerOffset, size_type size) const
Return a nonpersisting view of a contiguous range of elements.