CMS 3D CMS Logo

ESHandle.h

Go to the documentation of this file.
00001 #ifndef Framework_ESHandle_h
00002 #define Framework_ESHandle_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class  :     ESHandle
00007 // 
00016 //
00017 // Author:      Chris Jones
00018 // Created:     Fri Apr  1 14:47:35 EST 2005
00019 // $Id: ESHandle.h,v 1.10 2006/08/31 23:26:24 wmtan Exp $
00020 //
00021 
00022 // system include files
00023 
00024 // user include files
00025 #include "FWCore/Utilities/interface/EDMException.h"
00026 #include "FWCore/Framework/interface/ComponentDescription.h"
00027 
00028 // forward declarations
00029 namespace edm {
00030 template< class T>
00031 class ESHandle
00032 {
00033 
00034    public:
00035       typedef T value_type;
00036    
00037       ESHandle() : data_(0), description_(0) {}
00038       ESHandle(const T* iData) : data_(iData), description_(0) {}
00039 //      { std::cout<<"Call ESHanlde(data) ctor"<<std::endl; }
00040       ESHandle(const T* iData, const edm::eventsetup::ComponentDescription* desc) 
00041            : data_(iData), description_(desc) {}
00042 //      { std::cout<<"Call ESHanlde(data,desc) ctor"<<std::endl; }
00043       //virtual ~ESHandle();
00044 
00045       // ---------- const member functions ---------------------
00046       const T* product() const { return data_; }
00047       const T* operator->() const { return product(); }
00048       const T& operator*() const { return *product(); }
00049       const edm::eventsetup::ComponentDescription* description() const { 
00050          if(!description_) {
00051             throw edm::Exception(edm::errors::InvalidReference,"NullPointer");
00052          }
00053          return description_; 
00054       }
00055       
00056       bool isValid() const { return 0 != data_ && 0 != description_; }
00057       // ---------- static member functions --------------------
00058 
00059       // ---------- member functions ---------------------------
00060       void swap(ESHandle<T>& iOther) {
00061          std::swap(data_, iOther.data_);
00062          std::swap(description_, iOther.description_);
00063       }
00064       
00065    private:
00066       //ESHandle(const ESHandle&); // stop default
00067 
00068       //const ESHandle& operator=(const ESHandle&); // stop default
00069 
00070       // ---------- member data --------------------------------
00071       const T* data_; 
00072       const edm::eventsetup::ComponentDescription* description_;
00073 };
00074 
00075   // Free swap function
00076   template <class T>
00077   inline
00078   void
00079   swap(ESHandle<T>& a, ESHandle<T>& b) 
00080   {
00081     a.swap(b);
00082   }
00083 }
00084 #endif

Generated on Tue Jun 9 17:35:29 2009 for CMSSW by  doxygen 1.5.4