This file is indexed.

/usr/include/ns3.27/ns3/simple-ref-count.h is in libns3-dev 3.27+dfsg-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
 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
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2007 Georgia Tech Research Corporation, INRIA
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Authors: George Riley <riley@ece.gatech.edu>
 *          Gustavo Carneiro <gjcarneiro@gmail.com>,
 *          Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
 */
#ifndef SIMPLE_REF_COUNT_H
#define SIMPLE_REF_COUNT_H

#include "empty.h"
#include "default-deleter.h"
#include "assert.h"
#include <stdint.h>
#include <limits>

/**
 * \file
 * \ingroup ptr
 * ns3::SimpleRefCount declaration and template implementation.
 */

namespace ns3 {

/**
 * \ingroup ptr
 * \brief A template-based reference counting class
 *
 * This template can be used to give reference-counting powers
 * to a class. This template does not require this class to
 * have a virtual destructor or a specific (or any) parent class.
 * 
 * \note If you are moving to this template from the RefCountBase class,
 * you need to be careful to mark appropriately your destructor virtual
 * if needed. i.e., if your class has subclasses, _do_ mark your destructor
 * virtual.
 *
 *
 * This template takes 3 arguments but only the first argument is
 * mandatory:
 *
 * \tparam T \explicit The typename of the subclass which derives
 *      from this template class. Yes, this is weird but it's a
 *      common C++ template pattern whose name is CRTP (Curiously
 *      Recursive Template Pattern)
 * \tparam PARENT \explicit The typename of the parent of this template.
 *      By default, this typename is "'ns3::empty'" which is an empty
 *      class: compilers which implement the RBCO optimization (empty
 *      base class optimization) will make this a no-op
 * \tparam DELETER \explicit The typename of a class which implements
 *      a public static method named 'Delete'. This method will be called
 *      whenever the SimpleRefCount template detects that no references
 *      to the object it manages exist anymore.
 *
 * Interesting users of this class include ns3::Object as well as ns3::Packet.
 */
template <typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T> >
class SimpleRefCount : public PARENT
{
public:
  /** Default constructor.  */
  SimpleRefCount ()
    : m_count (1)
  {}
  /**
   * Copy constructor
   * \param [in] o The object to copy into this one.
   */
  SimpleRefCount (const SimpleRefCount &o)
    : m_count (1)
  {}
  /**
   * Assignment operator
   * \param [in] o The object to copy
   * \returns The copy of \p o
   */
  SimpleRefCount &operator = (const SimpleRefCount &o)
  {
    return *this;
  }
  /**
   * Increment the reference count. This method should not be called
   * by user code. SimpleRefCount instances are expected to be used in
   * conjunction with the Ptr template which would make calling Ref
   * unnecessary and dangerous.
   */
  inline void Ref (void) const
  {
    NS_ASSERT (m_count < std::numeric_limits<uint32_t>::max());
    m_count++;
  }
  /**
   * Decrement the reference count. This method should not be called
   * by user code. SimpleRefCount instances are expected to be used in 
   * conjunction with the Ptr template which would make calling Ref
   * unnecessary and dangerous.
   */
  inline void Unref (void) const
  {
    m_count--;
    if (m_count == 0)
      {
        DELETER::Delete (static_cast<T*> (const_cast<SimpleRefCount *> (this)));
      }
  }

  /**
   * Get the reference count of the object.
   * Normally not needed; for language bindings.
   *
   * \return The reference count.
   */
  inline uint32_t GetReferenceCount (void) const
  {
    return m_count;
  }

private:
  /**
   * The reference count.
   *
   * \internal
   * Note we make this mutable so that the const methods can still
   * change it.
   */
  mutable uint32_t m_count;
};

} // namespace ns3

#endif /* SIMPLE_REF_COUNT_H */