Crazy Eddies GUI System: CEGUIDataContainer.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# CEGUIDataContainer.h

    00001 /************************************************************************
    00002         filename:       CEGUIDataContainer.h
    00003         created:        10/8/2004
    00004         author:         James '_mental_' O'Sullivan
    00005
    00006         purpose:        Defines abstract base class for Window objects
    00007 *************************************************************************/
    00008 /*************************************************************************
    00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00011
    00012     This library is free software; you can redistribute it and/or
    00013     modify it under the terms of the GNU Lesser General Public
    00014     License as published by the Free Software Foundation; either
    00015     version 2.1 of the License, or (at your option) any later version.
    00016
    00017     This library is distributed in the hope that it will be useful,
    00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020     Lesser General Public License for more details.
    00021
    00022     You should have received a copy of the GNU Lesser General Public
    00023     License along with this library; if not, write to the Free Software
    00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025 *************************************************************************/
    00026 #ifndef _CEGUIDataContainer_h_
    00027 #define _CEGUIDataContainer_h_
    00028
    00029 #include "CEGUIBase.h"
    00030
    00031 #include <malloc.h>
    00032 //#include <xercesc/sax/InputSource.hpp>
    00033
    00034 // Start of CEGUI namespace section
    00035 namespace CEGUI
    00036 {
    00037
    00038 template <class T>
    00039 class CEGUIEXPORT DataContainer
    00040 {
    00041 public:
    00042         /*************************************************************************
    00043                 Construction and Destruction
    00044         *************************************************************************/
    00049     DataContainer()
    00050       : mData(0),
    00051         mSize(0)
    00052     {
    00053     }
    00054
    00059         virtual ~DataContainer(void)
    00060     {
    00061         release();
    00062     }
    00063
    00064         /*************************************************************************
    00065                 Accessor functions
    00066         *************************************************************************/
    00074     void setData(T* data) { mData = data; }
    00075
    00083     T* getDataPtr(void) { return mData; }
    00084
    00092     void setSize(size_t size) { mSize = size; }
    00093
    00101     size_t getSize(void) const { return mSize; }
    00102
    00108     virtual void release(void)
    00109     {
    00110         if(mData)
    00111         {
    00112             delete mData;
    00113             mData = 0;
    00114         }
    00115     }
    00116         /*************************************************************************
    00117                 Implementation Data
    00118         *************************************************************************/
    00119 protected:
    00120     T* mData;
    00121     size_t mSize;
    00122 };
    00123
    00124 // Specialized templates
    00125 class RawDataContainer : public DataContainer<unsigned char>
    00126 {
    00127 public:
    00128     RawDataContainer() : DataContainer<unsigned char>()
    00129     {
    00130     }
    00131
    00132     ~RawDataContainer()
    00133     {
    00134         release();
    00135     }
    00136
    00137     void release(void)
    00138     {
    00139         if(mData)
    00140         {
    00141             delete [] mData;
    00142             mData = 0;
    00143         }
    00144     }
    00145 };
    00146
    00147 //typedef DataContainer<unsigned char> RawDataContainer;
    00148 //typedef DataContainer<XERCES_CPP_NAMESPACE::InputSource> InputSourceContainer;
    00149
    00150 } // End of  CEGUI namespace section
    00151
    00152 #endif  // end of guard _CEGUIDataContainer_h_
    00153
    00154