This file is indexed.

/usr/include/polybori/common/CExtrusivePtr.h is in libbrial-dev 1.2.0-2.

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
// -*- c++ -*-
//*****************************************************************************
/** @file CExtrusivePtr.h
 *
 * @author Alexander Dreyer
 * @date 2010-08-24
 *
 * This is essentially a reimplementation of the interface from
 * boost:intrusive_ptr, but with an additional field for storing data, which
 * might be used .
 *
 * @par Copyright:
 *   (c) 2010 by The PolyBoRi Team
 *
**/
//*****************************************************************************

#ifndef polybori_common_CExtrusivePtr_h_
#define polybori_common_CExtrusivePtr_h_

// include basic definitions
#include <polybori/pbori_defs.h>
#include <algorithm>            // std::swap

BEGIN_NAMESPACE_PBORI

/** @class CExtrusivePtr
 * @brief This template class defines a reimplementation of the interface from
 * boost:intrusive_ptr, but with an additional data field.
 *
 * The data field can be used as a helper for the incrementing and decrementing
 * reference counts. Very much like in boost::intrusive_ptr, the following
 * functions have to be defined:
 * 
 * @code
 void extrusive_ptr_release(const DataType&, ValueType*);
 void extrusive_ptr_add_ref(const DataType&, ValueType*)
 * @endcode
 * If @c DataType is ignored, this is essentially
 * @c boost::intrusive_ptr, while something like DataType = int* could be used
 * to implement something like @c boost::shared_ptr.
 **/
template <class DataType, class ValueType>
class CExtrusivePtr {

  /// Name type of *this
  typedef CExtrusivePtr self;

public:

  /// Type for additional data storange
  typedef DataType data_type;

  /// Value type
  typedef ValueType value_type;

  /// Construct managed pointer with additional data
  CExtrusivePtr(const data_type& data, value_type* ptr): 
    m_data(data), p_ptr(ptr) { lock(); }

  /// Copy constructor
  CExtrusivePtr(const self& rhs): 
    m_data(rhs.m_data), p_ptr(rhs.p_ptr) { lock(); } 

  CExtrusivePtr(): 
    m_data(), p_ptr(NULL) { } 

  /// Destructor
  ~CExtrusivePtr() { release(); }

  /// Assignment
  self& operator=(const self& rhs) {
    self(rhs).swap(*this);
    return *this;
  }

  /// Accessing helpter data
  const data_type& data() const { return m_data; }

  /// Get actual pointer
  value_type* get() const {
    return p_ptr;
  }

  /// Constant dereferencing
  const value_type & operator*() const {
    PBORI_ASSERT(p_ptr != NULL);
    return *p_ptr;
  }

  /// Nonconstant dereference
  value_type & operator*() {
    PBORI_ASSERT(p_ptr != NULL);
    return *p_ptr;
  }
  
  /// Pointer operator
  value_type* operator->() const {
    PBORI_ASSERT(p_ptr != NULL);
    return p_ptr;
  }

  /// Swap
  void swap(self & rhs) {
    std::swap(m_data, rhs.m_data);
    std::swap(p_ptr, rhs.p_ptr);
  }

protected:
  void lock() {
    extrusive_ptr_add_ref(data(), get());
  }
  void release() {
    extrusive_ptr_release(data(), get());
  }

  /// Store helper data
  data_type m_data;

  /// Store actual pointer
  value_type* p_ptr;
};

/// Equality check
template <class Data1, class Type1, class Data2, class Type2> 
inline bool
operator==(const CExtrusivePtr<Data1, Type1> & lhs, 
           const CExtrusivePtr<Data2, Type2> & rhs) {
  return lhs.get() == rhs.get();
}

/// Nonequality check
template <class Data1, class Type1, class Data2, class Type2>
inline bool
operator!=(const CExtrusivePtr<Data1, Type1> & lhs,
           const CExtrusivePtr<Data2, Type2> & rhs) {
  return lhs.get() != rhs.get();
}

/// Equality check wrt. pointer
template <class Data1, class Type1, class Type2>
inline bool
operator==(const CExtrusivePtr<Data1, Type1> & lhs, Type2 * rhs) {
  return lhs.get() == rhs;
}

/// Nonequality check wrt. pointer
template <class Data1, class Type1, class Type2>
inline bool 
operator!=(const CExtrusivePtr<Data1, Type1> & lhs, Type2* rhs) {
  return lhs.get() != rhs;
}

/// Equality check from a pointer
template <class Type1, class Data2, class Type2>
inline bool
operator==(Type1* lhs, const CExtrusivePtr<Data2, Type2> & rhs) {
  return lhs == rhs.get();
}

/// Nonequality check from a pointer
template <class Type1, class Data2, class Type2>
inline bool
operator!=(Type1* lhs, const CExtrusivePtr<Data2, Type2> & rhs) {
  return lhs != rhs.get();
}

END_NAMESPACE_PBORI

#endif