部屋座標クラス


4.2.4.4 部屋座標クラス

This is a very simple class that keeps track of a coordinate in the maze:

このクラスは、迷路の座標の把握するとても単純なクラスです。

class RoomCoordinate
{
public:
 int x, y, z;
 RoomCoordinate () : x (0), y (0), z (0) { }
 RoomCoordinate (int x, int y, int z) : x (x), y (y), z (z) { }
 RoomCoordinate (const RoomCoordinate& rc) : x (rc.x), y (rc.y), z (rc.z) { }
# ifdef CS_DEBUG
 static bool IsValid (int x, int y, int z)
 {
   return (x >= 0 && x < MAZE_DIMENSION &&
	    y >= 0 && y < MAZE_DIMENSION &&
	    z >= 0 && z < MAZE_DIMENSION);
 }
 bool IsValid () const
 {
   return IsValid (x, y, z);
 }
# endif
};

One special thing in this class is the usage of the `CS_DEBUG' define. When your application is compiled in debug mode this define will be set. This means that you can do additional checks in debug mode that will disappear in optimize/release mode. This is very useful during development.

1つ特別なことは、定義`CS_DEBUG`を使用していることです。もし、あなたのアプリケーションがデバッグモードでコンパイルされた場合、この定義がセットされます。これは、リリースモードでは消えるが、デバッグモードでのみ表示する情報を入れられることを意味します。これは開発のときに役に立ちます。