cgal/Packages/Kernel_23/include/CGAL/Simple_Handle_for.h

101 lines
1.8 KiB
C++

// ======================================================================
//
// Copyright (c) 2001,2002,2003 The CGAL Consortium
//
// This software and related documentation is part of an INTERNAL release
// of the Computational Geometry Algorithms Library (CGAL). It is not
// intended for general use.
//
// ----------------------------------------------------------------------
//
// release :
// release_date :
//
// file : include/CGAL/Simple_Handle_for.h
// revision : $Revision$
// revision_date : $Date$
// author(s) : Sylvain Pion
// coordinator : MPI, Saarbruecken
//
// ======================================================================
#ifndef CGAL_SIMPLE_HANDLE_FOR_H
#define CGAL_SIMPLE_HANDLE_FOR_H
CGAL_BEGIN_NAMESPACE
template < class Stored >
class Simple_Handle_for
{
public:
typedef Stored element_type;
Simple_Handle_for()
{}
Simple_Handle_for(const Stored& rc)
: _s(rc) {}
Simple_Handle_for&
operator=(const Stored& rc)
{
_s = rc;
return *this;
}
void
initialize_with(const Stored& rc)
{
_s = rc;
}
long int
id() const
{ return reinterpret_cast<long int>(&_s); }
bool
identical(const Simple_Handle_for& h) const
{ return id() == h.id(); } // Or should it always return false ?
const Stored * Ptr() const
{ return &_s; }
Stored * Ptr()
{ return &_s; }
const Stored * ptr() const
{ return &_s; }
Stored * ptr()
{ return &_s; }
bool
is_shared() const
{
return false;
}
void
swap(Simple_Handle_for &h)
{
using std::swap;
swap(_s, h._s);
}
private:
Stored _s;
};
template < class Stored >
inline
void
swap(Simple_Handle_for<Stored> &h1, Simple_Handle_for<Stored> &h2)
{
h1.swap(h2);
}
CGAL_END_NAMESPACE
#endif // CGAL_SIMPLE_HANDLE_FOR_H