Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

vnl_vector_ref.h

Go to the documentation of this file.
00001 #ifndef vnl_vector_ref_h_
00002 #define vnl_vector_ref_h_
00003 // This is vxl/vnl/vnl_vector_ref.h
00004 
00005 //: 
00006 //  \file
00007 //  \brief vnl_vector using user-supplied storage
00008 //  \author Andrew W. Fitzgibbon, Oxford RRG, 04 Aug 96 
00009 
00010 //
00011 // Modifications
00012 // LSB (Manchester) 19/03/2001: Tidied up the documentation
00013 //
00014 //-----------------------------------------------------------------------------
00015 
00016 #include <vnl/vnl_vector.h>
00017 
00018 //: vnl_vector using user-supplied storage
00019 //   vnl_vector for which the data space has
00020 //   been supplied externally.
00021 export template <class T>
00022 class vnl_vector_ref : public vnl_vector<T> {
00023 public:
00024   typedef vnl_vector<T> Base;
00025 
00026   //: Constructor
00027   // Do *not* call anything else than the default constructor of vnl_vector<T>
00028   vnl_vector_ref(int n, T *space) : vnl_vector<T>() {
00029     Base::data = space;
00030     Base::num_elmts = n;
00031   }
00032   //: Copy constructor.
00033   vnl_vector_ref(vnl_vector_ref<T> const& v) : vnl_vector<T>() 
00034     {
00035       Base::data = v.data;
00036       Base::num_elmts = v.num_elmts;
00037     }
00038   
00039   //: Destructor
00040   // Prevents base destructor from releasing memory we don't own
00041   ~vnl_vector_ref() {
00042     
00043     Base::data = 0;
00044   }
00045 
00046   //private:
00047   // Private operator new because deleting a pointer to
00048   // one of these through a baseclass pointer will attempt
00049   // to free the referenced memory.
00050   // Therefore disallow newing of these -- if you're paying for
00051   // one malloc, you can afford two.
00052   // NOW COMMENTED OUT - PVR, may 97
00053   //void* operator new(size_t) { return 0; }
00054 
00055   //public:
00056   // Privatizing other new means we must offer placement new for STL
00057   //void* operator new(size_t, void* space) { return space; }
00058 };
00059 
00060 #endif // vnl_vector_ref_h_

Generated at Wed Mar 12 01:13:16 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000