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

Pointer.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2003-2005 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 
00023 #ifndef _DWFCORE_POINTER_H
00024 #define _DWFCORE_POINTER_H
00025 
00031 
00032 #include "dwfcore/Core.h"
00033 
00034 
00035 namespace DWFCore
00036 {
00037 
00048 template<class T>
00049 class DWFPointer
00050 {
00051 
00052 public:
00053 
00071     DWFPointer( T* pT, bool bArray )
00072         : _pT( pT )
00073         , _bArray( bArray )
00074     {;}
00075 
00081     virtual ~DWFPointer()
00082     {
00083         if (_pT)
00084         {
00085             if (_bArray)
00086             {
00087                 DWFCORE_FREE_MEMORY( _pT );
00088             }
00089             else
00090             {
00091                 DWFCORE_FREE_OBJECT( _pT );
00092             }
00093         }
00094     }
00095 
00102     DWFPointer&
00103     operator=( T* pT )
00104         throw()
00105     {
00106         _pT = pT;
00107         return *this;
00108     }
00109 
00116     operator T*() const
00117         throw()
00118     {
00119         return _pT;
00120     }
00121 
00128     operator const T*() const
00129         throw()
00130     {
00131         return (const T*)_pT;
00132     }
00133 
00140     operator void*() const
00141         throw()
00142     {
00143         return (void*)_pT;
00144     }
00145 
00152     operator const void*() const
00153         throw()
00154     {
00155         return (const void*)_pT;
00156     }
00157 
00164     operator T&() const
00165     {
00166         return *_pT;
00167     }
00168 
00175     operator const T&() const
00176     {
00177         return (const T&)*_pT;
00178     }
00179 
00187     bool null() const
00188         throw()
00189     {
00190         return (_pT == NULL);
00191     }
00192 
00199     T* operator->() const
00200     {
00201         return _pT;
00202     }
00203 
00204 private:
00205 
00206     T*      _pT;
00207     bool    _bArray;
00208 
00209 private:
00210 
00211     //
00212     // not implemented
00213     //
00214 
00215     DWFPointer( const DWFPointer& );
00216     const DWFPointer& operator=( const DWFPointer& );
00217 };
00218 
00219 }
00220 
00221 #endif

Generated on Tue May 17 12:05:10 2005 for Autodesk DWF Core Library by  doxygen 1.4.1