Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Handle.h
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 1999 The CGAL Consortium
4 
5 // This software and related documentation is part of the Computational
6 // Geometry Algorithms Library (CGAL).
7 // This software and documentation is provided "as-is" and without warranty
8 // of any kind. In no event shall the CGAL Consortium be liable for any
9 // damage of any kind.
10 //
11 // Every use of CGAL requires a license.
12 //
13 // Academic research and teaching license
14 // - For academic research and teaching purposes, permission to use and copy
15 // the software and its documentation is hereby granted free of charge,
16 // provided that it is not a component of a commercial product, and this
17 // notice appears in all copies of the software and related documentation.
18 //
19 // Commercial licenses
20 // - A commercial license is available through Algorithmic Solutions, who also
21 // markets LEDA (http://www.algorithmic-solutions.de).
22 // - Commercial users may apply for an evaluation license by writing to
23 // Algorithmic Solutions (contact@algorithmic-solutions.com).
24 //
25 // The CGAL Consortium consists of Utrecht University (The Netherlands),
26 // ETH Zurich (Switzerland), Free University of Berlin (Germany),
27 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
28 // (Germany), Max-Planck-Institute Saarbrucken (Germany), RISC Linz (Austria),
29 // and Tel-Aviv University (Israel).
30 //
31 // ----------------------------------------------------------------------
32 //
33 // release : CGAL-2.2
34 // release_date : 2000, September 30
35 //
36 // source : Handle.fw
37 // file : include/CGAL/Handle.h
38 // package : Kernel_basic (3.14)
39 // revision : 3.14
40 // revision_date : 15 Sep 2000
41 // author(s) :
42 //
43 //
44 // coordinator : MPI, Saarbruecken (<Stefan.Schirra>)
45 // email : contact@cgal.org
46 // www : http://www.cgal.org
47 //
48 // ======================================================================
49 
50 
51 #ifndef CGAL_HANDLE_H
52 #define CGAL_HANDLE_H
53 #include <CGAL/Handle_for.h>
54 
56 
58 {
59  friend class Leda_like_handle;
60  protected:
61  Leda_like_rep() { count = 1; }
62  virtual ~Leda_like_rep() {}
63 
64  int count;
65 };
66 
68 {
69  public:
71  { PTR = (Leda_like_rep*)NULL; }
72  // { PTR = (Leda_like_rep*)0xefefefef; }
73 
75  {
77  PTR = x.PTR;
78  PTR->count++;
79  }
80 
81 
83  { if ( PTR && (--PTR->count == 0)) { delete PTR; } }
84 
87  {
89  x.PTR->count++;
90  if ( PTR && (--PTR->count == 0)) { delete PTR; }
91  PTR = x.PTR;
92  return *this;
93  }
94 
95 
96  int
97  refs() const { return PTR->count; }
98 
99  friend unsigned long id(const Leda_like_handle& x);
100 
101  protected:
103 };
104 
105 inline
106 unsigned long
108 { return (unsigned long)x.PTR; }
109 
110 template < class T >
111 inline
112 bool
113 identical(const T &t1, const T &t2)
114 { return id(t1) == id(t2); }
116 
117 
118 #if defined(CGAL_USE_LEDA) && !defined(CGAL_NO_LEDA_HANDLE)
119 # include <LEDA/basic.h>
120 
122 
123 typedef handle_base Handle;
124 typedef handle_rep Rep;
125 
126 inline
127 unsigned long
128 id(const Handle& x)
129 { return ID_Number(x); }
131 
132 
133 # else
134 
136 
140 
141 
142 #endif // defined(CGAL_USE_LEDA) && !defined(CGAL_NO_LEDA_HANDLE)
143 #endif // CGAL_HANDLE_H
int count
Definition: Handle.h:64
int refs() const
Definition: Handle.h:97
bool identical(const T &t1, const T &t2)
Definition: Handle.h:113
CGAL_END_NAMESPACE CGAL_BEGIN_NAMESPACE typedef Leda_like_handle Handle
Definition: Handle.h:137
Leda_like_handle & operator=(const Leda_like_handle &x)
Definition: Handle.h:86
friend unsigned long id(const Leda_like_handle &x)
Definition: Handle.h:107
Leda_like_handle(const Leda_like_handle &x)
Definition: Handle.h:74
void int int REAL * x
Definition: read.cpp:74
Leda_like_rep * PTR
Definition: Handle.h:102
virtual ~Leda_like_rep()
Definition: Handle.h:62
unsigned long id(const Leda_like_handle &x)
Definition: Handle.h:107
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
Leda_like_handle()
Definition: Handle.h:70
Leda_like_rep()
Definition: Handle.h:61
~Leda_like_handle()
Definition: Handle.h:82
Leda_like_rep Rep
Definition: Handle.h:138
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
#define CGAL_kernel_precondition(EX)