Logo
~Sockets~
~Examples~
~Contact~

Chunkinfo.h

Go to the documentation of this file.
00001 // Chunkinfo.h
00002 // released 2006-09-25
00003 /*
00004 Copyright (C) 2006  Anders Hedstrom (grymse@alhem.net)
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 */
00020 #ifndef _CHUNKINFO_H
00021 #define _CHUNKINFO_H
00022 
00023 #include <map>
00024 #include <list>
00025 #include "Object.h"
00026 
00027 
00028 class Database;
00029 class Chunk;
00030 namespace db { class Chunkinfo; }
00031 class InSocket;
00032 
00033 typedef std::map<long,std::list<db::Chunkinfo *> > chunkinfos_t;
00034 
00037 class Chunkinfo : public Object
00038 {
00039 public:
00040         typedef enum // bits, please
00041         {
00042                 TYPE_PORTAL = 1,
00043                 TYPE_ROOM_DESCRIPTION = 2,
00044         } infotype_t;
00045 public:
00047         Chunkinfo(Database& db,Chunk& chunk);
00049         Chunkinfo(Database& db,Chunk& chunk,int x,int y,infotype_t type);
00050         ~Chunkinfo();
00051 
00052         void Save();
00053         bool Exists();
00054         long GetNum();
00055 
00056         void SetX(int);
00057         void SetY(int);
00058         int GetX();
00059         int GetY();
00060         void SetType(infotype_t);
00061         void SetData(const std::string&);
00062         infotype_t GetType();
00063         const std::string& GetData();
00064 
00065         virtual void Display(InSocket *) {}
00066 
00067 static  std::list<db::Chunkinfo *>& GetChunkinfo(Chunk& );
00068 static  Chunkinfo *GetInstance(Database&,Chunk&,int x,int y,infotype_t type);
00069 
00070 protected:
00071         db::Chunkinfo *m_chunkinfo;
00072 
00073 private:
00074 static  db::Chunkinfo *GetChunkinfo(Database& db,Chunk& chunk);
00075 static  db::Chunkinfo *GetChunkinfo(Database& db,Chunk& chunk,long num);
00076 static  db::Chunkinfo *GetChunkinfo(Database& db,Chunk& chunk,int x,int y,infotype_t type);
00077         Chunk& m_chunk;
00078 static  chunkinfos_t m_cache;
00079 };
00080 
00081 
00082 
00083 
00084 #endif // _CHUNKINFO_H
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