LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LCObjectHandle.h
Go to the documentation of this file.
1 #ifndef UTIL_LCOBJECTHANDLE_H
2 #define UTIL_LCOBJECTHANDLE_H 1
3 
4 #include "EVENT/LCObject.h"
5 #include "Exceptions.h"
6 //#include "lcio.h"
7 
8 namespace UTIL{
9 
15  template<class T> class LCObjectHandle{
16 
17  protected:
18  T* _lcObj ;
19 
20  public:
21  virtual ~LCObjectHandle() { /*no_op*/; }
22 
23  LCObjectHandle( T* obj) : _lcObj(obj) {
24  }
25 
27 
28  _lcObj = dynamic_cast< T* >( obj ) ;
29 
30  if( _lcObj == 0 )
31  throw EVENT::Exception("dynamic cast failed for LCObjectHandle() !" ) ;
32  }
33 
34  T* operator->() { return _lcObj ; }
35 
36  T* lcObj() { return _lcObj ; }
37 
38  };
39 
40 } // namespace
41 #endif /* ifndef LCIO_OBJECTHANDLE_H */
The generic object that is held in an LCCollection.
Definition: LCObject.h:30
Base exception class for LCIO - all other exceptions extend this.
Definition: Exceptions.h:21
Template handle class for LCObjects.
LCObjectHandle(EVENT::LCObject *obj)