Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/wroot/member_writer is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_wroot_member_writer
0005 #define tools_wroot_member_writer
0006 
0007 #include "../store/iobj_const_visitor"
0008 
0009 #include "buffer"
0010 
0011 namespace tools {
0012 namespace wroot {
0013 
0014 class member_writer : public virtual iobj_const_visitor {
0015 public:
0016   virtual bool begin(const istorable&,const std::string&,local_func) {return true;}
0017   virtual bool end(const istorable&){return true;}
0018 
0019   virtual bool visit(const std::string&,bool a_v){return m_buf.write(a_v);}
0020   virtual bool visit(const std::string&,char a_v){return m_buf.write(a_v);}
0021   virtual bool visit(const std::string&,short a_v){return m_buf.write(a_v);}
0022   virtual bool visit(const std::string&,int a_v){return m_buf.write(a_v);}
0023 
0024   virtual bool visit(const std::string&,unsigned int a_v) {return m_buf.write(a_v);}
0025 
0026   virtual bool visit(const std::string&,int64){
0027     m_buf.out() << "tools::wroot::member_writer::visit(int64) :"
0028                 << " dummy." << std::endl;
0029     return false; //FIXME
0030   }
0031 
0032   virtual bool visit(const std::string&,uint64){
0033     m_buf.out() << "tools::wroot::member_writer::visit(uint64) :"
0034                 << " dummy." << std::endl;
0035     return false; //FIXME
0036   }
0037 
0038   virtual bool visit(const std::string&,float a_v){return m_buf.write(a_v);}
0039   virtual bool visit(const std::string&,double a_v){return m_buf.write(a_v);}
0040 
0041   virtual bool visit(const std::string&,const std::string& a_v) {return m_buf.write(a_v);}
0042 
0043   //virtual bool visit(const std::string&,const char* a_v){
0044   //  return m_buf.write(std::string(a_v));
0045   //}
0046 
0047   virtual bool visit(const std::string&,const std::vector<bool>& a_v){
0048     size_t number = a_v.size();
0049     std::vector<unsigned char> data(number);
0050     for(size_t index=0;index<number;index++) {
0051       data[index] = (unsigned char)a_v[index];
0052     }
0053     return m_buf.write_array<unsigned char>(data);
0054   }
0055 
0056   virtual bool visit(const std::string&,const std::vector<char>& a_v) {return m_buf.write_array(a_v);}
0057 
0058   virtual bool visit(const std::string&,const std::vector<short>& a_v) {return m_buf.write_array(a_v);}
0059 
0060   virtual bool visit(const std::string&,const std::vector<int>& a_v) {return m_buf.write_array(a_v);}
0061 
0062   virtual bool visit(const std::string&,const std::vector<int64>& /*a_v*/){
0063     //FIXME return ::Rio::writeArray<Slash::int64>(fBuffer,a_v);
0064     m_buf.out() << "tools::wroot::member_writer::visit(vector<int64>) :"
0065                 << " dummy." << std::endl;
0066     return false;
0067   }
0068 
0069   virtual bool visit(const std::string&,const std::vector<float>& a_v) {return m_buf.write_array(a_v);}
0070 
0071   virtual bool visit(const std::string&,const std::vector<double>& a_v) {return m_buf.write_array(a_v);}
0072 
0073 //virtual bool visit(const std::string&,const std::vector<unsigned char>& a_v) {return m_buf.write_array(a_v);}
0074 
0075   virtual bool visit(const std::string&,const std::vector<std::string>& a_v) {return m_buf.write(a_v);}
0076 
0077   virtual bool visit(const std::string&,const std::vector< std::vector<double> >& a_v){
0078     return m_buf.write_array2(a_v);
0079   }
0080 
0081   virtual bool visit(const std::string&,const istorable& a_v){
0082     // WARNING : can't be called in a object.visit()
0083     //   over a a_v being a "super" of "object" .
0084     if(!a_v.visit(*this)) return false;
0085     return true;
0086   }
0087 public:
0088   member_writer(buffer& a_buf):m_buf(a_buf){}
0089   virtual ~member_writer(){}
0090 private:
0091   member_writer(const member_writer& a_from)
0092   :iobj_const_visitor(a_from)
0093   ,m_buf(a_from.m_buf)
0094   {}
0095   member_writer& operator=(const member_writer&){return *this;}
0096 protected:
0097   buffer& m_buf;
0098 };
0099 
0100 }}
0101 
0102 #endif