NEST  2.6.0,not_revisioned_source_dir@0
Classes | Public Member Functions | Private Attributes | List of all members
lockPTR< D > Class Template Reference

This template is the standard safe-pointer implementation of SYNOD. More...

#include <lockptr.h>

Inheritance diagram for lockPTR< D >:
lockPTRDatum< D, slt >

Classes

class  PointerObject
 

Public Member Functions

 lockPTR (D *p=NULL)
 
 lockPTR (D &p_o)
 
 lockPTR (const lockPTR< D > &spd)
 
virtual ~lockPTR ()
 
lockPTR< D > operator= (const lockPTR< D > &spd)
 
lockPTR< D > operator= (D &s)
 
lockPTR< D > operator= (D const &s)
 
D * get (void)
 
D * get (void) const
 
D * operator-> () const
 
D * operator-> ()
 
D & operator* ()
 
const D & operator* () const
 
bool operator! () const
 < returns true if and only if obj->pointee == NULL More...
 
bool operator== (const lockPTR< D > &p) const
 
bool operator!= (const lockPTR< D > &p) const
 
bool valid (void) const
 < returns true if and only if obj->pointee != NULL More...
 
bool islocked (void) const
 
bool deletable (void) const
 
void lock (void) const
 
void unlock (void) const
 
void unlock (void)
 
size_t references (void) const
 

Private Attributes

PointerObjectobj
 

Detailed Description

template<class D>
class lockPTR< D >

This template is the standard safe-pointer implementation of SYNOD.

In order for this scheme to work smoothly, the user has to take some precautions:

  1. each pointer should only be used ONCE to initialize a lockPTR.
  2. The lockPTR assumes that there are no other access points to the protected pointer.
  3. The lockPTR can freely be copied and passed between objects and functions.
  4. lockPTR objects should be used like the pointer to the object.
  5. lockPTR objects should be passed as objects in function calls and function return values.
  6. There should be no pointers to lockPTR objects.

Class lockPTR is designed to behave just like the pointer would. You can use the dereference operators (* and ->) to access the protected object. However, the pointer itself is (with exceptions) never exposed to the user.

Since all access to the referenced object is done via a lockPTR, it is possible to maintain a count of all active references. If this count dropts to zero, the referenced object can savely be destroyed. For dynamically allocated objects, delete is envoked on the stored pointer.

class lockPTR distinguishes between dynamically and automatically allocated objects by the way it is initialised:

If a lockPTR is initialised with a pointer, it assumes that the referenced object was dynamically allocated and will call the destructor once the reference count drops to zero.

If the lockPTR is initialised with a reference, it assumes that the object is automatically allocated. Thus, the lockPTR wil NOT call the destructor.

In some cases it is necessary for a routine to actually get hold of the pointer, contained in the lockPTR object. This can be done by using the member function get(). After the pointer has been exposed this way, the lockPTR will regard the referenced object as unsafe, since the user might call delete on the pointer. Thus, lockPTR will "lock" the referenced object and deny all further access. The object can be unlocked by calling the unlock() member.

Equality for lockPTRs is defined as identity of the data object.

Constructor & Destructor Documentation

template<class D>
lockPTR< D >::lockPTR ( D *  p = NULL)
inlineexplicit
template<class D>
lockPTR< D >::lockPTR ( D &  p_o)
inlineexplicit
template<class D>
lockPTR< D >::lockPTR ( const lockPTR< D > &  spd)
inline
template<class D>
virtual lockPTR< D >::~lockPTR ( )
inlinevirtual

Member Function Documentation

template<class D>
bool lockPTR< D >::deletable ( void  ) const
inline
template<class D>
D* lockPTR< D >::get ( void  )
inline
template<class D>
D* lockPTR< D >::get ( void  ) const
inline
template<class D>
bool lockPTR< D >::islocked ( void  ) const
inline
template<class D>
void lockPTR< D >::lock ( void  ) const
inline
template<class D>
bool lockPTR< D >::operator! ( ) const
inline

< returns true if and only if obj->pointee == NULL

template<class D>
bool lockPTR< D >::operator!= ( const lockPTR< D > &  p) const
inline
template<class D>
D& lockPTR< D >::operator* ( )
inline
template<class D>
const D& lockPTR< D >::operator* ( ) const
inline
template<class D>
D* lockPTR< D >::operator-> ( ) const
inline
template<class D>
D* lockPTR< D >::operator-> ( )
inline
template<class D>
lockPTR<D> lockPTR< D >::operator= ( const lockPTR< D > &  spd)
inline
template<class D>
lockPTR<D> lockPTR< D >::operator= ( D &  s)
inline
template<class D>
lockPTR<D> lockPTR< D >::operator= ( D const &  s)
inline
template<class D>
bool lockPTR< D >::operator== ( const lockPTR< D > &  p) const
inline
template<class D>
size_t lockPTR< D >::references ( void  ) const
inline
template<class D>
void lockPTR< D >::unlock ( void  ) const
inline
template<class D>
void lockPTR< D >::unlock ( void  )
inline
template<class D>
bool lockPTR< D >::valid ( void  ) const
inline

< returns true if and only if obj->pointee != NULL

Referenced by nest::ConnectionCreator::convergent_connect_(), PrintFunction::execute(), PrettyprintFunction::execute(), CloseistreamFunction::execute(), FlushFunction::execute(), EndlFunction::execute(), EndsFunction::execute(), IparseFunction::execute(), EatwhiteFunction::execute(), SetwFunction::execute(), SetprecisionFunction::execute(), IOSFixedFunction::execute(), IOSScientificFunction::execute(), IOSDefaultFunction::execute(), IOSShowpointFunction::execute(), IOSNoshowpointFunction::execute(), IOSShowbaseFunction::execute(), IOSNoshowbaseFunction::execute(), IOSDecFunction::execute(), IOSHexFunction::execute(), IOSOctFunction::execute(), IOSLeftFunction::execute(), IOSRightFunction::execute(), IOSInternalFunction::execute(), GetcFunction::execute(), GetsFunction::execute(), GetlineFunction::execute(), IGoodFunction::execute(), IClearFunction::execute(), OClearFunction::execute(), IFailFunction::execute(), OGoodFunction::execute(), IEofFunction::execute(), OEofFunction::execute(), In_AvailFunction::execute(), ReadDoubleFunction::execute(), ReadIntFunction::execute(), ReadWordFunction::execute(), nest::Node::get_status_base(), PgetrusageFunction::getinfo_(), SLIStartup::init(), librandom::BinomialRandomDev::ldev(), librandom::PoissonRandomDev::ldev(), librandom::RandomDev::ldev(), librandom::RandomDev::operator()(), nest::Node::set_status_base(), nest::ConnectionCreator::source_driven_connect_(), and nest::ConnectionCreator::target_driven_connect_().

Member Data Documentation

template<class D>
PointerObject* lockPTR< D >::obj
private

The documentation for this class was generated from the following file: