Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/sf_img 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_sg_sf_img
0005 #define tools_sg_sf_img
0006 
0007 #include "sf"
0008 
0009 #include "../img"
0010 
0011 namespace tools {
0012 namespace sg {
0013 
0014 template <class T>
0015 class sf_img : public bsf< img<T> > {
0016   typedef bsf< img<T> > parent;
0017 public:
0018   static const std::string& s_class() {
0019     static const std::string s_v("tools::sg::sf_img<"+stype(T())+">");
0020     return s_v;
0021   }
0022   virtual void* cast(const std::string& a_class) const {
0023     if(void* p = cmp_cast< sf_img<T> >(this,a_class)) {return p;}
0024     return parent::cast(a_class);
0025   }
0026   virtual const std::string& s_cls() const {return s_class();}
0027 public:
0028   virtual bool write(io::iwbuf& a_buffer) {
0029     const img<T>& im = parent::m_value;
0030     return a_buffer.write_img(im.width(),im.height(),im.bytes_per_pixel(),im.buffer());
0031   }
0032   virtual bool read(io::irbuf& a_buffer) {
0033     uint32 w,h,n;uchar* b;
0034     if(!a_buffer.read_img(w,h,n,b)) return false;
0035     img<T>& im = parent::m_value;
0036     if(w && h && n && b) {
0037       im.set(w,h,n,b,true);
0038     }
0039     return true;
0040   }
0041   virtual bool dump(std::ostream&) {
0042     return true;
0043   }
0044   virtual bool s_value(std::string& a_s) const {a_s.clear();return false;}
0045   virtual bool s2value(const std::string&) {return false;}
0046 public:
0047   sf_img():parent(){}
0048   sf_img(const img<T>& a_value):parent(a_value){}
0049   virtual ~sf_img(){}
0050 public:
0051   sf_img(const sf_img& a_from):parent(a_from){}
0052   sf_img& operator=(const sf_img& a_from){
0053     parent::operator=(a_from);
0054     return *this;
0055   }
0056 public:
0057   sf_img& operator=(const img<T>& a_value){
0058     parent::operator=(a_value);
0059     return *this;
0060   }
0061 };
0062 
0063 }}
0064 
0065 #endif