CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ora::UniqueRef< T > Class Template Reference

#include <UniqueRef.h>

List of all members.

Public Member Functions

void * address () const
template<class C >
UniqueRef< T > & cast (const UniqueRef< C > &)
Tget () const
bool isLoaded () const
boost::shared_ptr< IPtrLoader > & loader () const
 operator bool () const
bool operator! () const
template<class C >
bool operator!= (const UniqueRef< C > &aPtr) const
Toperator* () const
Toperator-> () const
template<class C >
UniqueRef< T > & operator= (const UniqueRef< C > &)
UniqueRef< T > & operator= (const UniqueRef< T > &)
UniqueRef< T > & operator= (T *)
template<class C >
bool operator== (const UniqueRef< C > &aPtr) const
void reset ()
boost::shared_ptr< T > & share () const
const std::type_info * typeInfo () const
 UniqueRef (const UniqueRef< T > &)
 UniqueRef (T *anObject)
template<class C >
 UniqueRef (const UniqueRef< C > &)
 UniqueRef ()
virtual ~UniqueRef ()

Private Member Functions

Tptr (bool throw_flag) const

Private Attributes

bool m_isLoaded
boost::shared_ptr< IPtrLoaderm_loader
boost::shared_ptr< Tm_ptr

Detailed Description

template<typename T>
class ora::UniqueRef< T >

Templated class for the persistency of associated objects. Same features as Ptr (lazy loading) + support of polymorhism .

Definition at line 14 of file UniqueRef.h.


Constructor & Destructor Documentation

template<class T >
ora::UniqueRef< T >::UniqueRef ( )

Definition at line 114 of file UniqueRef.h.

                                              :
  m_ptr(),m_loader(),m_isLoaded(false) {}
template<class T >
ora::UniqueRef< T >::UniqueRef ( T anObject) [explicit]

Definition at line 117 of file UniqueRef.h.

                                                         :
  m_ptr(anObject),m_loader(),m_isLoaded(true) {}
template<class T >
ora::UniqueRef< T >::UniqueRef ( const UniqueRef< T > &  aPtr)

Definition at line 120 of file UniqueRef.h.

                                                                      :
  m_ptr(aPtr.m_ptr),m_loader(aPtr.m_loader),m_isLoaded(false){
}
template<class T >
template<class C >
ora::UniqueRef< T >::UniqueRef ( const UniqueRef< C > &  aPtr)

Definition at line 125 of file UniqueRef.h.

References trackerHits::c, funct::C, and lumiQTWidget::t.

                                                                      :
  m_ptr(aPtr.share()),m_loader(aPtr.loader()),m_isLoaded(aPtr.isLoaded()) {
  // compile-time type checking
  C* c = 0; T* t(c); assert(t==0);
}
template<class T >
ora::UniqueRef< T >::~UniqueRef ( ) [virtual]

Definition at line 131 of file UniqueRef.h.

                                               {
}

Member Function Documentation

template<class T >
void * ora::UniqueRef< T >::address ( ) const

Definition at line 184 of file UniqueRef.h.

                                                         {
  return m_ptr.get();  
}
template<class T >
template<class C >
ora::UniqueRef< T > & ora::UniqueRef< T >::cast ( const UniqueRef< C > &  aPtr)

Definition at line 159 of file UniqueRef.h.

References reset().

                                                                                                    {
  reset();
  m_loader = aPtr.loader();
  m_ptr = boost::dynamic_pointer_cast(aPtr.share());
  m_isLoaded = aPtr.isLoaded();
  return *this;  
}
template<class T >
T * ora::UniqueRef< T >::get ( void  ) const

Definition at line 175 of file UniqueRef.h.

                                                  {
  return ptr(false);  
}
template<typename T >
bool ora::UniqueRef< T >::isLoaded ( ) const [inline]

Definition at line 90 of file UniqueRef.h.

           :
    
template<typename T >
boost::shared_ptr<IPtrLoader>& ora::UniqueRef< T >::loader ( ) const [inline]

