![]() |
Chunkinfo Class ReferenceDatabase table Chunkinfo.
More...
|
Public Types | |
enum | infotype_t { TYPE_PORTAL = 1, TYPE_ROOM_DESCRIPTION = 2 } |
Public Member Functions | |
Chunkinfo (Database &db, Chunk &chunk) | |
Create and save empty chunkinfo. | |
Chunkinfo (Database &db, Chunk &chunk, int x, int y, infotype_t type) | |
Get location specific chunkinfo. | |
~Chunkinfo () | |
void | Save () |
Save the object in database. | |
bool | Exists () |
Check if the object already exists in database. | |
long | GetNum () |
Get integer primary key from object. | |
void | SetX (int) |
void | SetY (int) |
int | GetX () |
int | GetY () |
void | SetType (infotype_t) |
void | SetData (const std::string &) |
infotype_t | GetType () |
const std::string & | GetData () |
virtual void | Display (InSocket *) |
Static Public Member Functions | |
static std::list< db::Chunkinfo * > & | GetChunkinfo (Chunk &) |
static Chunkinfo * | GetInstance (Database &, Chunk &, int x, int y, infotype_t type) |
Protected Attributes | |
db::Chunkinfo * | m_chunkinfo |
Static Private Member Functions | |
static db::Chunkinfo * | GetChunkinfo (Database &db, Chunk &chunk) |
static db::Chunkinfo * | GetChunkinfo (Database &db, Chunk &chunk, long num) |
static db::Chunkinfo * | GetChunkinfo (Database &db, Chunk &chunk, int x, int y, infotype_t type) |
Private Attributes | |
Chunk & | m_chunk |
Static Private Attributes | |
static chunkinfos_t | m_cache |
Definition at line 37 of file Chunkinfo.h.
Definition at line 40 of file Chunkinfo.h.
00041 { 00042 TYPE_PORTAL = 1, 00043 TYPE_ROOM_DESCRIPTION = 2, 00044 } infotype_t;
Chunkinfo::Chunkinfo | ( | Database & | db, | |
Chunk & | chunk | |||
) |
Create and save empty chunkinfo.
Definition at line 34 of file Chunkinfo.cpp.
References GetChunkinfo(), and m_chunkinfo.
00034 : Object(db), m_chunk(chunk) 00035 { 00036 m_chunkinfo = Chunkinfo::GetChunkinfo(db, chunk); 00037 }
Chunkinfo::Chunkinfo | ( | Database & | db, | |
Chunk & | chunk, | |||
int | x, | |||
int | y, | |||
infotype_t | type | |||
) |
Get location specific chunkinfo.
Definition at line 40 of file Chunkinfo.cpp.
References GetChunkinfo(), and m_chunkinfo.
00040 : Object(db), m_chunk(chunk) 00041 { 00042 m_chunkinfo = Chunkinfo::GetChunkinfo(db, chunk, x, y, type); 00043 }
Chunkinfo::~Chunkinfo | ( | ) |
void Chunkinfo::Save | ( | ) | [virtual] |
Save the object in database.
Implements Object.
Definition at line 51 of file Chunkinfo.cpp.
References m_chunkinfo.
Referenced by Chunk::AddPortal().
00052 { 00053 m_chunkinfo -> save(); 00054 }
bool Chunkinfo::Exists | ( | ) | [virtual] |
Check if the object already exists in database.
Implements Object.
Definition at line 57 of file Chunkinfo.cpp.
References m_chunkinfo.
Referenced by Portal::Display().
00058 { 00059 if (m_chunkinfo && m_chunkinfo -> num) 00060 return true; 00061 return false; 00062 }
long Chunkinfo::GetNum | ( | ) | [virtual] |
Get integer primary key from object.
Implements Object.
Definition at line 65 of file Chunkinfo.cpp.
References m_chunkinfo.
00066 { 00067 return m_chunkinfo -> num; 00068 }
void Chunkinfo::SetX | ( | int | ) |
Definition at line 121 of file Chunkinfo.cpp.
References m_chunkinfo.
Referenced by Chunk::AddPortal().
00122 { 00123 m_chunkinfo -> x = x; 00124 }
void Chunkinfo::SetY | ( | int | ) |
Definition at line 127 of file Chunkinfo.cpp.
References m_chunkinfo.
Referenced by Chunk::AddPortal().
00128 { 00129 m_chunkinfo -> y = x; 00130 }
int Chunkinfo::GetX | ( | ) |
Definition at line 133 of file Chunkinfo.cpp.
References m_chunkinfo.
00134 { 00135 return m_chunkinfo -> x; 00136 }
int Chunkinfo::GetY | ( | ) |
Definition at line 139 of file Chunkinfo.cpp.
References m_chunkinfo.
00140 { 00141 return m_chunkinfo -> y; 00142 }
void Chunkinfo::SetType | ( | infotype_t | ) |
Definition at line 97 of file Chunkinfo.cpp.
References m_chunkinfo.
Referenced by Chunk::AddPortal().
00098 { 00099 m_chunkinfo -> type = x; 00100 }
void Chunkinfo::SetData | ( | const std::string & | ) |
Definition at line 103 of file Chunkinfo.cpp.
References m_chunkinfo.
00104 { 00105 m_chunkinfo -> data = x; 00106 }
Chunkinfo::infotype_t Chunkinfo::GetType | ( | ) |
Definition at line 109 of file Chunkinfo.cpp.
References m_chunkinfo.
00110 { 00111 return (infotype_t)m_chunkinfo -> type; 00112 }
const std::string & Chunkinfo::GetData | ( | ) |
Definition at line 115 of file Chunkinfo.cpp.
References m_chunkinfo.
Referenced by RoomDescription::Display().
00116 { 00117 return m_chunkinfo -> data; 00118 }
virtual void Chunkinfo::Display | ( | InSocket * | ) | [inline, virtual] |
std::list< db::Chunkinfo * > & Chunkinfo::GetChunkinfo | ( | Chunk & | ) | [static] |
Definition at line 166 of file Chunkinfo.cpp.
References Chunk::GetNum(), and m_cache.
Referenced by Chunkinfo(), and Chunk::Show().
Chunkinfo * Chunkinfo::GetInstance | ( | Database & | , | |
Chunk & | , | |||
int | x, | |||
int | y, | |||
infotype_t | type | |||
) | [static] |
Definition at line 172 of file Chunkinfo.cpp.
References TYPE_PORTAL, and TYPE_ROOM_DESCRIPTION.
Referenced by Chunk::Show().
00173 { 00174 switch (type) 00175 { 00176 case TYPE_PORTAL: 00177 return new Portal(db, chunk, x, y); 00178 case TYPE_ROOM_DESCRIPTION: 00179 return new RoomDescription(db, chunk, x, y); 00180 } 00181 return NULL; 00182 }
db::Chunkinfo * Chunkinfo::GetChunkinfo | ( | Database & | db, | |
Chunk & | chunk | |||
) | [static, private] |
Definition at line 71 of file Chunkinfo.cpp.
References Chunk::GetNum(), and m_cache.
00072 { 00073 std::list<db::Chunkinfo *>& ref = m_cache[chunk.GetNum()]; 00074 db::Chunkinfo *p = new db::Chunkinfo(&db); 00075 p -> chunk = chunk.GetNum(); 00076 ref.push_back(p); 00077 return p; 00078 }
db::Chunkinfo * Chunkinfo::GetChunkinfo | ( | Database & | db, | |
Chunk & | chunk, | |||
long | num | |||
) | [static, private] |
Definition at line 81 of file Chunkinfo.cpp.
References Chunk::GetNum(), and m_cache.
00082 { 00083 std::list<db::Chunkinfo *>& ref = m_cache[chunk.GetNum()]; 00084 for (std::list<db::Chunkinfo *>::iterator it = ref.begin(); it != ref.end(); it++) 00085 { 00086 db::Chunkinfo *p = *it; 00087 if (p -> num == num) 00088 return p; 00089 } 00090 db::Chunkinfo *p = new db::Chunkinfo(db, num); 00091 p -> chunk = chunk.GetNum(); 00092 ref.push_back(p); 00093 return p; 00094 }
db::Chunkinfo * Chunkinfo::GetChunkinfo | ( | Database & | db, | |
Chunk & | chunk, | |||
int | x, | |||
int | y, | |||
infotype_t | type | |||
) | [static, private] |
Definition at line 145 of file Chunkinfo.cpp.
References Chunk::GetNum(), and m_cache.
00146 { 00147 std::list<db::Chunkinfo *>& ref = m_cache[chunk.GetNum()]; 00148 for (std::list<db::Chunkinfo *>::iterator it = ref.begin(); it != ref.end(); it++) 00149 { 00150 db::Chunkinfo *p = *it; 00151 if (p -> x == x && p -> y == y && p -> type == type) 00152 { 00153 return p; 00154 } 00155 } 00156 db::Chunkinfo *p = new db::Chunkinfo(db, chunk.GetNum(), type, x, y); 00157 p -> chunk = chunk.GetNum(); 00158 p -> type = type; 00159 p -> x = x; 00160 p -> y = y; 00161 ref.push_back(p); 00162 return p; 00163 }
db::Chunkinfo* Chunkinfo::m_chunkinfo [protected] |
Definition at line 71 of file Chunkinfo.h.
Referenced by Chunkinfo(), Exists(), GetData(), GetNum(), Portal::GetToArea(), Portal::GetToChunk(), Portal::GetToX(), Portal::GetToY(), GetType(), GetX(), GetY(), Save(), SetData(), Portal::SetToArea(), Portal::SetToChunk(), Portal::SetToX(), Portal::SetToY(), SetType(), SetX(), and SetY().
Chunk& Chunkinfo::m_chunk [private] |
Definition at line 77 of file Chunkinfo.h.
chunkinfos_t Chunkinfo::m_cache [static, private] |