g4tools  5.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::sg::gstos Class Reference
Inheritance diagram for tools::sg::gstos:
Inheritance graph
[legend]

Public Member Functions

size_t num_gstos () const
 

Protected Member Functions

 gstos ()
 
virtual ~gstos ()
 
 gstos (const gstos &)
 
gstosoperator= (const gstos &a_from)
 
unsigned int get_tex_id (std::ostream &a_out, render_manager &a_mgr, const img_byte &a_img, bool a_NEAREST)
 
virtual unsigned int create_gsto (std::ostream &, render_manager &)
 
unsigned int get_gsto_id (std::ostream &a_out, render_manager &a_mgr)
 
void clean_gstos ()
 
void clean_gstos (render_manager *a_mgr)
 
unsigned int _find (render_manager *a_mgr)
 

Protected Attributes

std::vector< std::pair< unsigned int, render_manager * > > m_gstos
 

Detailed Description

Definition at line 16 of file gstos.

Constructor & Destructor Documentation

◆ gstos() [1/2]

tools::sg::gstos::gstos ( )
inlineprotected

Definition at line 18 of file gstos.

18 {}

◆ ~gstos()

virtual tools::sg::gstos::~gstos ( )
inlineprotectedvirtual

Definition at line 19 of file gstos.

19 {clean_gstos();}

◆ gstos() [2/2]

tools::sg::gstos::gstos ( const gstos )
inlineprotected

Definition at line 21 of file gstos.

21 {}

Member Function Documentation

◆ _find()

unsigned int tools::sg::gstos::_find ( render_manager a_mgr)
inlineprotected

Definition at line 108 of file gstos.

108  {
109  std::vector< std::pair<unsigned int,render_manager*> >::iterator it;
110  for(it=m_gstos.begin();it!=m_gstos.end();++it){
111  if((*it).second==a_mgr) return (*it).first;
112  }
113  return 0;
114  }

◆ clean_gstos() [1/2]

void tools::sg::gstos::clean_gstos ( )
inlineprotected

Definition at line 89 of file gstos.

89  {
90  std::vector< std::pair<unsigned int,render_manager*> >::iterator it;
91  for(it=m_gstos.begin();it!=m_gstos.end();){
92  (*it).second->delete_gsto((*it).first);
93  it = m_gstos.erase(it);
94  }
95  }

◆ clean_gstos() [2/2]

void tools::sg::gstos::clean_gstos ( render_manager a_mgr)
inlineprotected

Definition at line 96 of file gstos.

96  {
97  std::vector< std::pair<unsigned int,render_manager*> >::iterator it;
98  for(it=m_gstos.begin();it!=m_gstos.end();){
99  if((*it).second==a_mgr) {
100  (*it).second->delete_gsto((*it).first);
101  it = m_gstos.erase(it);
102  } else {
103  it++;
104  }
105  }
106  }

◆ create_gsto()

virtual unsigned int tools::sg::gstos::create_gsto ( std::ostream &  ,
render_manager  
)
inlineprotectedvirtual

◆ get_gsto_id()

unsigned int tools::sg::gstos::get_gsto_id ( std::ostream &  a_out,
render_manager a_mgr 
)
inlineprotected

Definition at line 60 of file gstos.

60  {
61  unsigned int _id = _find(&a_mgr);
62  if(_id && !a_mgr.is_gsto_id_valid(_id)){
63 #ifdef TOOLS_SG_GSTOS_DEBUG
64  a_out << "debug : tools::sg::gstos::get_gsto_id : " << _id << " not valid." << std::endl;
65 #endif
66  clean_gstos(&a_mgr);
67  _id = 0;
68  }
69  if(!_id) {
70 #ifdef TOOLS_SG_GSTOS_DEBUG
71  a_out << "debug : tools::sg::gstos::get_gsto_id : create_gsto ..." << std::endl;
72 #endif
73  _id = create_gsto(a_out,a_mgr);
74 #ifdef TOOLS_SG_GSTOS_DEBUG
75  a_out << "debug : tools::sg::gstos::get_gsto_id : create_gsto : _id " << _id << "." << std::endl;
76 #endif
77  if(!_id) {
78  // could be ok if there is no graphical data to load.
79  //a_out << "tools::sg::gstos::get_gsto_id :"
80  // << " create_gsto() failed."
81  // << std::endl;
82  } else {
83  m_gstos.push_back(std::pair<unsigned int,render_manager*>(_id,&a_mgr));
84  }
85  }
86  return _id;
87  }

◆ get_tex_id()

unsigned int tools::sg::gstos::get_tex_id ( std::ostream &  a_out,
render_manager a_mgr,
const img_byte a_img,
bool  a_NEAREST 
)
inlineprotected

Definition at line 30 of file gstos.

30  {
31  unsigned int _id = _find(&a_mgr);
32  if(_id && !a_mgr.is_gsto_id_valid(_id)){
33 #ifdef TOOLS_SG_GSTOS_DEBUG
34  a_out << "debug : tools::sg::gstos::get_tex_id : " << _id << " not valid." << std::endl;
35 #endif
36  clean_gstos(&a_mgr);
37  _id = 0;
38  }
39  if(!_id) {
40 #ifdef TOOLS_SG_GSTOS_DEBUG
41  a_out << "debug : tools::sg::gstos::get_tex_id : create_texture ... " << std::endl;
42 #endif
43  _id = a_mgr.create_texture(a_img,a_NEAREST);
44 #ifdef TOOLS_SG_GSTOS_DEBUG
45  a_out << "debug : tools::sg::gstos::get_tex_id : create_texture : _id " << _id << "." << std::endl;
46 #endif
47  if(!_id) {
48  a_out << "tools::sg::gstos::get_tex_id :"
49  << " render_manager.create_texture() failed."
50  << std::endl;
51  } else {
52  m_gstos.push_back(std::pair<unsigned int,render_manager*>(_id,&a_mgr));
53  }
54  }
55  return _id;
56  }

◆ num_gstos()

size_t tools::sg::gstos::num_gstos ( ) const
inline

Definition at line 28 of file gstos.

28 {return m_gstos.size();}

◆ operator=()

gstos& tools::sg::gstos::operator= ( const gstos a_from)
inlineprotected

Definition at line 22 of file gstos.

22  {
23  if(&a_from==this) return *this;
24  clean_gstos();
25  return *this;
26  }

Member Data Documentation

◆ m_gstos

std::vector< std::pair<unsigned int,render_manager*> > tools::sg::gstos::m_gstos
protected

Definition at line 117 of file gstos.


The documentation for this class was generated from the following file:
tools::sg::gstos::m_gstos
std::vector< std::pair< unsigned int, render_manager * > > m_gstos
Definition: gstos:117
tools::sg::gstos::create_gsto
virtual unsigned int create_gsto(std::ostream &, render_manager &)
Definition: gstos:58
tools::sg::gstos::clean_gstos
void clean_gstos()
Definition: gstos:89
tools::sg::gstos::_find
unsigned int _find(render_manager *a_mgr)
Definition: gstos:108