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.bpp(),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 #ifdef TOOLS_MEM
0039 mem::decrement(s_new().c_str());
0040 #endif
0041 }
0042 return true;
0043 }
0044 virtual bool dump(std::ostream&) {
0045 //a_out << parent::m_value << std::endl;
0046 return true;
0047 }
0048 virtual bool s_value(std::string& a_s) const {a_s.clear();return false;}
0049 virtual bool s2value(const std::string&) {return false;}
0050 public:
0051 sf_img():parent(){}
0052 sf_img(const img<T>& a_value):parent(a_value){}
0053 virtual ~sf_img(){}
0054 public:
0055 sf_img(const sf_img& a_from):parent(a_from){}
0056 sf_img& operator=(const sf_img& a_from){
0057 parent::operator=(a_from);
0058 return *this;
0059 }
0060 public:
0061 sf_img& operator=(const img<T>& a_value){
0062 parent::operator=(a_value);
0063 return *this;
0064 }
0065 };
0066
0067 }}
0068
0069 #endif