#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/Buffer/Buffer2d.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_BUFFER2D_HEADER #define RAVL_BUFFER2D_HEADER 1 /////////////////////////////////////////////////////// //! rcsid="$Id: Buffer2d.hh,v 1.6 2002/07/07 21:41:12 craftit Exp $" //! file="Ravl/Core/Container/Buffer/Buffer2d.hh" //! lib=RavlCore //! docentry="Ravl.Core.Arrays.Buffer" //! author="Charles Galambos" #include "Ravl/Buffer.hh" //: Ravl global namespace. namespace RavlN { //! userlevel=Develop //: Buffer2D // This holds a handle to data used in various 2d arrays. template class Buffer2dBodyC : public BufferBodyC > { public: Buffer2dBodyC() {} //: Default constructor. Buffer2dBodyC(SizeT size1,SizeT size2) : BufferBodyC >(size1), data(size2 * size1) {} //: Sized constructor. Buffer2dBodyC(SizeT size1,SizeT size2,DataT *data,bool copy = false,bool deletable = true) : BufferBodyC >(size1), data(size1 * size2,data,copy, deletable) {} //: Sized constructor. Buffer2dBodyC(const BufferC &dat,SizeT size1) : BufferBodyC >(size1), data(dat) {} //: Construct a buffer with data area 'dat' and an access buffer with 'size1' entries. BufferC &Data() { return data; } //: Access data buffer. const BufferC &Data() const { return data; } //: Access data buffer. SizeT Size1() const { return BufferBodyC >::Size(); } //: Get size 1 SizeT Size2() const { return data.Size() / Size1(); } //: Get size 2 (estimate.) protected: BufferC data; }; //! userlevel=Develop //: Buffer2D // This holds a handle to data used in various 2d arrays. template class Buffer2dC : public BufferC > { public: Buffer2dC() {} //: Default constructor. // creates an invalid handle. Buffer2dC(SizeT size1,SizeT size2) : BufferC >(*new Buffer2dBodyC(size1,size2)) {} //: Sized constructor. Buffer2dC(const BufferC &dat,SizeT size1) : BufferC >(*new Buffer2dBodyC(dat,size1)) {} //: Construct a buffer with data area 'dat' and an access buffer with 'size1' entries. Buffer2dC(SizeT size1,SizeT size2,DataT *data,bool copy = false,bool deletable = true) : BufferC >(*new Buffer2dBodyC(size1,size2,data,copy,deletable)) {} //: Construct from an existing buffer. protected: Buffer2dBodyC &Body() { return static_cast &>(BufferC >::Body()); } //: Access body. const Buffer2dBodyC &Body() const { return static_cast &>(BufferC >::Body()); } //: Constant access to body. public: BufferC &Data() { return Body().Data(); } //: Access data buffer. const BufferC &Data() const { return Body().Data(); } //: Access data buffer. SizeT Size1() const { return Body().Size1(); } //: Get size of buffer along dimention 1 SizeT Size2() const { return Body().Size2(); } //: Get size of buffer along dimention 2 (estimate.) }; } #endif