CMS 3D CMS Logo

DetSetNew.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Common_DetSetNew_h
00002 #define DataFormats_Common_DetSetNew_h
00003 
00004 namespace edmNew {
00005   //  FIXME move it elsewhere....
00006   typedef unsigned int det_id_type;
00007 
00008   template<typename T> class DetSetVector;
00009   
00010   /* a proxy to a variable size array of T belonging to
00011    * a "channel" identified by an 32bit id
00012    *
00013    * FIXME interface to be finalized once use-cases fully identified
00014    * 
00015    */
00016   template<typename T>
00017   class DetSet {
00018   public: 
00019     typedef DetSetVector<T> Container;
00020     typedef unsigned int size_type; // for persistency
00021     typedef unsigned int id_type;
00022     typedef T data_type;
00023 
00024     typedef data_type * iterator;
00025     typedef data_type const * const_iterator;
00026 
00027     typedef data_type value_type;
00028     typedef id_type key_type;
00029     
00030     
00031     inline
00032     DetSet() : m_id(0), m_data(0), m_size(0){}
00033     inline
00034     DetSet(id_type i, data_type const * idata, size_type isize) :
00035       m_id(i), m_data(idata), m_size(isize) {}
00036     
00037    inline
00038     DetSet(Container const & icont,
00039            typename Container::Item const & item);
00040 
00041     //FIXME (it may confuse users as size_type is same type as id_type...)
00042     inline
00043     void set(Container const & icont,
00044              typename Container::Item const & item);
00045     inline
00046     data_type & operator[](size_type i) {
00047       return data()[i];
00048     }
00049     
00050     inline
00051     data_type operator[](size_type i) const {
00052       return data()[i];
00053     }
00054     
00055     inline
00056     iterator begin() { return data();}
00057 
00058     inline
00059     iterator end() { return data()+m_size;}
00060 
00061     inline
00062     const_iterator begin() const { return data();}
00063 
00064     inline
00065     const_iterator end() const { return data()+m_size;}
00066 
00067 
00068     inline
00069     id_type id() const { return m_id;}
00070     
00071     inline
00072     id_type detId() const { return m_id;}
00073     
00074     inline
00075     size_type size() const { return m_size; }
00076 
00077     inline
00078     bool empty() const { return m_size==0;}
00079     
00080   private:
00081     data_type const * data() const {
00082       return m_data;
00083     }
00084 
00085    data_type * data() {
00086       return const_cast<data_type *>(m_data);
00087     }
00088     
00089     id_type m_id;
00090     data_type const * m_data;
00091     size_type m_size;
00092   };
00093 }
00094 
00095 #endif // DataFormats_Common_DetSet_h

Generated on Tue Jun 9 17:28:44 2009 for CMSSW by  doxygen 1.5.4