CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondCore/ORA/interface/Record.h

Go to the documentation of this file.
00001 #ifndef CondCore_ORA_Record_H
00002 #define CondCore_ORA_Record_H
00003 
00004 #include <typeinfo>
00005 #include <vector>
00006 #include<string>
00007 #include<boost/shared_ptr.hpp>
00008 
00009 namespace ora {
00010   union AnyData;
00011   struct TypeHandler;
00012   struct RecordSpecImpl;
00013   class Record;
00014 
00015   class RecordSpec {
00016   public:
00017     RecordSpec();
00018     ~RecordSpec();
00019 
00020     size_t add(std::string const & name, std::type_info const & type);
00021 
00022   private:
00023     friend class Record;
00024     boost::shared_ptr<RecordSpecImpl> specs;
00025   };
00026 
00027 
00028   class Record {
00029   public:
00030     Record();
00031     
00032     explicit Record(RecordSpec ispecs);
00033     void init(RecordSpec ispecs);
00034 
00035     ~Record();
00036     void destroy();
00037     
00038     void swap(Record & lh);
00039 
00040     size_t size() const { return m_null.size();}
00041 
00042     template<typename T>
00043     T & data(int i) {
00044       // assert???
00045       return
00046         *reinterpret_cast<T*>(const_cast<void*>(address(i)));
00047     }
00048 
00049     template<typename T>
00050     T const & data(int i) const {
00051        // assert???
00052      return 
00053         *reinterpret_cast<T const*>(address(i));
00054     }
00055 
00056     void setNull(int i) {  m_null[i]=true;  } 
00057     void setNotNull(int i) {  m_null[i]=false;  } 
00058 
00059     int index(std::string const & iname) const;
00060     std::type_info const * type(int i) const;
00061     void const * address(int i) const;
00062     void const * get(int i) const;
00063     void set(int i, void * p);
00064     std::string const & name(int i) const;
00065     bool isNull(int i) const { return m_null[i];}
00066 
00067     boost::shared_ptr<RecordSpecImpl> specs;
00068     std::vector<AnyData> m_field;
00069     std::vector<bool> m_null;
00070   };
00071 
00072 }
00073 
00074 inline void swap(ora::Record & rh, ora::Record & lh) {
00075   rh.swap(lh);
00076 }
00077 
00078 #endif //  CondCore_ORA_Record_H