/usr/include/openturns/Pointer.hxx is in libopenturns-dev 1.5-7build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | // -*- C++ -*-
/**
* @file Pointer.hxx
* @brief The class Pointer implements a shared pointer strategy
*
* Copyright 2005-2015 Airbus-EDF-IMACS-Phimeca
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* @author schueller
* @date 2012-04-18 17:56:46 +0200 (Wed, 18 Apr 2012)
*/
#ifndef OPENTURNS_POINTER_HXX
#define OPENTURNS_POINTER_HXX
#include "OTprivate.hxx"
#include "SharedPointer.hxx"
BEGIN_NAMESPACE_OPENTURNS
/**
* @class Pointer
* @brief Implements a shared pointer strategy
* @see SharedPointer
* @see InterfaceObject
* @tparam T The class to point to
* @tparam IMPL The class used to actually implement the shared pointer
*
* Pointer implements a shared pointer strategy. The pointee
* object is shared among all pointers so none has pointee
* ownership. When one of them wants to modify the object, it
* MUST deep-copy it (copy-on-write strategy).
*/
#ifdef SWIG
template <class T>
#else
template < class T,
template <class> class IMPL = SharedPointer >
#endif
class Pointer
{
#ifdef SWIG
template <class Y> friend class Pointer;
#else
template <class Y, template <class> class I> friend class Pointer;
#endif
public:
/**
* Pointer_type gives access to the shared pointer
* implementation type
*/
#ifdef SWIG
typedef SharedPointer<T> pointer_type;
#else
typedef IMPL<T> pointer_type;
#endif
/**
* The actual shared pointer is \em ptr_
*/
pointer_type ptr_;
typedef T ElementType;
typedef T ValueType;
/**
* Default constructor.
*
* Constructed like this, the underlying pointer is NULL
*/
Pointer() : ptr_()
{
}
/**
* Constructor from T * type
*
* The object pointed t is from now owned and taken in charge
* by the shared pointer. It MUST NOT be manually deleted
*/
Pointer(T * ptr) : ptr_(ptr)
{
}
/**
* Destructor does nothing
*/
~Pointer()
{
}
/**
* Copy constructor adds one more reference
* on the underying object so its reference counter is
* incremented by one
*/
template <class Derived>
Pointer(const Pointer<Derived> & ref) : ptr_(ref.ptr_)
{
}
#ifndef SWIG
/**
* Equality operator adds one more reference
* on the underying object so its reference counter is
* incremented by one
*/
template <class Derived>
Pointer & operator = (const Pointer<Derived> & ref)
{
ptr_ = ref.ptr_;
return *this;
}
#endif
/**
* Method to cast objects passed as base class into
* derived class
*/
template <class Base>
Pointer & assign(const Pointer<Base> & ref)
{
ptr_.assign(ref.ptr_);
return *this;
}
/**
* Reset forsakes its reference on the pointed-to object.
* If the shared pointer is the only owner of the object,
* reset leads to its deletion
*/
inline void reset()
{
ptr_.reset();
}
/**
* Reset forsakes its reference on the pointed-to object.
* If the shared pointer is the only owner of the object,
* reset leads to its deletion. This method takes the new
* pointed-to object and takes it in charge inside the
* shared pointer
*/
template <class Y>
inline void reset(Y * p)
{
ptr_.reset(p);
}
/**
* Operator * dereferences the const shared pointer and gives
* access to the underlying object
*/
inline const T & operator * () const
{
return *ptr_;
}
#ifndef SWIG
/**
* Operator -> dereferences the const shared pointer and gives
* access to the underlying object
*/
inline const T * operator -> () const
{
return ptr_.get();
}
#endif
/**
* Operator * dereferences the shared pointer and gives
* access to the underlying object
*/
inline T & operator * ()
{
return *ptr_;
}
/**
* Operator -> dereferences the shared pointer and gives
* access to the underlying object
*/
inline T * operator -> ()
{
return ptr_.get();
}
/**
* Method isNull returns true if there is no underlying
* object pointed to
*/
inline Bool isNull() const
{
return ptr_.get() == 0;
}
/**
* Operator bool() allows null pointer checking is assertions or tests
*/
inline operator bool() const
{
return ptr_.get() != 0;
}
/**
* Method get gives access to the underlying object
* pointed to
*/
inline T * get() const
{
return ptr_.get();
}
/**
* Method getImplementation() gives access to the
* underlying implementation object (for copy
* constructor needs)
*/
inline const pointer_type & getImplementation() const
{
return ptr_;
}
/**
* Unique returns true when the shared pointer is the only
* one that takes in charge the pointed-to object
* It is semantically equivalent to use_count() == 1
*/
inline Bool unique() const
{
return ptr_.unique();
}
/**
* Use_count returns the number of shared pointers that
* share the pointed-to object
*/
inline UnsignedInteger use_count() const
{
return ptr_.use_count();
}
/**
* Swap exchanges the pointed-to objects between two
* shared pointers
*/
inline void swap(Pointer<T> & other)
{
ptr_.swap(other.ptr_);
}
}; /* class Pointer */
END_NAMESPACE_OPENTURNS
#endif /* OPENTURNS_POINTER_HXX */
|