Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Friends
CLHEP::sp::shared_ctrl_handle Class Reference

#include <memory.h>

Public Member Functions

 shared_ctrl_handle () throw ()
 
template<typename P >
 shared_ctrl_handle (P *)
 
template<typename P , typename D >
 shared_ctrl_handle (P *, D)
 
template<typename P , typename D , typename A >
 shared_ctrl_handle (P *, D, A)
 
template<typename P >
 shared_ctrl_handle (std::auto_ptr< P > &)
 
 ~shared_ctrl_handle () throw ()
 
void swap (shared_ctrl_handle &) throw ()
 
 shared_ctrl_handle (shared_ctrl_handle const &) throw ()
 
shared_ctrl_handleoperator= (shared_ctrl_handle const &) throw ()
 
 shared_ctrl_handle (weak_ctrl_handle const &)
 
 shared_ctrl_handle (weak_ctrl_handle const &, sp_nothrow_tag)
 
voidget_deleter (std::type_info const &) const
 
bool unique () const throw ()
 
bool empty () const throw ()
 
long use_count () const throw ()
 

Friends

class weak_ctrl_handle
 
bool operator== (shared_ctrl_handle const &, shared_ctrl_handle const &)
 
bool operator< (shared_ctrl_handle const &, shared_ctrl_handle const &)
 

Detailed Description

Definition at line 407 of file memory.h.

Constructor & Destructor Documentation

CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( )
throw (
)
inline

Definition at line 456 of file memory.h.

457  : acb_ptr( 0 )
458 { }
template<typename P >
CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( P *  p)
inlineexplicit

Definition at line 461 of file memory.h.

464  : acb_ptr( 0 )
465 {
466  try {
467  acb_ptr = new ctrl_block_p<P>(p);
468  }
469  catch(...) {
470  delete p;
471  throw;
472  }
473 }
const char * p
Definition: xmltok.h:285
template<typename P , typename D >
CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( P *  p,
d 
)
inline

Definition at line 476 of file memory.h.

479  : acb_ptr( 0 )
480 {
481  try {
482  acb_ptr = new ctrl_block_pd<P,D>(p, d);
483  }
484  catch(...) {
485  d( p );
486  throw;
487  }
488 }
const char * p
Definition: xmltok.h:285
template<typename P , typename D , typename A >
CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( P *  p,
d,
a 
)
inline

Definition at line 491 of file memory.h.

492  : acb_ptr( 0 )
493 {
494  typedef ctrl_block_pda<P,D,A>
495  ctrl_block;
496  typedef typename A::template rebind<ctrl_block>::other
497  ctrl_block_allocator;
498  ctrl_block_allocator cba( a );
499 
500  try
501  {
502  acb_ptr = cba.allocate( 1 );
503  new( static_cast<void*>(acb_ptr) ) ctrl_block(p, d, a);
504  }
505  catch(...)
506  {
507  d( p );
508  if( acb_ptr != 0 )
509  cba.deallocate( static_cast<ctrl_block*>( acb_ptr ), 1 );
510  throw;
511  }
512 }
const char * p
Definition: xmltok.h:285
template<typename P >
CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( std::auto_ptr< P > &  p)
inlineexplicit

Definition at line 515 of file memory.h.

516  : acb_ptr( new ctrl_block_p<P>( p.get() ) )
517 {
518  p.release();
519 }
const char * p
Definition: xmltok.h:285
CLHEP::sp::shared_ctrl_handle::~shared_ctrl_handle ( )
throw (
)
inline

Definition at line 521 of file memory.h.

References CLHEP::sp::abstract_ctrl_block::release().

522 {
523  if( acb_ptr != 0 )
524  acb_ptr->release();
525 }
CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( shared_ctrl_handle const &  other)
throw (
)
inline

Definition at line 535 of file memory.h.

536  : acb_ptr( other.acb_ptr )
537 {
538  if( acb_ptr != 0 )
539  acb_ptr->add_ref();
540 }
CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( weak_ctrl_handle const &  other)
inlineexplicit

Definition at line 715 of file memory.h.

References CLHEP::sp::abstract_ctrl_block::add_ref_lock().

716  : acb_ptr( other.acb_ptr )
717 {
718  if( acb_ptr == 0 || ! acb_ptr->add_ref_lock() )
719  throw bad_weak_ptr();
720 }
CLHEP::sp::shared_ctrl_handle::shared_ctrl_handle ( weak_ctrl_handle const &  other,
sp_nothrow_tag   
)
inline

Definition at line 722 of file memory.h.

References CLHEP::sp::abstract_ctrl_block::add_ref_lock().

724  : acb_ptr( other.acb_ptr )
725 {
726  if( acb_ptr != 0 && ! acb_ptr->add_ref_lock() )
727  acb_ptr = 0;
728 }

Member Function Documentation

bool CLHEP::sp::shared_ctrl_handle::empty ( ) const
throw (
)
inline

Definition at line 570 of file memory.h.

571 {
572  return acb_ptr == 0;
573 }
void * CLHEP::sp::shared_ctrl_handle::get_deleter ( std::type_info const &  ti) const
inline

Definition at line 558 of file memory.h.

References CLHEP::sp::abstract_ctrl_block::get_deleter().

559 {
560  return acb_ptr ? acb_ptr->get_deleter( ti ) : 0;
561 }
virtual void * get_deleter(std::type_info const &ti)=0
shared_ctrl_handle & CLHEP::sp::shared_ctrl_handle::operator= ( shared_ctrl_handle const &  other)
throw (
)
inline

Definition at line 543 of file memory.h.

References CLHEP::sp::abstract_ctrl_block::add_ref().

544 {
545  abstract_ctrl_block * tmp = other.acb_ptr;
546 
547  if( tmp != acb_ptr )
548  {
549  if( tmp != 0 ) tmp->add_ref();
550  if( acb_ptr != 0 ) acb_ptr->release();
551  acb_ptr = tmp;
552  }
553 
554  return *this;
555 }
void CLHEP::sp::shared_ctrl_handle::swap ( shared_ctrl_handle other)
throw (
)
inline

Definition at line 528 of file memory.h.

529 {
530  abstract_ctrl_block * tmp = other.acb_ptr;
531  other.acb_ptr = acb_ptr;
532  acb_ptr = tmp;
533 }
bool CLHEP::sp::shared_ctrl_handle::unique ( ) const
throw (
)
inline

Definition at line 564 of file memory.h.

References use_count().

565 {
566  return 1L == use_count();
567 }
long use_count() const
Definition: memory.h:576
long CLHEP::sp::shared_ctrl_handle::use_count ( ) const
throw (
)
inline

Definition at line 576 of file memory.h.

References CLHEP::sp::abstract_ctrl_block::use_count().

Referenced by unique().

577 {
578  return acb_ptr == 0 ? 0L : acb_ptr->use_count();
579 }

Friends And Related Function Documentation

bool operator< ( shared_ctrl_handle const &  lhs,
shared_ctrl_handle const &  rhs 
)
friend

Definition at line 588 of file memory.h.

589 {
590  return std::less<abstract_ctrl_block*>()( lhs.acb_ptr, rhs.acb_ptr );
591 }
bool operator== ( shared_ctrl_handle const &  lhs,
shared_ctrl_handle const &  rhs 
)
friend

Definition at line 582 of file memory.h.

583 {
584  return lhs.acb_ptr == rhs.acb_ptr;
585 }
friend class weak_ctrl_handle
friend

Definition at line 409 of file memory.h.


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