00001 #ifndef UTIL_LCOBJECTHANDLE_H
00002 #define UTIL_LCOBJECTHANDLE_H 1
00003
00004 #include "EVENT/LCObject.h"
00005 #include "Exceptions.h"
00006
00007
00008 namespace UTIL{
00009
00015 template<class T> class LCObjectHandle{
00016
00017 protected:
00018 T* _lcObj ;
00019
00020 public:
00021 virtual ~LCObjectHandle() { ; }
00022
00023 LCObjectHandle( T* obj) : _lcObj(obj) {
00024 }
00025
00026 LCObjectHandle(EVENT::LCObject* obj){
00027
00028 _lcObj = dynamic_cast< T* >( obj ) ;
00029
00030 if( _lcObj == 0 )
00031 throw EVENT::Exception("dynamic cast failed for LCObjectHandle() !" ) ;
00032 }
00033
00034 T* operator->() { return _lcObj ; }
00035
00036 T* lcObj() { return _lcObj ; }
00037
00038 };
00039
00040 }
00041 #endif