Logo
~Sockets~
~Examples~
~Contact~

Terrain Class Reference
[Database]

Database table Terrain. More...

#include <Terrain.h>

Inheritance diagram for Terrain:

Inheritance graph
[legend]
Collaboration diagram for Terrain:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Terrain (Database &, Area &, char tchar)
 ~Terrain ()
bool Exists ()
 Check if the object already exists in database.
void Save ()
 Save the object in database.
const std::string & GetColor ()
void SetColor (const std::string &)
const std::string & GetName ()
void SetName (const std::string &)
char GetChar ()
void SetChar (char tchar)
bool IsImpassable ()
void SetImpassable (bool=true)
long GetNum ()
 Get integer primary key from object.
double GetDelay ()
void SetDelay (double)

Static Public Member Functions

static db::TerrainGetTerrain (Database &, Area &, char tchar)

Private Attributes

Aream_area
db::Terrainm_terrain

Static Private Attributes

static terrains_t m_terrains

Detailed Description

Database table Terrain.

Definition at line 35 of file Terrain.h.


Constructor & Destructor Documentation

Terrain::Terrain ( Database &  ,
Area ,
char  tchar 
)

Definition at line 31 of file Terrain.cpp.

References Area::GetNum(), GetTerrain(), and m_terrain.

00032 :Object(db)
00033 ,m_area(area)
00034 {
00035         m_terrain = Terrain::GetTerrain(db, area, tchar);
00036         m_terrain -> area = area.GetNum();
00037         m_terrain -> tchar = tchar;
00038 }

Terrain::~Terrain (  ) 

Definition at line 41 of file Terrain.cpp.

00042 {
00043 }


Member Function Documentation

bool Terrain::Exists (  )  [virtual]

Check if the object already exists in database.

Returns:
true if the object exists

Implements Object.

Definition at line 62 of file Terrain.cpp.

References m_terrain.

Referenced by Setcmd::Execute(), Create::OnLine(), and Area::VerifyTerrain().

00063 {
00064         if (m_terrain && m_terrain -> num)
00065                 return true;
00066         return false;
00067 }

void Terrain::Save (  )  [virtual]

Save the object in database.

Implements Object.

Definition at line 82 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine(), and Area::VerifyTerrain().

00083 {
00084         m_terrain -> save();
00085 }

const std::string & Terrain::GetColor (  ) 

Definition at line 70 of file Terrain.cpp.

References m_terrain.

Referenced by Map::Execute(), and Create::OnLine().

00071 {
00072         return m_terrain -> tcolor;
00073 }

void Terrain::SetColor ( const std::string &   ) 

Definition at line 94 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine(), and Area::VerifyTerrain().

00095 {
00096         m_terrain -> tcolor = x;
00097 }

const std::string & Terrain::GetName (  ) 

Definition at line 100 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine().

00101 {
00102         return m_terrain -> name;
00103 }

void Terrain::SetName ( const std::string &   ) 

Definition at line 106 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine(), and Area::VerifyTerrain().

00107 {
00108         m_terrain -> name = x;
00109 }

char Terrain::GetChar (  ) 

Definition at line 76 of file Terrain.cpp.

References m_terrain.

Referenced by Chunk::Edge(), and Setcmd::Execute().

00077 {
00078         return m_terrain -> tchar[0];
00079 }

void Terrain::SetChar ( char  tchar  ) 

Definition at line 88 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine().

00089 {
00090         m_terrain -> tchar = tchar;
00091 }

bool Terrain::IsImpassable (  ) 

Definition at line 112 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine().

00113 {
00114         return m_terrain -> impassable ? true : false;
00115 }

void Terrain::SetImpassable ( bool  = true  ) 

Definition at line 118 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine().

00119 {
00120         m_terrain -> impassable = x ? 1 : 0;
00121 }

long Terrain::GetNum (  )  [virtual]

Get integer primary key from object.

Implements Object.

Definition at line 124 of file Terrain.cpp.

References m_terrain.

00125 {
00126         return m_terrain -> num;
00127 }

double Terrain::GetDelay (  ) 

Definition at line 130 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine().

00131 {
00132         return m_terrain -> delay;
00133 }

void Terrain::SetDelay ( double   ) 

Definition at line 136 of file Terrain.cpp.

References m_terrain.

Referenced by Create::OnLine().

00137 {
00138         m_terrain -> delay = d;
00139 }

db::Terrain * Terrain::GetTerrain ( Database &  ,
Area ,
char  tchar 
) [static]

Definition at line 46 of file Terrain.cpp.

References Area::GetNum(), and m_terrains.

Referenced by Terrain().

00047 {
00048         std::map<char,db::Terrain *>& ref = m_terrains[area.GetNum()];
00049         db::Terrain *p = ref[tchar];
00050         if (p != NULL)
00051                 return p;
00052         std::string tmp;
00053         tmp += tchar;
00054         p = new db::Terrain(db, area.GetNum(), tmp);
00055         p -> area = area.GetNum();
00056         p -> tchar = tchar;
00057         ref[tchar] = p;
00058         return p;
00059 }


Member Data Documentation

Area& Terrain::m_area [private]

Definition at line 59 of file Terrain.h.

terrains_t Terrain::m_terrains [static, private]

Definition at line 60 of file Terrain.h.

Referenced by GetTerrain().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4