Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:50

0001 #ifndef DataFormats_Common_DataFrame_h
0002 #define DataFormats_Common_DataFrame_h
0003 
0004 class TestDataFrame;
0005 namespace edm {
0006 
0007   class DataFrameContainer;
0008 
0009   /* a proxy to a fixed size array of 16bit words belonging to
0010    * a "channel" identified by an 32bit id
0011    *
0012    * FIXME interface to be finalized once use-cases fully identified
0013    * 
0014    */
0015   class DataFrame {
0016   public:
0017     typedef unsigned int size_type;  // for persistency
0018     typedef unsigned int id_type;
0019     typedef unsigned short data_type;
0020     typedef data_type *iterator;
0021     typedef data_type const *const_iterator;
0022 
0023     constexpr inline DataFrame() : m_id(0), m_data(nullptr), m_size(0) {}
0024     constexpr inline DataFrame(id_type i, data_type const *idata, size_type isize)
0025         : m_id(i), m_data(idata), m_size(isize) {}
0026 
0027     inline DataFrame(DataFrameContainer const &icont, size_type i);
0028     inline void set(DataFrameContainer const &icont, size_type i);
0029     constexpr inline data_type &operator[](size_type i) { return data()[i]; }
0030 
0031     constexpr inline data_type operator[](size_type i) const { return m_data[i]; }
0032 
0033     constexpr inline iterator begin() { return data(); }
0034 
0035     constexpr inline iterator end() { return data() + m_size; }
0036 
0037     constexpr inline const_iterator begin() const { return m_data; }
0038 
0039     constexpr inline const_iterator end() const { return m_data + m_size; }
0040 
0041     constexpr inline id_type id() const { return m_id; }
0042 
0043     constexpr inline size_type size() const { return m_size; }
0044 
0045   private:
0046     //for testing
0047     friend class ::TestDataFrame;
0048 
0049     constexpr data_type *data() { return const_cast<data_type *>(m_data); }
0050 
0051     id_type m_id;
0052     data_type const *m_data;
0053     size_type m_size;
0054   };
0055 }  // namespace edm
0056 
0057 #endif  // DataFormats_Common_DataFrame_h