Salome HOME
remove a reference to the $MED_ROOT_DIR in the Makefile.in wich is useless
[modules/med.git] / src / MEDMEM / MEDMEM_PointerOf.hxx
index 1b7b6ede25a37f98f406a01134c061776d24ed2f..33ce95da21e3d35cc20c77be637aa361cb24adbc 100644 (file)
@@ -13,6 +13,7 @@
         In these cases, memory will be desallocated at object destruction. In all other cases,
        the desallocator will only nullify pointers.
 */
+namespace MEDMEM {
 
 template <typename T> class PointerOf
 {
@@ -35,6 +36,7 @@ public :
        void set( const int &size ) ;
        void set( const T *pointer ) ;
        void set( const int &size, const T *pointer ) ;
+        void setShallowAndOwnership( const T *pointer );
        PointerOf<T>& operator=( const PointerOf<T> &pointer ) ;
 } ;
 
@@ -44,7 +46,6 @@ public :
 //                                                             //
 // ------------------------------------------------------------ //
 
-
 /*! Creates a null T* pointer and sets the boolean (for desallocation) to false. */
 template <typename T> PointerOf<T>::PointerOf() : _pointer(0), _done(false)
 {
@@ -73,7 +74,7 @@ template <typename T> PointerOf<T>::PointerOf( const int &size, const PointerOf<
 }
 
 /*! If size <= 0, creates a null "T*" pointer\n
-    Else allocates memory and sets desallocation boolean to true./n
+    Else allocates memory and sets desallocation boolean to true.\n
     Memory will be desallocated  when erasing this PointerOf*/
 template <typename T> PointerOf<T>::PointerOf( const int &size )
 {
@@ -89,15 +90,15 @@ template <typename T> PointerOf<T>::PointerOf( const int &size )
         }
 }
 
-/*! Creates a standard pointer to the memory zone pointed by T*. /n
-   T* owner is in charged of memory desallocation. /n
+/*! Creates a standard pointer to the memory zone pointed by T*. \n
+   T* owner is in charged of memory desallocation. \n
    Memory will not be released when erasing this PointerOf*/
 template <typename T> PointerOf<T>::PointerOf( const T* pointer ) : _pointer( (T*)pointer ), _done(false)
 {
 }
 
 /*! If size <= 0, return an exception\n
-    Else duplicate array and sets desallocation boolean to true./n
+    Else duplicate array and sets desallocation boolean to true.\n
     Memory will be desallocated  when erasing this PointerOf*/
 template <typename T> PointerOf<T>::PointerOf( const int &size, const T* pointer)
 {
@@ -161,9 +162,9 @@ template <typename T> PointerOf<T>::operator const T*() const
 }
 
 
-/*! If necessary, released memory holded by PointerOf/n.
-    Else allocates memory and sets desallocation boolean to true./n
-    Can be used in order to "nullify" an existing PointerOf/n
+/*! If necessary, released memory holded by PointerOf\n.
+    Else allocates memory and sets desallocation boolean to true.\n
+    Can be used in order to "nullify" an existing PointerOf\n
     Memory will be desallocated  when erasing this PointerOf*/
 template <typename T> void PointerOf<T>::set( const int &size )
 {
@@ -184,9 +185,9 @@ template <typename T> void PointerOf<T>::set( const int &size )
        return ;
 }
 
-/*! If necessary, released memory holded by PointerOf/n.
-    Then, sets _pointer to the memory zone pointed by T*. /n
-    T* owner is in charged of memory desallocation. /n
+/*! If necessary, released memory holded by PointerOf\n.
+    Then, sets _pointer to the memory zone pointed by T*. \n
+    T* owner is in charged of memory desallocation. \n
     memory will not be released when erasing this PointerOf*/
 template <typename T> void PointerOf<T>::set( const T *pointer )
 {
@@ -206,10 +207,10 @@ template <typename T> void PointerOf<T>::set( const T *pointer )
        return ;
 }
 
-/*! If necessary, released memory holded by PointerOf/n.
+/*! If necessary, released memory holded by PointerOf\n.
     If size <= 0, return an exception\n.
-    Else allocates memory and sets desallocation boolean to true./n
-    Can be used in order to "nullify" an existing PointerOf/n
+    Else allocates memory and sets desallocation boolean to true.\n
+    Can be used in order to "nullify" an existing PointerOf\n
     Memory will be desallocated  when erasing this PointerOf*/
 template <typename T> void PointerOf<T>::set( const int &size, const T *pointer)
 {
@@ -228,4 +229,14 @@ template <typename T> void PointerOf<T>::set( const int &size, const T *pointer)
   return ;
 }
 
+template <typename T> void PointerOf<T>::setShallowAndOwnership( const T *pointer )
+{
+  if ( _pointer && _done )
+    delete [] _pointer;
+  _pointer=(T*)pointer;
+  _done=true;
+}
+
+}//End namespace MEDMEM
+
 # endif                /* # if ! defined( __PointerOf_HXX__ ) */