CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Utilities/interface/ECGetterBase.h

Go to the documentation of this file.
00001 #ifndef Utilities_ECGetterBase_h
00002 #define Utilities_ECGetterBase_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Utilities
00006 // Class  :     ECGetterBase
00007 // 
00016 //
00017 // Original Author:  Chris Jones
00018 //         Created:  Fri Sep 22 12:41:05 EDT 2006
00019 // $Id: ECGetterBase.h,v 1.1 2006/09/22 18:42:58 chrjones Exp $
00020 //
00021 
00022 // system include files
00023 
00024 // user include files
00025 
00026 // forward declarations
00027 namespace edm {
00028   namespace extensioncord {
00029     template <class T>
00030     class ECGetterBase
00031     {
00032       
00033      public:
00034       ECGetterBase(): data_(0) {}
00035       virtual ~ECGetterBase() {}
00036 
00037       // ---------- const member functions ---------------------
00038       const T* get() const  {
00039         if(data_==0) {
00040           data_ = this->getImpl();
00041         }
00042         return data_;
00043       }
00044       
00045      private:
00046       //ECGetterBase(const ECGetterBase&); // allow default
00047 
00048       //const ECGetterBase& operator=(const ECGetterBase&); // allow default
00049       
00050       //the actual method which is used to get the requested data
00051       virtual const T* getImpl() const = 0;
00052 
00053       // ---------- member data --------------------------------
00054       //does not own the data
00055       mutable const T* data_;
00056 
00057     };
00058   }
00059   template <class T>
00060   class ValueHolderECGetter : public extensioncord::ECGetterBase<T> {
00061   public:
00062     ValueHolderECGetter(const T& iValue) : value_(&iValue) {}
00063   private:
00064     virtual const T* getImpl() const {
00065       return value_;
00066     }
00067     const T* value_;
00068   };
00069 }
00070 
00071 #endif