ManaPlus
Public Member Functions | Data Fields
AtlasResource Class Reference

#include <atlasresource.h>

Inheritance diagram for AtlasResource:
Resource MemoryCounter

Public Member Functions

 AtlasResource ()
 
 ~AtlasResource ()
 
void incRef ()
 
void decRef ()
 
int calcMemoryLocal () const
 
int calcMemoryChilds (const int level) const
 
- Public Member Functions inherited from Resource
 Resource ()
 
 ~Resource ()
 
int calcMemoryLocal () const
 
std::string getCounterName () const
 
- Public Member Functions inherited from MemoryCounter
 MemoryCounter ()
 
virtual ~MemoryCounter ()
 
int calcMemory (const int level) const
 

Data Fields

std::vector< TextureAtlas * > atlases
 
- Data Fields inherited from Resource
time_t mTimeStamp
 
std::string mIdPath
 
std::string mSource
 
unsigned int mRefCount
 
bool mProtected
 
bool mNotCount
 

Detailed Description

Definition at line 32 of file atlasresource.h.

Constructor & Destructor Documentation

◆ AtlasResource()

AtlasResource::AtlasResource ( )
inline

Definition at line 35 of file atlasresource.h.

References A_DELETE_COPY, calcMemoryChilds(), calcMemoryLocal(), decRef(), incRef(), and ~AtlasResource().

Referenced by calcMemoryLocal().

35  :
36  atlases()
37  { }
std::vector< TextureAtlas * > atlases
Definition: atlasresource.h:51

◆ ~AtlasResource()

AtlasResource::~AtlasResource ( )

Definition at line 32 of file atlasresource.cpp.

References atlases, TextureAtlas::atlasImage, ResourceManager::clearDeleted(), Image::decRef(), FOR_EACH, AtlasItem::image, ServerCommandType::item, and TextureAtlas::items.

Referenced by AtlasResource().

33 {
34  FOR_EACH (STD_VECTOR<TextureAtlas*>::iterator, it, atlases)
35  {
36  TextureAtlas *const atlas = *it;
37  if (atlas != nullptr)
38  {
39  FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it2, atlas->items)
40  {
41  AtlasItem *const item = *it2;
42  if (item != nullptr)
43  {
44  Image *const image2 = item->image;
45  if (image2 != nullptr)
46  image2->decRef();
47  delete item;
48  }
49  }
50  Image *const image = atlas->atlasImage;
51  if (image != nullptr)
52  image->decRef();
53  delete atlas;
54  }
55  }
57 }
Image * image
Definition: atlasitem.h:53
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void clearDeleted(const bool full)
std::vector< TextureAtlas * > atlases
Definition: atlasresource.h:51
Image * atlasImage
Definition: textureatlas.h:74
Definition: image.h:61
std::vector< AtlasItem * > items
Definition: textureatlas.h:77
void decRef()
Definition: image.cpp:522

Member Function Documentation

◆ calcMemoryChilds()

int AtlasResource::calcMemoryChilds ( const int  level) const
virtual

Reimplemented from MemoryCounter.

Definition at line 80 of file atlasresource.cpp.

References atlases, MemoryCounter::calcMemory(), and FOR_EACH.

Referenced by AtlasResource().

81 {
82  int sz = 0;
83  FOR_EACH (STD_VECTOR<TextureAtlas*>::const_iterator, it, atlases)
84  {
85  TextureAtlas *const atlas = *it;
86  sz += atlas->calcMemory(level + 1);
87  }
88  return sz;
89 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int calcMemory(const int level) const
std::vector< TextureAtlas * > atlases
Definition: atlasresource.h:51

◆ calcMemoryLocal()

int AtlasResource::calcMemoryLocal ( ) const
virtual

Reimplemented from MemoryCounter.

Definition at line 73 of file atlasresource.cpp.

References atlases, AtlasResource(), and Resource::calcMemoryLocal().

Referenced by AtlasResource().

74 {
75  return static_cast<int>(sizeof(AtlasResource)) +
77  static_cast<int>(atlases.capacity() * sizeof(TextureAtlas*));
78 }
int calcMemoryLocal() const
Definition: resource.cpp:75
std::vector< TextureAtlas * > atlases
Definition: atlasresource.h:51

◆ decRef()

void AtlasResource::decRef ( )
virtual

Decrements the reference count and deletes the object if no references are left.

Returns
true if the object was deleted false otherwise.

Reimplemented from Resource.

Definition at line 66 of file atlasresource.cpp.

References Resource::decRef(), AtlasManager::moveToDeleted(), and Resource::mRefCount.

Referenced by AtlasResource(), and Map::~Map().

67 {
69  if (mRefCount == 0U)
71 }
virtual void decRef()
Definition: resource.cpp:49
unsigned int mRefCount
Definition: resource.h:86
static void moveToDeleted(AtlasResource *const resource)

◆ incRef()

void AtlasResource::incRef ( )
virtual

Increments the internal reference count.

Reimplemented from Resource.

Definition at line 59 of file atlasresource.cpp.

References Resource::incRef(), AtlasManager::injectToResources(), and Resource::mRefCount.

Referenced by AtlasResource().

60 {
61  if (mRefCount == 0U)
64 }
unsigned int mRefCount
Definition: resource.h:86
virtual void incRef()
Definition: resource.cpp:37
static void injectToResources(const AtlasResource *const resource)

Field Documentation

◆ atlases

std::vector<TextureAtlas*> AtlasResource::atlases

The documentation for this class was generated from the following files: