Switch branches/tags
v0_8_3 v0_8_2 v0_8_1 start smcq030515 rt-dance-branch-point rel-1_1_6 refactor-stage_6 presequpdate2 presendfile preondemand preiiopopt precorbae prearray preAnyRefactor pre_1_4_5 pre_recursive_typecodes pre_reactor_deadlock pre_pp_endpoint pre_pluggable_av_merge pre_orbsvcs_split pre_oci_asynch_imr_trunk pre_oci_asynch_imr_merge pre_non_tss_orb_core pre_new_load_balancer_01 pre_multiple_profile_server pre_merge_886 pre_merge_non_interpretive pre_memory_leak_fixes pre_mda_cleanup pre_log_msg_dep_break pre_local_policies pre_fix_bug132 pre_dynamic_any pre_doxygen_ace pre_bug_1269 pre_beta_atd_20020715 pre_bala_pmb_optimize pre_avsvc_split pre_ami_phase3_merge pre_ami_phase2_merge pre_ami_phase1_merge pre_TAO_0_2 pre_OBV_patch pre-typecode-rewrite-merge pre-subset pre-stream-code-reorganization pre-refactor pre-refactor-stage3 pre-refactor-stage2 pre-new-any pre-dyn-corba pre-corba-env-clean-merge pre-connect-strategy pre-SHM pre-PI2 pre-LocalObject pre-IDL3 pre-CIAO-1 pre-CIAO-0 pre-CCM-Core pre-AX0 post_recursive_typecodes post_poa_merge post_pluggable_av_merge post_mt_posix_proactor post_log_msg_dep_break post_bug_1269 post-poa-skeleton-refactor post-corba-env-clean-merge post-connect-strategy pos_pp_endpoint pos_orbsvcs_split pos_non_tss_orb_core pos_multiple_profile_server pos_merge_886 pos_merge_non_interpretive pos_local_policies pos_fix_bug_1222 pos_fix_bug132 pos_dynamic_any pos_doxygen_ace pos_avsvc_split pos_ami_phase3_merge pos_ami_phase2_merge pos_ami_phase1_merge pos_OBV_patch poa_start poa_real_end poa_end pns_start pns_branch_start pnotify_start pmb_integration_start pmb_integration_mike_start pmb_integration_greedyread pmb_branch_start pmb_branch_ocitao_patch_1_generation pmb_branch_mainline_mergeout_1 pluggable_testing
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
163 lines (122 sloc) 4.85 KB
// -*- C++ -*-
* @file Intrusive_Auto_Ptr.h
* @author Iliyan Jeliazkov <>
* @note Modeled on
#include /**/ "ace/pre.h"
#include "ace/Atomic_Op.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
// Forward decl.
template <class X> class ACE_Intrusive_Auto_Ptr;
* @class ACE_Intrusive_Auto_Ptr
* @brief This class implements support for a reference counted
* auto_ptr. It assumes reference counting abilities of the
* parameterizing class.
* Assigning or copying instances of an ACE_Intrusive_Auto_Ptr will
* automatically increment the reference count. When the last instance
* that references a ACE_Intrusive_Auto_Ptr instance is destroyed or
* overwritten, it will invoke delete on its underlying pointer.
* The ACE_Intrusive_Auto_Ptr works by maintaining a reference to a
* separate representation object, ACE_Intrusive_Auto_Ptr_Rep. That
* separate representation object contains the reference count and the
* actual pointer value.
template <class X>
class ACE_Intrusive_Auto_Ptr
/// Used to define a proper boolean conversion for "if (sp) ..."
static void unspecified_bool(ACE_Intrusive_Auto_Ptr<X>***){};
typedef void (*unspecified_bool_type)(ACE_Intrusive_Auto_Ptr<X>***);
/// Enables "if (sp) ..."
operator unspecified_bool_type() const
return rep_ == 0 ? 0: unspecified_bool;
// = Initialization and termination methods.
/// Constructor that initializes an ACE_Intrusive_Auto_Ptr to
/// the specified pointer value.
ACE_Intrusive_Auto_Ptr (X *p = 0, bool addref = true);
/// Copy constructor binds the new ACE_Intrusive_Auto_Ptr to the
/// representation object referenced by @a r.
/// An ACE_Intrusive_Auto_Ptr_Rep is created if necessary.
ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr<X> &r);
// Derived class copy ctor
template<class U> ACE_Intrusive_Auto_Ptr(const ACE_Intrusive_Auto_Ptr<U> & rhs);
/// Destructor. Releases the reference to the underlying representation.
/// If the release of that reference causes its reference count to reach 0,
/// the representation object will also be destroyed.
virtual ~ACE_Intrusive_Auto_Ptr (void);
/// Assignment operator that binds the current object and @a r to the same
/// ACE_Intrusive_Auto_Ptr_Rep. An ACE_Intrusive_Auto_Ptr_Rep
/// is created if necessary.
void operator = (const ACE_Intrusive_Auto_Ptr<X> &r);
/// Redirection operator
X *operator-> (void) const;
/// Accessor method.
X &operator *() const;
/// Releases the reference to the underlying representation object.
/// @retval The pointer value prior to releasing it.
X *release (void);
/// Releases the current pointer value and then sets a new
/// pointer value specified by @a p.
void reset (X *p = 0);
/// Get the pointer value.
X *get (void) const;
/// Get the reference count value.
long count (void) const;
/// Returns @c true if this object does not contain a valid pointer.
// bool null (void) const;
/// Declare the dynamic allocation hooks.
/// Protect operations on the ACE_Intrusive_Auto_Ptr.
X *rep_;
/// Equality operator that returns @c true if both
/// ACE_Intrusive_Auto_Ptr objects point to the same underlying
/// representation. It does not compare the actual pointers.
* @note It also returns @c true if both objects have just been
* instantiated and not used yet.
template<class T, class U>
bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b);
/// Inequality operator, which is the opposite of equality.
template<class T, class U>
bool operator!=(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b);
template<class T, class U>
bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, U * b);
template<class T, class U>
bool operator!=(ACE_Intrusive_Auto_Ptr<T> & a, U * b);
template<class T, class U>
bool operator==(T * a, ACE_Intrusive_Auto_Ptr<U> const & b);
template<class T, class U>
bool operator!=(T * a, ACE_Intrusive_Auto_Ptr<U> const & b);
#if defined (__ACE_INLINE__)
#include "ace/Intrusive_Auto_Ptr.inl"
#endif /* __ACE_INLINE __ */
#include "ace/Intrusive_Auto_Ptr.cpp"
#pragma implementation ("Intrusive_Auto_Ptr.cpp")
#include /**/ "ace/post.h"