oasys::Ref< _Type > Class Template Reference

#include <Ref.h>

List of all members.


Detailed Description

template<typename _Type>
class oasys::Ref< _Type >

Smart pointer class to maintain reference counts on objects.

The reference template expects the instatiating _Type to implement methods for adding and deleting references that fit the following signature:

void add_ref(const char* what1, const char* what2); void del_ref(const char* what1, const char* what2);

For example, see the RefCountedObject class.

The strings what1 and what2 can be used for debugging and are stored in the reference. Note that what1 is mandatory and is typically the function name or object class that is holding the reference. What2 is any other additional information used to distinguish the instance.

Definition at line 46 of file Ref.h.


Public Member Functions

 Ref (const char *what1="!!DEFAULT REF CONSTRUCTOR!!", const char *what2="")
 Constructor that initializes the pointer to be empty.
 Ref (_Type *object, const char *what1, const char *what2="")
 Constructor that takes an initial pointer for assignment.
 Ref (const TempRef< _Type > temp)
 Constructor that takes a temporary ref.
 Ref (const Ref &other)
 Copy constructor.
 ~Ref ()
 Destructor.
void release ()
 Release the reference on the object.
_Type * object () const
 Accessor for the object pointer.
const _Type * const_object () const
 Accessor for a const object pointer.
_Type * operator-> () const
 Operator overload for pointer access.
_Type & operator * () const
 Operator overload for pointer access.
void assign (_Type *new_obj)
 Assignment function.
Refoperator= (_Type *o)
 Assignment operator.
Refoperator= (const Ref< _Type > &other)
 Assignment operator.
Refoperator= (const TempRef< _Type > &temp)
 Assignment operator from a temporary ref.
bool operator== (_Type *o) const
 Equality operator.
bool operator== (const Ref< _Type > &other) const
 Equality operator.
bool operator!= (_Type *o) const
 Inequality operator.
bool operator!= (const Ref< _Type > &other) const
 Equality operator.

Private Member Functions

 Ref (_Type *object)
 Constructor (deliberately private and unimplemented) that takes a _Type* pointer but no debugging string.

Private Attributes

_Type * object_
 The object.
const char * what1_
 Debugging strings.
const char * what2_

Constructor & Destructor Documentation

template<typename _Type>
oasys::Ref< _Type >::Ref ( const char *  what1 = "!!DEFAULT REF CONSTRUCTOR!!",
const char *  what2 = "" 
) [inline]

Constructor that initializes the pointer to be empty.

Note: we need the default constructor because otherwise Ref cannot be placed in an STL container.

Definition at line 54 of file Ref.h.

template<typename _Type>
oasys::Ref< _Type >::Ref ( _Type *  object,
const char *  what1,
const char *  what2 = "" 
) [inline]

Constructor that takes an initial pointer for assignment.

Definition at line 62 of file Ref.h.

References oasys::Ref< _Type >::object_, oasys::Ref< _Type >::what1_, and oasys::Ref< _Type >::what2_.

template<typename _Type>
oasys::Ref< _Type >::Ref ( _Type *  object  )  [private]

Constructor (deliberately private and unimplemented) that takes a _Type* pointer but no debugging string.

This is intended to cause the compiler to complain both that it's private, and to provide ambiguity (with the first constructor) when called with a single argument of NULL, hence forcing the caller to pass at least char* debug string.

template<typename _Type>
oasys::Ref< _Type >::Ref ( const TempRef< _Type >  temp  )  [inline]

Constructor that takes a temporary ref.

Definition at line 86 of file Ref.h.

References oasys::TempRef< _Type >::object(), oasys::Ref< _Type >::object_, oasys::TempRef< _Type >::release(), oasys::Ref< _Type >::what1_, and oasys::Ref< _Type >::what2_.

template<typename _Type>
oasys::Ref< _Type >::Ref ( const Ref< _Type > &  other  )  [inline]

Copy constructor.

Definition at line 100 of file Ref.h.

