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
void setEmpty (const bool b)
bool isEmpty () 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

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

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 34 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 


Definition at line 40 of file tileset.h.

45  :
46  ImageSet(img, w, h, margin, spacing),
47  mProperties(),
48  mFirstGid(firstGid),
49  mIsEmpty(false)
50  {
51  }
ImageSet(Image *const img, const int w, const int h, const int margin, const int spacing)
Definition: imageset.cpp:35
bool mIsEmpty
Definition: tileset.h:106
std::map< std::string, std::string > mProperties
Definition: tileset.h:104
int mFirstGid
Definition: tileset.h:105

Referenced by calcMemoryLocal().

Member Function Documentation

◆ calcMemoryLocal()

int Tileset::calcMemoryLocal ( ) const

Reimplemented from ImageSet.

Definition at line 80 of file tileset.h.

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

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

◆ getFirstGid()

int Tileset::getFirstGid ( ) const

Returns the first gid.

Definition at line 58 of file tileset.h.

59  { return mFirstGid; }

References mFirstGid.

Referenced by setTile().

◆ getProperty()

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

Returns property value.

Definition at line 71 of file tileset.h.

72  {
73  const std::map<std::string, std::string>::const_iterator
74  it = mProperties.find(name);
75  if (it == mProperties.end())
76  return "";
77  return mProperties[name];
78  }

References mProperties.

◆ isEmpty()

bool Tileset::isEmpty ( ) const

Definition at line 100 of file tileset.h.

101  { return mIsEmpty; }

References mIsEmpty.

Referenced by setTile().

◆ setEmpty()

void Tileset::setEmpty ( const bool  b)

Definition at line 97 of file tileset.h.

98  { mIsEmpty = b; }

References mIsEmpty.

Referenced by MapReader::readTileset().

◆ setProperties()

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

Set tileset property.

Definition at line 64 of file tileset.h.

66  { mProperties = props; }

References mProperties.

Referenced by MapReader::readTileset().

Field Documentation

◆ mFirstGid

int Tileset::mFirstGid

Definition at line 105 of file tileset.h.

Referenced by getFirstGid().

◆ mIsEmpty

bool Tileset::mIsEmpty

Definition at line 106 of file tileset.h.

Referenced by isEmpty(), and setEmpty().

◆ mProperties

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

Definition at line 104 of file tileset.h.

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

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