This file is indexed.

/usr/include/ucommon/counter.h is in libucommon-dev 6.0.7-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
 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
// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
//
// This file is part of GNU uCommon C++.
//
// GNU uCommon C++ 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.
//
// GNU uCommon C++ 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 License
// along with GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Support for various automatic counting objects.
 * This header defines templates for various kinds of automatic counting
 * and sequencing objects.  Templates are used to allow manipulation of
 * various numerical-like types.
 * @file ucommon/counter.h
 */

#ifndef _UCOMMON_COUNTER_H_
#define _UCOMMON_COUNTER_H_

#ifndef _UCOMMON_CONFIG_H_
#include <ucommon/platform.h>
#endif

NAMESPACE_UCOMMON

/**
 * Automatic integer counting class.  This is an automatic counting object
 * that is used to retrieve a new integer value between 0 and n each time
 * the object is referenced.  When reaching the last n value, the object
 * restarts at 0, and so is used to retrieve a sequence of values in order.
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT counter
{
private:
    unsigned value, cycle;

public:
    /**
     * Initialize integer counter of unknown size.
     */
    counter();

    /**
     * Initialize integer counter for a range of values.
     * @param limit before recycling to zero.
     */
    counter(unsigned limit);

    /**
     * Get the next counter value.
     * @return next counter value.
     */
    unsigned get(void);

    /**
     * Get the range of values before recycling.
     * @return counter limit.
     */
    inline unsigned range(void)
        {return cycle;};

    /**
     * Reference next counter value through pointer operation.
     * @return next counter value.
     */
    inline unsigned operator*()
        {return get();};

    /**
     * Reference next counter value by casting to integer.
     * @return next counter value.
     */
    inline operator unsigned()
        {return get();};

    /**
     * Assign the value of the counter.
     * @param value to assign.
     */
    void operator=(unsigned value);
};

/**
 * Automatically return a sequence of untyped objects.  This is an automatic
 * counter based class which returns the next pointer in an array of pointers
 * and restarts the list when reaching the end.  This is used to support the
 * sequence template.
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT SeqCounter : protected counter
{
private:
    void *item;
    size_t offset;

protected:
    SeqCounter(void *start, size_t size, unsigned count);

    void *get(void);

    void *get(unsigned idx);

public:
    /**
     * Used to directly assign sequence position in template.
     * @param inc_offset in sequence to reset sequencing to.
     */
    inline void operator=(unsigned inc_offset)
        {counter::operator=(inc_offset);};
};

/**
 * Automatically toggle a bool on each reference.
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT toggle
{
private:
    bool value;

public:
    inline toggle()
        {value = false;};

    bool get(void);

    inline bool operator*()
        {return get();};

    inline void operator=(bool v)
        {value = v;};

    inline operator bool()
        {return get();};

};

/**
 * A template to return a sequence of objects of a specified type.
 * This is used to return a different member in a sequence of objects of
 * a specified type during each reference to the sequencer.
 * @author David Sugar <dyfet@gnutelephony.org>
 */
template <class T>
class sequence : public SeqCounter
{
protected:
    inline T *get(unsigned idx)
        {return static_cast<T *>(SeqCounter::get(idx));};

public:
    /**
     * Create a template auto-sequence from a list of typed pointers.
     * @param array of typed values to sequence on reference.
     * @param size of list of typed values.
     */
    inline sequence(T *array, unsigned size) :
        SeqCounter(array, sizeof(T), size) {};

    /**
     * Return next typed member of the sequence.
     * @return next typed member of sequence.
     */
    inline T* get(void)
        {return static_cast<T *>(SeqCounter::get());};

    /**
     * Return next typed member of the sequence by pointer reference.
     * @return next typed member of sequence.
     */
    inline T& operator*()
        {return *get();};

    /**
     * Return next typed member of the sequence by casted reference.
     * @return next typed member of sequence.
     */
    inline operator T&()
        {return *get();};

    /**
     * Return a specific typed member from the sequence list.
     * @param offset of member to return.
     * @return typed value at the specified offset.
     */
    inline T& operator[](unsigned offset)
        {return *get(offset);};
};

/**
 * A convenience typecast for integer counters.
 */
typedef counter counter_t;

/**
 * A convenience typecast for auto-toggled bools.
 */
typedef toggle toggle_t;

END_NAMESPACE

#endif