xoreos  0.0.5
texturehandle.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include <cassert>
26 
30 
31 namespace Graphics {
32 
33 namespace Aurora {
34 
35 ManagedTexture::ManagedTexture(Texture *t) : texture(t), referenceCount(0) {
36 }
37 
39  delete texture;
40 }
41 
42 
43 TextureHandle::TextureHandle() : _empty(true) {
44 }
45 
46 TextureHandle::TextureHandle(TextureMap::iterator &i) : _empty(false), _it(i) {
47  _it->second->referenceCount++;
48 }
49 
50 TextureHandle::TextureHandle(const TextureHandle &right) : _empty(true) {
51  *this = right;
52 }
53 
55  clear();
56 }
57 
59  if (this == &right)
60  return *this;
61 
62  clear();
63 
64  TextureMan.assign(*this, right);
65 
66  return *this;
67 }
68 
69 bool TextureHandle::empty() const {
70  return _empty;
71 }
72 
75  if (_empty)
76  return kEmptyString;
77 
78  return _it->first;
79 }
80 
82  TextureMan.release(*this);
83 }
84 
86  assert(!_empty);
87 
88  return *_it->second->texture;
89 }
90 
91 } // End of namespace Aurora
92 
93 } // End of namespace Graphics
A class holding an UTF-8 string.
Definition: ustring.h:48
#define TextureMan
Shortcut for accessing the texture manager.
Definition: textureman.h:127
const Common::UString kEmptyString
Definition: fonthandle.cpp:70
The Aurora texture manager.
A handle to an Aurora texture.
TextureHandle & operator=(const TextureHandle &right)
A texture as used in the Aurora engines.
const Common::UString & getName() const
TextureMap::iterator _it
Definition: texturehandle.h:68
A handle to a texture.
Definition: texturehandle.h:51