Logo
~Sockets~
~Examples~
~Contact~

Steps Class Reference
[Database]

Database table Steps. More...

#include <Steps.h>

Inheritance diagram for Steps:

Inheritance graph
[legend]
Collaboration diagram for Steps:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Steps (Database &, Player &, Area &, long z, long y)
 ~Steps ()
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 AddCoord (long x)

Static Public Member Functions

static db::StepsGetStep (Player &, Area &, long z, long y)

Static Private Member Functions

static db::StepsGetSteps (Database &, Player &, Area &, long z, long y)

Private Attributes

Playerm_player
Aream_area
db::Stepsm_steps

Static Private Attributes

static steps_t m_cache

Detailed Description

Database table Steps.

Definition at line 39 of file Steps.h.


Constructor & Destructor Documentation

Steps::Steps ( Database &  ,
Player ,
Area ,
long  z,
long  y 
)

Definition at line 32 of file Steps.cpp.

References GetSteps(), and m_steps.

00033 :Object(db)
00034 ,m_player(pl)
00035 ,m_area(area)
00036 {
00037         m_steps = Steps::GetSteps(db, pl, area, z, y);
00038 }

Steps::~Steps (  ) 

Definition at line 41 of file Steps.cpp.

00042 {
00043 }


Member Function Documentation

void Steps::Save (  )  [virtual]

Save the object in database.

Implements Object.

Definition at line 84 of file Steps.cpp.

References m_steps.

Referenced by AddCoord().

00085 {
00086         m_steps -> save();
00087 }

bool Steps::Exists (  )  [virtual]

Check if the object already exists in database.

Returns:
true if the object exists

Implements Object.

Definition at line 90 of file Steps.cpp.

References m_steps.

00091 {
00092         if (m_steps && m_steps -> num)
00093                 return true;
00094         return false;
00095 }

long Steps::GetNum (  )  [virtual]

Get integer primary key from object.

Implements Object.

Definition at line 98 of file Steps.cpp.

References m_steps.

00099 {
00100         return m_steps -> num;
00101 }

void Steps::AddCoord ( long  x  ) 

Definition at line 61 of file Steps.cpp.

References m_steps, and Save().

00062 {
00063         Parse pa(m_steps -> xcoords, ":");
00064         std::string tmp = pa.getword();
00065         while (tmp.size())
00066         {
00067                 if (atol(tmp.c_str()) == x)
00068                         return;
00069                 //
00070                 tmp = pa.getword();
00071         }
00072         if (m_steps -> xcoords.size())
00073         {
00074                 m_steps -> xcoords += ":" + Utility::l2string(x);
00075         }
00076         else
00077         {
00078                 m_steps -> xcoords = Utility::l2string(x);
00079         }
00080         Save();
00081 }

db::Steps * Steps::GetStep ( Player ,
Area ,
long  z,
long  y 
) [static]

Definition at line 104 of file Steps.cpp.

References Area::GetNum(), Player::GetNum(), and m_cache.

Referenced by Player::Seen().

00105 {
00106         return m_cache[pl.GetNum()][area.GetNum()][z][y];
00107 }

db::Steps * Steps::GetSteps ( Database &  ,
Player ,
Area ,
long  z,
long  y 
) [static, private]

Definition at line 46 of file Steps.cpp.

References Area::GetNum(), Player::GetNum(), and m_cache.

Referenced by Steps().

00047 {
00048         db::Steps *p = m_cache[pl.GetNum()][area.GetNum()][z][y];
00049         if (p)
00050                 return p;
00051         p = new db::Steps(db, pl.GetNum(), area.GetNum(), z, y);
00052         p -> player = pl.GetNum();
00053         p -> area = area.GetNum();
00054         p -> zcoord = z;
00055         p -> ycoord = y;
00056         m_cache[pl.GetNum()][area.GetNum()][z][y] = p;
00057         return p;
00058 }


Member Data Documentation

steps_t Steps::m_cache [static, private]

Definition at line 55 of file Steps.h.

Referenced by GetStep(), and GetSteps().

Player& Steps::m_player [private]

Definition at line 56 of file Steps.h.

Area& Steps::m_area [private]

Definition at line 57 of file Steps.h.

Definition at line 58 of file Steps.h.

Referenced by AddCoord(), Exists(), GetNum(), Save(), and Steps().


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