Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/zb_manager 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_zb_manager
0005 #define tools_sg_zb_manager
0006 
0007 #include "render_manager"
0008 
0009 #ifdef TOOLS_MEM
0010 #include "../mem"
0011 #endif
0012 
0013 #include <map>
0014 
0015 namespace tools {
0016 namespace sg {
0017 
0018 class zb_manager : public virtual render_manager {
0019   typedef render_manager parent;
0020 public:
0021   TOOLS_SCLASS(tools::sg::zb_manager)
0022   virtual void* cast(const std::string& a_class) const {
0023     if(void* p = cmp_cast<zb_manager>(this,a_class)) {return p;}
0024     else return 0;
0025   }
0026 public:
0027   virtual bool begin_render(int,int,unsigned int,unsigned int,float,float,float,float,bool = true) {return true;}
0028   virtual void end_render() {}
0029 
0030   virtual unsigned int create_texture(const img_byte& a_img,bool /*a_NEAREST*/) {
0031     m_gen_id++; //never return 0.
0032     m_gstos[m_gen_id] = a_img;
0033     return m_gen_id;
0034   }
0035 
0036   virtual unsigned int create_gsto_from_data(size_t,const float*) {return 0;}
0037 
0038   virtual bool is_gsto_id_valid(unsigned int a_id) const {
0039     gstos_t::const_iterator it = m_gstos.find(a_id);
0040     if(it==m_gstos.end()) return false;
0041     return true;
0042   }
0043   virtual void delete_gsto(unsigned int a_id) {
0044     gstos_t::iterator it = m_gstos.find(a_id);
0045     if(it!=m_gstos.end()) m_gstos.erase(it);
0046   }
0047 
0048   //
0049   virtual gsto_mode get_gsto_mode() const {return gsto_memory;}
0050   virtual void set_gsto_mode(gsto_mode) {}
0051   virtual void available_gsto_modes(std::vector<std::string>& a_v) {a_v.clear();}
0052   virtual void available_not_memory_gsto_mode(std::string& a_s) const {a_s.clear();}
0053   virtual size_t used_texture_memory() const {return 0;}
0054   virtual size_t gstos_size() const {return 0;}
0055 public:
0056   zb_manager():m_gen_id(0){
0057 #ifdef TOOLS_MEM
0058     mem::increment(s_class().c_str());
0059 #endif
0060   }
0061   virtual ~zb_manager(){
0062     m_gstos.clear();
0063 #ifdef TOOLS_MEM
0064     mem::decrement(s_class().c_str());
0065 #endif
0066   }
0067 public:
0068   zb_manager(const zb_manager& a_from)
0069   :parent(a_from)
0070   ,m_gen_id(0)
0071   ,m_gstos()
0072   {
0073 #ifdef TOOLS_MEM
0074     mem::increment(s_class().c_str());
0075 #endif
0076   }
0077   zb_manager& operator=(const zb_manager& a_from){
0078     if(&a_from==this) return *this;
0079     m_gen_id = 0;
0080     m_gstos.clear();
0081     return *this;
0082   }
0083 public:
0084   bool find(unsigned int a_id,img_byte& a_img) {
0085     gstos_t::iterator it = m_gstos.find(a_id);
0086     if(it==m_gstos.end()) return false;
0087     a_img = (*it).second;
0088     return true;
0089   }
0090   //void cleanup() {}
0091   void delete_gstos() {m_gstos.clear();}
0092 protected:
0093   unsigned int m_gen_id;
0094   typedef std::map<unsigned int,img_byte> gstos_t;
0095   gstos_t m_gstos; //only textures for the moment.
0096 };
0097 
0098 }}
0099 
0100 #endif