ManaPlus
Public Member Functions | Private Attributes
Tileset Class Reference

#include <tileset.h>

Inheritance diagram for Tileset:
ImageSet Resource MemoryCounter

Public Member Functions

 Tileset (Image *const img, const int w, const int h, const int firstGid, const int margin, const int spacing)
 
int getFirstGid () const
 
void setProperties (const std::map< std::string, std::string > &props)
 
std::string getProperty (const std::string &name)
 
int calcMemoryLocal () const
 
- Public Member Functions inherited from ImageSet
 ImageSet (Image *const img, const int w, const int h, const int margin, const int spacing)
 
 ~ImageSet ()
 
int getWidth () const
 
int getHeight () const
 
Imageget (const size_type i) const
 
size_type size () const
 
int getOffsetX () const
 
void setOffsetX (const int n)
 
int getOffsetY () const
 
void setOffsetY (const int n)
 
const std::vector< Image * > & getImages () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
 ~Resource ()
 
virtual void incRef ()
 
virtual void decRef ()
 
int calcMemoryLocal () const
 
std::string getCounterName () const
 
- Public Member Functions inherited from MemoryCounter
 MemoryCounter ()
 
virtual ~MemoryCounter ()
 
int calcMemory (const int level) const
 
virtual int calcMemoryChilds (const int level) const
 

Private Attributes

int mFirstGid
 
std::map< std::string, std::string > mProperties
 

Additional Inherited Members

- Public Types inherited from ImageSet
typedef std::vector< Image * >::size_type size_type
 
- Data Fields inherited from Resource
time_t mTimeStamp
 
std::string mIdPath
 
std::string mSource
 
unsigned int mRefCount
 
bool mProtected
 
bool mNotCount
 

Detailed Description

A tileset, which is basically just an image set but it stores a firstgid.

Definition at line 33 of file tileset.h.

Constructor & Destructor Documentation

◆ Tileset()

Tileset::Tileset ( Image *const  img,
const int  w,
const int  h,
const int  firstGid,
const int  margin,
const int  spacing 
)
inline

Constructor.

Definition at line 39 of file tileset.h.

References A_DELETE_COPY.

Referenced by calcMemoryLocal().

44  :
45  ImageSet(img, w, h, margin, spacing),
46  mFirstGid(firstGid),
47  mProperties()
48  {
49  }
ImageSet(Image *const img, const int w, const int h, const int margin, const int spacing)
Definition: imageset.cpp:34
int mFirstGid
Definition: tileset.h:96
std::map< std::string, std::string > mProperties
Definition: tileset.h:98

Member Function Documentation

◆ calcMemoryLocal()

int Tileset::calcMemoryLocal ( ) const
inlinevirtual

Reimplemented from ImageSet.

Definition at line 78 of file tileset.h.

References ImageSet::calcMemoryLocal(), mProperties, and Tileset().

79  {
80  int sz = ImageSet::calcMemoryLocal() +
81  static_cast<int>(sizeof(Tileset));
82  const std::map<std::string, std::string>::const_iterator it_end =
83  mProperties.end();
84  std::map<std::string, std::string>::const_iterator it =
85  mProperties.begin();
86  while (it != it_end)
87  {
88  sz += static_cast<int>((*it).first.capacity() +
89  (*it).second.capacity());
90  ++ it;
91  }
92  return sz;
93  }
Tileset(Image *const img, const int w, const int h, const int firstGid, const int margin, const int spacing)
Definition: tileset.h:39
std::map< std::string, std::string > mProperties
Definition: tileset.h:98
int calcMemoryLocal() const
Definition: imageset.cpp:77

◆ getFirstGid()

int Tileset::getFirstGid ( ) const
inline

Returns the first gid.

Definition at line 56 of file tileset.h.

References mFirstGid.

57  { return mFirstGid; }
int mFirstGid
Definition: tileset.h:96

◆ getProperty()

std::string Tileset::getProperty ( const std::string &  name)
inline

Returns property value.

Definition at line 69 of file tileset.h.

References mProperties.

70  {
71  const std::map<std::string, std::string>::const_iterator
72  it = mProperties.find(name);
73  if (it == mProperties.end())
74  return "";
75  return mProperties[name];
76  }
std::map< std::string, std::string > mProperties
Definition: tileset.h:98

◆ setProperties()

void Tileset::setProperties ( const std::map< std::string, std::string > &  props)
inline

Set tileset property.

Definition at line 62 of file tileset.h.

References mProperties.

64  { mProperties = props; }
std::map< std::string, std::string > mProperties
Definition: tileset.h:98

Field Documentation

◆ mFirstGid

int Tileset::mFirstGid
private

Definition at line 96 of file tileset.h.

Referenced by getFirstGid().

◆ mProperties

std::map<std::string, std::string> Tileset::mProperties
private

Definition at line 98 of file tileset.h.

Referenced by calcMemoryLocal(), getProperty(), and setProperties().


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