/** * NaosEngine - Open Source Game Engine * Copyright (C) 2008-2009 * For the latest info, see http://aierosracing.xooit.com/index.php * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **/ #ifndef __NaosBuffer_HPP__ #define __NaosBuffer_HPP__ #include "NaosPrerequisities.hpp" namespace Naos { class _NaosExport_ Buffer { private: /// Taille du buffer. size_t mSize; /// Position dans le buffer. unsigned int mPosition; /// Données contenu dans le buffer. char* mData; /// Taille maximal du buffer /// @Note /// Si aucune taille n'est spécifiée lors de la création du buffer /// MAX_BUFFER_SIZE est la taille par défaut du buffer. static const unsigned int MAX_BUFFER_SIZE; public: /** * Constructeur par défaut. */ Buffer(); /** * Constructeur surchargé. * @Param _data : données à mettre dans le buffer * _size : taille du buffer. */ Buffer(char* _data, size_t _size); /** * Constructeur par copie. */ Buffer(const Buffer& _buffer); /** * Destructeur. */ ~Buffer(); /** * Copie le contenu du buffer _rhs vers le buffer courant. * @Note * Ceci produit 2 buffers identiques (même données, même taille) * La modification d'un buffer n'influe pas sur l'autre. * @Param _rhs : buffer source. * @Retour Nouveau buffer créé. */ Buffer& operator = (const Buffer& _rhs); /** * Retourne un pointeur sur le début des données contenu dans le buffer. */ void* getData(void) const { return mData; } /** * Défini une nouvelle taille pour le buffer. * @Param _size : nouvelle taille du buffer. */ void setSize(size_t _size); /** * Retourne la taille du buffer. */ unsigned int getSize(void) const { return mSize; } /** * Etablit la position dans le buffer. * @Param _position : position dans le buffer. */ void setPosition(unsigned int _position); /** * Retourne la position actuelle dans le buffer. */ unsigned int getPosition(void) const { return mPosition; } /** * Inscrit une donnée dans le buffer. * @Param _data : donnée à inscrire. */ template Buffer& operator << (const T* _data); }; } // Naos. #endif // __NaosBuffer_HPP__