LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
UTIL/LCObjectHandle.h
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* lcObj) : _lcObj(lcObj) {
24  }
25 
27 
28  _lcObj = dynamic_cast< T* >( lcObj ) ;
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.
Definition: UTIL/LCObjectHandle.h:15