References oasys::Ref< _Type >::object(), oasys::Ref< _Type >::object_, oasys::Ref< _Type >::what1_, and oasys::Ref< _Type >::what2_.

template<typename _Type>
oasys::Ref< _Type >::~Ref (  )  [inline]

Destructor.

Definition at line 113 of file Ref.h.

References oasys::Ref< _Type >::release().


Member Function Documentation

template<typename _Type>
void oasys::Ref< _Type >::release (  )  [inline]

Release the reference on the object.

Definition at line 121 of file Ref.h.

References oasys::Ref< _Type >::object_, oasys::Ref< _Type >::what1_, and oasys::Ref< _Type >::what2_.

Referenced by dtn::BundleDaemon::delete_from_pending(), and oasys::Ref< _Type >::~Ref().

template<typename _Type>
_Type* oasys::Ref< _Type >::object (  )  const [inline]

Accessor for the object pointer.

Definition at line 132 of file Ref.h.

References oasys::Ref< _Type >::object_.

Referenced by dtn::BundleOfferList::add_offer(), dtn::StreamConvergenceLayer::Connection::check_completed(), dtn::UDPConvergenceLayer::close_contact(), dtn::ConvergenceLayer::close_contact(), dtn::ConnectionConvergenceLayer::close_contact(), dtn::CLConnection::close_contact(), dtn::BundleCommand::exec(), dtn::ProphetEncounter::fwd_to_nexthop(), dtn::TclRegistration::get_bundle_data(), dtn::BundleDaemon::handle_bundle_accept(), dtn::BundleDaemon::handle_bundle_cancel(), dtn::ProphetController::handle_bundle_delivered(), dtn::ProphetController::handle_bundle_expired(), dtn::ProphetEncounter::handle_bundle_received(), dtn::ProphetController::handle_bundle_received(), dtn::BundleDaemon::handle_bundle_send(), dtn::ProphetEncounter::handle_bundle_tlv(), dtn::BundleDaemon::handle_contact_down(), dtn::NeighborhoodRouter::handle_contact_up(), dtn::BundleDaemon::handle_contact_up(), dtn::TableBasedRouter::handle_custody_timeout(), dtn::ProphetController::handle_link_state_change_request(), dtn::BundleDaemon::handle_link_state_change_request(), dtn::BundleDaemon::handle_reassembly_completed(), dtn::APIClient::handle_recv(), dtn::APIClient::handle_send(), dtn::BundleList::move_contents(), dtn::ProphetController::neighbor_gone(), dtn::ProphetController::new_neighbor(), dtn::Link::open(), dtnsim::SimConvergenceLayer::open_contact(), dtn::TclRegistration::parse_bundle_data(), dtn::CLConnection::process_command(), dtn::FragmentManager::process_for_reassembly(), oasys::Ref< _Type >::Ref(), dtn::UDPConvergenceLayer::send_bundle(), dtn::NullConvergenceLayer::send_bundle(), dtn::ConnectionConvergenceLayer::send_bundle(), dtn::ProphetEncounter::send_bundle_offer(), dtn::ProphetEncounter::send_prophet_tlv(), dtn::CustodyTimeoutEvent::serialize(), dtn::ContactDownEvent::serialize(), dtn::ContactUpEvent::serialize(), dtn::BundleAcceptRequest::serialize(), dtn::BundleExpiredEvent::serialize(), dtn::BundleDeliveryEvent::serialize(), dtn::BundleTransmitFailedEvent::serialize(), dtn::BundleTransmittedEvent::serialize(), dtn::BundleReceivedEvent::serialize(), dtn::ExpirationTimer::timeout(), and dtn::CustodyTimer::timeout().

template<typename _Type>
const _Type* oasys::Ref< _Type >::const_object (  )  const [inline]

Accessor for a const object pointer.

Definition at line 140 of file Ref.h.

References oasys::Ref< _Type >::object_.

template<typename _Type>
_Type* oasys::Ref< _Type >::operator-> (  )  const [inline]

