Skip to content
Snippets Groups Projects
Commit 33952cac authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

comment / wrong.

[[Imported from SVN: r1384]]
parent 25bbaadf
No related branches found
No related tags found
No related merge requests found
......@@ -3,20 +3,20 @@
#ifndef __DUNE_BSGRID_MYAUTOPTR_HH__
#define __DUNE_BSGRID_MYAUTOPTR_HH__
/** \brief An auto pointer class *\
template <class Pointer>
class AutoPointer
{
//! Pointer to Object
Pointer * ptr_;
/** \brief An auto pointer class */
template <class Pointer>
class AutoPointer
{
//! Pointer to Object
Pointer * ptr_;
//! number of copies that exist from this Object
mutable int *refCount_;
//! number of copies that exist from this Object
mutable int *refCount_;
public:
//! if a copy is made, the refcount is increased
inline AutoPointer(const AutoPointer<Pointer> & copy)
{
public:
//! if a copy is made, the refcount is increased
inline AutoPointer(const AutoPointer<Pointer> & copy)
{
ptr_ = 0;
refCount_ = 0;
if(copy.ptr_)
......@@ -25,14 +25,14 @@
refCount_ = copy.refCount_;
(*refCount_)++;
}
}
}
//! initialize the member variables
AutoPointer() : ptr_ (0) , refCount_ (0) {}
//! initialize the member variables
AutoPointer() : ptr_ (0) , refCount_ (0) {}
// store object pointer and create refCount
void store (Pointer * ptr)
{
// store object pointer and create refCount
void store (Pointer * ptr)
{
assert(ptr_ == 0);
ptr_ = ptr;
if(ptr_)
......@@ -41,11 +41,11 @@
refCount_ = tmp;
(*refCount_) = 1;
}
}
}
//! set Stack free, if no more refences exist
~AutoPointer()
{
//! set Stack free, if no more refences exist
~AutoPointer()
{
if(refCount_ && ptr_)
{
(*refCount_)--;
......@@ -55,32 +55,31 @@
if(refCount_) delete refCount_;
}
}
}
}
//! return object reference
Pointer & operator * () const
{
//! return object reference
Pointer & operator * () const
{
assert( ptr_ != 0);
return *ptr_;
}
}
//! return object pointer
Pointer * operator -> () const
{
//! return object pointer
Pointer * operator -> () const
{
assert( ptr_ != 0);
return ptr_;
}
}
private:
//! if copy is made than one more Reference exists
AutoPointer<Pointer> & operator = (const AutoPointer<Pointer> & copy)
{
private:
//! if copy is made than one more Reference exists
AutoPointer<Pointer> & operator = (const AutoPointer<Pointer> & copy)
{
assert(false);
return (*this);
}
};
}
};
#endif
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment