/usr/include/Cable/cableSmartPointer.h is in libcableswig-dev 0.1.0+cvs20111009-1.1.
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 | /*=========================================================================
Program: CABLE - CABLE Automates Bindings for Language Extension
Module: $RCSfile: cableSmartPointer.h,v $
Language: C++
Date: $Date: 2004-02-19 20:13:32 $
Version: $Revision: 1.4 $
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _cableSmartPointer_h
#define _cableSmartPointer_h
#include "cableUtils.h"
namespace cable
{
/** SmartPointer allows automatic reference counting. */
template <class T>
class SmartPointer
{
public:
SmartPointer(): m_Pointer(0) {}
SmartPointer(const SmartPointer& p): m_Pointer(p.m_Pointer)
{ this->Register(); }
SmartPointer(T* p): m_Pointer(p) { this->Register(); }
~SmartPointer() { this->Unregister(); }
/** Allow equality comparison with another pointer. */
bool operator == (SmartPointer r) const { return (m_Pointer==r.m_Pointer); }
/** Allow equality comparison with another pointer. */
bool operator == (T* r) const { return (m_Pointer==r); }
/** Allow inequality comparison with another pointer. */
bool operator != (SmartPointer r) const { return (m_Pointer!=r.m_Pointer); }
/** Allow inequality comparison with another pointer. */
bool operator != (T* r) const { return (m_Pointer!=r); }
/** Allow assignment. */
SmartPointer& operator = (const SmartPointer& r)
{ SmartPointer<T>(r).Swap(*this); return *this; }
/** Allow assignment. */
SmartPointer& operator = (T* r)
{ SmartPointer<T>(r).Swap(*this); return *this; }
/** Allow access to members of T as if this were a normal pointer. */
T* operator -> () const { return m_Pointer; }
/** Let smart pointer look like normal pointer to T. */
operator T* () const { return m_Pointer; }
/** Allow read access to real pointer to make casting easier. */
T* RealPointer() const { return m_Pointer; }
private:
/** Increment reference count of object. */
void Register() { if(m_Pointer) { m_Pointer->Register(); } }
/** Decrement reference count of object. */
void Unregister() { if(m_Pointer) { m_Pointer->Unregister(); } }
void Swap(SmartPointer& r)
{ T* temp = m_Pointer; m_Pointer = r.m_Pointer; r.m_Pointer = temp; }
T* m_Pointer;
};
} // namespace cable
#endif
|