Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages | Examples

agg_span_allocator.h

00001 //----------------------------------------------------------------------------
00002 // Anti-Grain Geometry - Version 2.2
00003 // Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
00004 //
00005 // Permission to copy, use, modify, sell and distribute this software 
00006 // is granted provided this copyright notice appears in all copies. 
00007 // This software is provided "as is" without express or implied
00008 // warranty, and with no claim as to its suitability for any purpose.
00009 //
00010 //----------------------------------------------------------------------------
00011 // Contact: mcseem@antigrain.com
00012 //          mcseemagg@yahoo.com
00013 //          http://www.antigrain.com
00014 //----------------------------------------------------------------------------
00015 
00016 #ifndef AGG_SPAN_ALLOCATOR_INCLUDED
00017 #define AGG_SPAN_ALLOCATOR_INCLUDED
00018 
00019 #include "agg_basics.h"
00020 
00021 namespace agg
00022 {
00023     //----------------------------------------------------------span_allocator
00024     template<class ColorT> class span_allocator
00025     {
00026     public:
00027         typedef ColorT color_type;
00028 
00029         //--------------------------------------------------------------------
00030         ~span_allocator()
00031         {
00032             delete [] m_span;
00033         }
00034 
00035         //--------------------------------------------------------------------
00036         span_allocator() :
00037             m_max_span_len(0),
00038             m_span(0)
00039         {
00040         }
00041 
00042         //--------------------------------------------------------------------
00043         color_type* allocate(unsigned max_span_len)
00044         {
00045             if(max_span_len > m_max_span_len)
00046             {
00047                 delete [] m_span;
00048                 m_span = new color_type[m_max_span_len = max_span_len];
00049             }
00050             return m_span;
00051         }
00052 
00053         //--------------------------------------------------------------------
00054         color_type* span()
00055         { 
00056             return m_span; 
00057         }
00058 
00059     private:
00060         //--------------------------------------------------------------------
00061         span_allocator(const span_allocator<ColorT>&);
00062         const span_allocator<ColorT>& operator = (const span_allocator<ColorT>&);
00063 
00064         unsigned    m_max_span_len;
00065         color_type* m_span;
00066     };
00067 }
00068 
00069 
00070 #endif
00071 
00072 

Generated on Wed Feb 9 11:31:35 2005 for OpenGUI by  doxygen 1.4.0