CMS 3D CMS Logo

lat::AutoLoad< Type > Class Template Reference

Function or variable loaded on first dereference at run-time. More...

#include <Iguana/Utilities/classlib/utils/AutoLoad.h>

List of all members.

Public Member Functions

 AutoLoad (AutoLoadLib &library, const char *symname)
 Define an auto-loaded function or variable names symname, to be looked up in library on first dereference.
bool exists (void)
 Return true if the auto-load entity is available: the library can be loaded and the symbol is found in the library.
Type & operator * (void)
 Return a reference to the the auto-loaded entity.
Type * operator-> (void)
 Return a pointer to the the auto-loaded entity.

Private Member Functions

void loadme (void)
 Load the implementation if we haven't done so yet.

Private Attributes

AutoLoadLibm_library
Type * m_symbol
const char * m_symname


Detailed Description

template<class Type>
class lat::AutoLoad< Type >

Function or variable loaded on first dereference at run-time.

AutoLoad defines a function or data smart pointer for entries that should be looked up at run-time by dynamically loading a library and resolving a symbol in it.

Typically one defines a smart pointer object with the appropriate type matching the entity, data or function. The entity is used by dereferencing this smart pointer.

Use this interface judiciously, hiding dependencies behind an auto-load facility is generally frowned upon.

Definition at line 64 of file AutoLoad.h.


Constructor & Destructor Documentation

template<class Type>
lat::AutoLoad< Type >::AutoLoad ( AutoLoadLib library,
const char *  funcname 
) [inline]

Define an auto-loaded function or variable names symname, to be looked up in library on first dereference.

Definition at line 107 of file AutoLoad.h.

00108     : m_library (library),
00109       m_symname (funcname),
00110       m_symbol (0)
00111 {}


Member Function Documentation

template<class Type>
bool lat::AutoLoad< Type >::exists ( void   )  [inline]

Return true if the auto-load entity is available: the library can be loaded and the symbol is found in the library.

Definition at line 125 of file AutoLoad.h.

References lat::AutoLoad< Type >::loadme(), and lat::AutoLoad< Type >::m_symbol.

00126 { try { loadme (); } catch (AutoLoadError &) {} return m_symbol; }

template<class Type>
void lat::AutoLoad< Type >::loadme ( void   )  [inline, private]

Load the implementation if we haven't done so yet.

Throws an AutoLoadError if the library fails to load or there is a symbol lookup failure (non-existence of the symbol is not a failure).

Definition at line 118 of file AutoLoad.h.

References lat::AutoLoad< Type >::m_library, lat::AutoLoad< Type >::m_symbol, and lat::AutoLoad< Type >::m_symname.

Referenced by lat::AutoLoad< Type >::exists(), lat::AutoLoad< Type >::operator *(), and lat::AutoLoad< Type >::operator->().

00119 { if (! m_symbol) m_symbol = AutoLoadLookup<Type> (m_library, m_symname, (Type *) 0); }

template<class Type>
Type & lat::AutoLoad< Type >::operator * ( void   )  [inline]

Return a reference to the the auto-loaded entity.

Loads the library and resolves the symbol; if either operation fails, throws an AutoLoadError.

Definition at line 133 of file AutoLoad.h.

References lat::AutoLoad< Type >::loadme(), and lat::AutoLoad< Type >::m_symbol.

00134 { loadme (); return *m_symbol; }

template<class Type>
Type * lat::AutoLoad< Type >::operator-> ( void   )  [inline]

Return a pointer to the the auto-loaded entity.

Loads the library and resolves the symbol; if either operation fails, throws an AutoLoadError.

Definition at line 141 of file AutoLoad.h.

References lat::AutoLoad< Type >::loadme(), and lat::AutoLoad< Type >::m_symbol.

00142 { loadme (); return m_symbol; }


Member Data Documentation

template<class Type>
AutoLoadLib& lat::AutoLoad< Type >::m_library [private]

Definition at line 79 of file AutoLoad.h.

Referenced by lat::AutoLoad< Type >::loadme().

template<class Type>
Type* lat::AutoLoad< Type >::m_symbol [private]

Definition at line 81 of file AutoLoad.h.

Referenced by lat::AutoLoad< Type >::exists(), lat::AutoLoad< Type >::loadme(), lat::AutoLoad< Type >::operator *(), and lat::AutoLoad< Type >::operator->().

template<class Type>
const char* lat::AutoLoad< Type >::m_symname [private]

Definition at line 80 of file AutoLoad.h.

Referenced by lat::AutoLoad< Type >::loadme().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:48:21 2009 for CMSSW by  doxygen 1.5.4