CH< CandType > Class Template Reference

#include <CH.h>

Inheritance diagram for CH< CandType >:

CandHandle List of all members.

Public Types

 DereferenceNil
enum  ErrorType { DereferenceNil }

Public Member Functions

 CH ()
 CH (CandBase *cb)
 CH (const CandHandle &ch)
template<class T>
 CH (const CH< T > &ch)
template<class T>
 operator CH ()
const CandType * operator-> () const
const CandType & operator * () const
CH< CandType > & operator= (const CandHandle &rhs)
template<class T>
CH< CandType > & operator= (const CH< T > &rhs)
virtual CH< CandType > * DupHandle () const
bool IsValid () const
const CandType & RCmd () const
CandType & WCmd ()

Detailed Description

template<class CandType>
class CH< CandType >

Definition at line 18 of file CH.h.


Member Enumeration Documentation

template<class CandType>
enum CH::ErrorType

Enumerator:
DereferenceNil 

Definition at line 22 of file CH.h.

00022 {DereferenceNil};


Constructor & Destructor Documentation

template<class CandType>
CH< CandType >::CH (  ) 

Definition at line 63 of file CH.h.

00063                  :
00064   CandHandle(0)
00065 {
00066 }

template<class CandType>
CH< CandType >::CH ( CandBase cb  ) 

Definition at line 70 of file CH.h.

00070                              :
00071   CandHandle(dynamic_cast<CandType*>(cb))
00072 {
00073 }

template<class CandType>
CH< CandType >::CH ( const CandHandle ch  ) 

Definition at line 77 of file CH.h.

00078 {
00079   *this = const_cast<CandHandle &>(ch);
00080 }

template<class CandType>
template<class T>
CH< CandType >::CH ( const CH< T > &  ch  ) 

Definition at line 169 of file CH.h.

00170 {
00171   *this = const_cast<CH<T>&>(ch);
00172 }


Member Function Documentation

template<class CandType>
CH< CandType > * CH< CandType >::DupHandle (  )  const [virtual]

Reimplemented from CandHandle.

Definition at line 110 of file CH.h.

00111 {
00112    return (new CH<CandType>(*this));
00113 }

template<class CandType>
bool CH< CandType >::IsValid (  )  const

Definition at line 117 of file CH.h.

References CandHandle::GetCandBase().

00118 {
00119   return dynamic_cast<const CandType*>(GetCandBase());
00120 }

template<class CandType>
const CandType & CH< CandType >::operator * (  )  const

Definition at line 132 of file CH.h.

References CandHandle::GetCandBase().

00133 {
00134   const CandType* cb = dynamic_cast<const CandType*>(GetCandBase());
00135   return *cb;
00136 }

template<class CandType>
template<class T>
CH< CandType >::operator CH< T > (  ) 

Definition at line 177 of file CH.h.

References CandHandle::GetCandBase().

00178 {
00179   return CH<T>(GetCandBase());
00180 }

template<class CandType>
const CandType * CH< CandType >::operator-> (  )  const

Definition at line 124 of file CH.h.

References CandHandle::GetCandBase().

00125 {
00126   const CandType* cb = dynamic_cast<const CandType*>(GetCandBase());
00127   return cb;
00128 }

template<class CandType>
template<class T>
CH< CandType > & CH< CandType >::operator= ( const CH< T > &  rhs  ) 

Definition at line 185 of file CH.h.

References CandHandle::GetCandBase().

00186 {
00187   CandHandle *chlhs = dynamic_cast<CandHandle*>(this);
00188   const CandHandle *chrhs = dynamic_cast<const CandHandle*>(&rhs);
00189   const CandType *refCrhs =
00190                     dynamic_cast<const CandType*>(chrhs->GetCandBase());
00191   
00192   if (refCrhs) {
00193     if (refCrhs == chlhs->GetCandBase()) {
00194       return *this;
00195     }  
00196     else {
00197       CandHandle chnew(const_cast<CandType*>(refCrhs));
00198       *chlhs = chnew;                    // Invoke CandHandle::operator=
00199       return *this;
00200     }
00201   }
00202   else {
00203     CandHandle chnew((CandBase*)0);
00204     *chlhs = chnew;                      // Invoke CandHandle::operator=
00205     return *this;
00206   }
00207 }

template<class CandType>
CH< CandType > & CH< CandType >::operator= ( const CandHandle rhs  ) 

Reimplemented from CandHandle.

Definition at line 84 of file CH.h.

References CandHandle::GetCandBase().

00085 {
00086   CandHandle *chlhs = dynamic_cast<CandHandle*>(this);
00087   const CandHandle *chrhs = dynamic_cast<const CandHandle*>(&rhs);
00088   const CandType *refCrhs =
00089                     dynamic_cast<const CandType*>(chrhs->GetCandBase());
00090   
00091   if (refCrhs) {
00092     if (refCrhs == chlhs->GetCandBase()) {
00093       return *this;
00094     }  
00095     else {
00096       CandHandle chnew(const_cast<CandType*>(refCrhs));
00097       *chlhs = chnew;                    // Invoke CandHandle::operator=
00098       return *this;
00099     }
00100   }
00101   else {
00102     CandHandle chnew((CandBase*)0);
00103     *chlhs = chnew;                      // Invoke CandHandle::operator=
00104     return *this;
00105   }
00106 }

template<class CandType>
const CandType & CH< CandType >::RCmd (  )  const

Definition at line 140 of file CH.h.

References CH< CandType >::DereferenceNil, and CandHandle::GetCandBase().

00141 {
00142   const CandType *cb = dynamic_cast<const CandType*>(GetCandBase());
00143   if (cb == 0) {
00144 //gmi MSG("Cand", Msg::kError)
00145 //gmi  << "Wrong type referenced from CandHandle " << GetName() << endl;
00146     throw CH::DereferenceNil;
00147   }
00148   return *cb;
00149 }

template<class CandType>
CandType & CH< CandType >::WCmd (  ) 

Definition at line 153 of file CH.h.

References CH< CandType >::DereferenceNil, and CandHandle::GetOwnedCandBase().

00154 {
00155   CandType *cb = dynamic_cast<CandType*>(GetOwnedCandBase());
00156   if (cb == 0) {
00157 //gmi MSG("Cand", Msg::kError)
00158 //gmi  << "Wrong type referenced from CandHandle " << GetName() << endl;
00159     throw CH::DereferenceNil;
00160   }
00161   return *cb;
00162 }


The documentation for this class was generated from the following file:
Generated on Mon Aug 11 01:05:39 2014 for loon by  doxygen 1.4.7