Operator overload for pointer access.

Definition at line 148 of file Ref.h.

References ASSERT, and oasys::Ref< _Type >::object_.

template<typename _Type>
_Type& oasys::Ref< _Type >::operator * (  )  const [inline]

Operator overload for pointer access.

Definition at line 157 of file Ref.h.

References ASSERT, and oasys::Ref< _Type >::object_.

template<typename _Type>
void oasys::Ref< _Type >::assign ( _Type *  new_obj  )  [inline]

Assignment function.

Definition at line 166 of file Ref.h.

References oasys::Ref< _Type >::object_, oasys::Ref< _Type >::what1_, and oasys::Ref< _Type >::what2_.

Referenced by dtn::APIClient::handle_send(), and oasys::Ref< _Type >::operator=().

template<typename _Type>
Ref& oasys::Ref< _Type >::operator= ( _Type *  o  )  [inline]

Assignment operator.

Definition at line 185 of file Ref.h.

References oasys::Ref< _Type >::assign().

template<typename _Type>
Ref& oasys::Ref< _Type >::operator= ( const Ref< _Type > &  other  )  [inline]

Assignment operator.

Definition at line 194 of file Ref.h.

References oasys::Ref< _Type >::assign(), and oasys::Ref< _Type >::object_.

template<typename _Type>
Ref& oasys::Ref< _Type >::operator= ( const TempRef< _Type > &  temp  )  [inline]

Assignment operator from a temporary ref.

Definition at line 203 of file Ref.h.

References oasys::Ref< _Type >::assign(), oasys::TempRef< _Type >::object(), oasys::Ref< _Type >::object_, and oasys::TempRef< _Type >::release().

template<typename _Type>
bool oasys::Ref< _Type >::operator== ( _Type *  o  )  const [inline]

Equality operator.

Definition at line 215 of file Ref.h.

References oasys::Ref< _Type >::object_.

template<typename _Type>
bool oasys::Ref< _Type >::operator== ( const Ref< _Type > &  other  )  const [inline]

Equality operator.

Definition at line 223 of file Ref.h.

References oasys::Ref< _Type >::object_.

template<typename _Type>
bool oasys::Ref< _Type >::operator!= ( _Type *  o  )  const [inline]

Inequality operator.

Definition at line 231 of file Ref.h.

References oasys::Ref< _Type >::object_.

template<typename _Type>
bool oasys::Ref< _Type >::operator!= ( const Ref< _Type > &  other  )  const [inline]

Equality operator.

Definition at line 239 of file Ref.h.

References oasys::Ref< _Type >::object_.


Member Data Documentation

template<typename _Type>
_Type* oasys::Ref< _Type >::object_ [private]

The object.

Definition at line 248 of file Ref.h.

Referenced by oasys::Ref< _Type >::assign(), oasys::Ref< _Type >::const_object(), oasys::Ref< _Type >::object(), oasys::Ref< _Type >::operator *(), oasys::Ref< _Type >::operator!=(), oasys::Ref< _Type >::operator->(), oasys::Ref< _Type >::operator=(), oasys::Ref< _Type >::operator==(), oasys::Ref< _Type >::Ref(), and oasys::Ref< _Type >::release().

template<typename _Type>
const char* oasys::Ref< _Type >::what1_ [private]

Debugging strings.

Definition at line 253 of file Ref.h.

Referenced by oasys::Ref< _Type >::assign(), oasys::Ref< _Type >::Ref(), and oasys::Ref< _Type >::release().

template<typename _Type>
const char * oasys::Ref< _Type >::what2_ [private]

Definition at line 253 of file Ref.h.

Referenced by oasys::Ref< _Type >::assign(), oasys::Ref< _Type >::Ref(), and oasys::Ref< _Type >::release().


The documentation for this class was generated from the following file:
Generated on Sat Sep 8 08:36:26 2007 for DTN Reference Implementation by  doxygen 1.5.3