ConfigMatrix.h

Go to the documentation of this file.
00001 
00011 #ifndef __CONFIGMATRIX__H__
00012 #define __CONFIGMATRIX__H__
00013 
00014 #include <deque>
00015 
00016 #include "../common.h"
00017 #include "../objects/Object.h"
00018 #include "../tinyxml/tinyxml.h"
00019 #include "../exceptions.h"
00020 #include "BaseConfig.h"
00021 
00025 class ConfigMatrix: public BaseConfig {
00026 public:
00030         typedef size_t SizeType;
00031 
00035         class ConfigCell: public BaseConfig {
00036         public:
00046                 ConfigCell(ConfigMatrix::SizeType xIndex, ConfigMatrix::SizeType yIndex,
00047                         const Object::Config * objectConfig):
00048                         x(xIndex), y(yIndex), objConfig(objectConfig) {}
00049 
00053                 explicit ConfigCell(TiXmlElement * node);
00054 
00058                 virtual ~ConfigCell() {
00059                         delete objConfig;
00060                 }
00061 
00065                 virtual TiXmlElement * CreateXmlNode() const;
00066 
00070                 ConfigMatrix::SizeType GetXIndex() const { return x; }
00071 
00075                 ConfigMatrix::SizeType GetYIndex() const { return y; }
00076 
00080                 const Object::Config * GetObjectConfig() const { return objConfig; }
00081 
00086                 void SetXIndex(ConfigMatrix::SizeType index) { x = index; }
00087 
00092                 void SetYIndex(ConfigMatrix::SizeType index) { y = index; }
00093 
00098                 void SetObjectConfig(const Object::Config * object) { objConfig = object; }
00099 
00100         private:
00102                 ConfigMatrix::SizeType x;
00104                 ConfigMatrix::SizeType y;
00106                 const Object::Config * objConfig;
00107 
00108         private:
00109                 // Protections - not implemented
00110                 ConfigCell(const ConfigCell &);
00111                 ConfigCell & operator=(const ConfigCell &);
00112         };
00113 
00114 public:
00120         ConfigMatrix(SizeType matrixWidth, SizeType matrixHeight):
00121                 width(matrixWidth), height(matrixHeight) {
00122                 currentCell = container.begin();
00123         }
00124 
00128         explicit ConfigMatrix(TiXmlElement * node);
00129 
00133         virtual ~ConfigMatrix();
00134 
00138         virtual TiXmlElement * CreateXmlNode() const;
00139 
00144         void SetWidth(SizeType matrixWidth) {
00145                 width = matrixWidth;
00146         }
00147 
00151         SizeType GetWidth() const {
00152                 return width;
00153         }
00154 
00159         void SetHeight(SizeType matrixHeight) {
00160                 height = matrixHeight;
00161         }
00162 
00166         SizeType GetHeight() const {
00167                 return height;
00168         }
00169 
00177         void AddConfigCell(const ConfigCell * cell);
00178 
00186         const ConfigCell & GetConfigCell() const;
00187 
00191         bool AreThereConfigCells() const {
00192                 return (!container.empty() && currentCell != container.end());
00193         }
00194 
00195 private:
00199         typedef std::deque<const ConfigCell *> CellsContainer;
00200 
00202         SizeType width;
00204         SizeType height;
00206         CellsContainer container;
00208         mutable CellsContainer::iterator currentCell;
00209 };
00210 
00211 #endif /* #ifndef __CONFIGMATRIX__H__ */
00212 
00213 /* End of file ConfigMatrix.h */

Generated on Sun Apr 29 11:46:10 2007 for IPP/ICP2007 by  doxygen 1.4.7