Definition at line 85 of file UniqueRef.h.

                          {
template<class T >
ora::UniqueRef< T >::operator bool ( ) const

Definition at line 194 of file UniqueRef.h.

                                                        {
  return ptr(false);
}
template<class T >
bool ora::UniqueRef< T >::operator! ( ) const

Definition at line 198 of file UniqueRef.h.

                                                         {
  return ptr(false)==0;
}
template<typename T >
template<class C >
bool ora::UniqueRef< T >::operator!= ( const UniqueRef< C > &  aPtr) const [inline]

Definition at line 75 of file UniqueRef.h.

          :

template<class T >
T & ora::UniqueRef< T >::operator* ( ) const

Definition at line 171 of file UniqueRef.h.

                                                       {
  return *ptr(true);
}
template<class T >
T * ora::UniqueRef< T >::operator-> ( ) const

Definition at line 167 of file UniqueRef.h.

                                                        {
  return ptr(true);
}
template<class T >
ora::UniqueRef< T > & ora::UniqueRef< T >::operator= ( const UniqueRef< T > &  aPtr)

Definition at line 141 of file UniqueRef.h.

References reset().

                                                                                      {
  reset();
  m_loader = aPtr.m_loader;
  m_ptr = aPtr.m_ptr;
  m_isLoaded = aPtr.m_isLoaded;
  return *this;  
}
template<class T >
ora::UniqueRef< T > & ora::UniqueRef< T >::operator= ( T aPtr)

Definition at line 134 of file UniqueRef.h.

References reset().

                                                                      {
  reset();
  m_ptr.reset(aPtr);
  m_isLoaded = true;
  return *this;
}
template<class T >
template<class C >
ora::UniqueRef< T > & ora::UniqueRef< T >::operator= ( const UniqueRef< C > &  aPtr)

Definition at line 150 of file UniqueRef.h.

References trackerHits::c, funct::C, reset(), and lumiQTWidget::t.

                                                                                      {
  C* c = 0; T* t(c); assert(t==0);
  reset();
  m_loader = aPtr.loader();
  m_ptr = aPtr.share();
  m_isLoaded = aPtr.isLoaded();
  return *this;  
}
template<typename T >
template<class C >
bool ora::UniqueRef< T >::operator== ( const UniqueRef< C > &  aPtr) const [inline]

Definition at line 71 of file UniqueRef.h.

                                                    {
template<class T >
T * ora::UniqueRef< T >::ptr ( bool  throw_flag) const [private]

Definition at line 208 of file UniqueRef.h.

References ora::throwException().

                                                               {
  if(!m_ptr.get()){
    if(!m_loader.get()){
      if(throwFlag) throwException("Loader is not installed.",
                                   "UniqueRef::ptr()");
    }
    if(!m_isLoaded && m_loader.get()){
      m_ptr.reset( static_cast<T*>(m_loader->load()));
      m_isLoaded = true;
    }
  }
  if(!m_ptr.get()){
    if(throwFlag) throwException("Underlying pointer is null.",
                                 "UniqueRef::ptr()");    
  }
  return m_ptr.get();
}
template<class T >
void ora::UniqueRef< T >::reset ( void  )

Definition at line 202 of file UniqueRef.h.

                                              {
  m_ptr.reset();
  m_loader.reset();
  m_isLoaded = false;
}
template<class T >
boost::shared_ptr< T > & ora::UniqueRef< T >::share ( ) const [inline]

Definition at line 180 of file UniqueRef.h.

                                                        {
  return m_ptr;
}
template<class T >
const std::type_info * ora::UniqueRef< T >::typeInfo ( ) const

Definition at line 188 of file UniqueRef.h.

References run_regression::ret.

                                                                        {
  const std::type_info* ret = 0;
  if(m_ptr) ret = &typeid(*m_ptr);
  return ret;
}

Member Data Documentation

template<typename T >
bool ora::UniqueRef< T >::m_isLoaded [mutable, private]

Definition at line 108 of file UniqueRef.h.

template<typename T >
boost::shared_ptr<IPtrLoader> ora::UniqueRef< T >::m_loader [mutable, private]

Definition at line 105 of file UniqueRef.h.

template<typename T >
boost::shared_ptr<T> ora::UniqueRef< T >::m_ptr [mutable, private]

Definition at line 102 of file UniqueRef.h.