This file is indexed.

/usr/include/simgear/structure/OSGUtils.hxx is in libsimgear-dev 3.0.0-6+b2.

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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
// OSGUtils.hxx - Useful templates for interfacing to Open Scene Graph
//
// Copyright (C) 2008  Tim Moore timoore@redhat.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA  02110-1301, USA.

#ifndef SIMGEAR_OSGUTILS_HXX
#define SIMGEAR_OSGUTILS_HXX 1

#include <osg/CopyOp>
#include <osg/StateAttribute>
#include <osg/StateSet>

namespace simgear
{
// RefPtrAdapter also appears in OpenSceneGraph's
// osgDB/DatabasePager.cpp. I wrote that code too. -- Tim Moore

// Convert function objects that take pointer args into functions that a
// reference to an osg::ref_ptr. This is quite useful for doing STL
// operations on lists of ref_ptr. This code assumes that a function
// with an argument const Foo* should be composed into a function of
// argument type ref_ptr<Foo>&, not ref_ptr<const Foo>&. Some support
// for that should be added to make this more general.
template <typename U>
struct PointerTraits
{
    typedef class NullType {} PointeeType;
};

template <typename U>
struct PointerTraits<U*>
{
    typedef U PointeeType;
};

template <typename U>
struct PointerTraits<const U*>
{
    typedef U PointeeType;
};

template <typename FuncObj>
class RefPtrAdapter
    : public std::unary_function<const osg::ref_ptr<typename PointerTraits<typename FuncObj::argument_type>::PointeeType>,
                                 typename FuncObj::result_type>
{
public:
    typedef typename PointerTraits<typename FuncObj::argument_type>::PointeeType PointeeType;
    typedef osg::ref_ptr<PointeeType> RefPtrType;
    explicit RefPtrAdapter(const FuncObj& funcObj) : _func(funcObj) {}
    typename FuncObj::result_type operator()(const RefPtrType& refPtr) const
    {
        return _func(refPtr.get());
    }
protected:
        FuncObj _func;
};

template <typename FuncObj>
RefPtrAdapter<FuncObj> refPtrAdapt(const FuncObj& func)
{
    return RefPtrAdapter<FuncObj>(func);
}
}
/** Typesafe wrapper around OSG's object clone function. Something
 * very similar is in current OSG sources.
 */
namespace osg
{
template <typename T> class ref_ptr;
class CopyOp;
}

namespace simgear
{
template <typename T>
T* clone(const T* object, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
{
    return static_cast<T*>(object->clone(copyop));
}

template<typename T>
T* clone_ref(const osg::ref_ptr<T>& object,
             const osg::CopyOp& copyop  = osg::CopyOp::SHALLOW_COPY)
{
    return static_cast<T*>(object->clone(copyop));
}

}

namespace osg
{
class AlphaFunc;
class BlendColor;
class BlendEquation;
class BlendFunc;
class ClampColor;
class ColorMask;
class ColorMatrix;
class CullFace;
class Depth;
class Fog;
class FragmentProgram;
class FrontFace;
class LightModel;
class LineStipple;
class LineWidth;
class LogicOp;
class Material;
class Multisample;
class Point;
class PointSprite;
class PolygonMode;
class PolygonOffset;
class PolygonStipple;
class Program;
class Scissor;
class ShadeModel;
class Stencil;
class StencilTwoSided;
class TexEnv;
class TexEnvCombine;
class TexEnvFilter;
class TexGen;
class TexMat;
class Texture1D;
class Texture2D;
class Texture2DArray;
class Texture3D;
class TextureCubeMap;
class TextureRectangle;
class VertexProgram;
class Viewport;
}

namespace simgear
{
namespace osgutils
{
using namespace osg;

template<StateAttribute::Type T>
struct TypeHolder
{
    static const StateAttribute::Type type = T;
};

template<typename AT> struct AttributeType;
template<typename AT> struct TexAttributeType;

template<>
struct AttributeType<AlphaFunc>
    : public TypeHolder<StateAttribute::ALPHAFUNC>
{};

template<>
struct AttributeType<BlendColor>
    : public TypeHolder<StateAttribute::BLENDCOLOR>
{};

template<>
struct AttributeType<BlendEquation>
    : public TypeHolder<StateAttribute::BLENDEQUATION>
{};

template<>
struct AttributeType<BlendFunc>
    : public TypeHolder<StateAttribute::BLENDFUNC>
{};

template<>
struct AttributeType<ClampColor>
    : public TypeHolder<StateAttribute::CLAMPCOLOR>
{};

template<>
struct AttributeType<ColorMask>
    : public TypeHolder<StateAttribute::COLORMASK>
{};

template<>
struct AttributeType<ColorMatrix>
    : public TypeHolder<StateAttribute::COLORMATRIX>
{};

template<>
struct AttributeType<CullFace>
    : public TypeHolder<StateAttribute::CULLFACE>
{};


template<>
struct AttributeType<osg::Depth> // Conflicts with Xlib
    : public TypeHolder<StateAttribute::DEPTH>
{};

template<>
struct AttributeType<Fog>
    : public TypeHolder<StateAttribute::FOG>
{};

template<>
struct AttributeType<FragmentProgram>
    : public TypeHolder<StateAttribute::FRAGMENTPROGRAM>
{};

template<>
struct AttributeType<FrontFace>
    : public TypeHolder<StateAttribute::FRONTFACE>
{};

template<>
struct AttributeType<LightModel>
    : public TypeHolder<StateAttribute::LIGHTMODEL>
{};

template<>
struct AttributeType<LineStipple>
    : public TypeHolder<StateAttribute::LINESTIPPLE>
{};

template<>
struct AttributeType<LineWidth>
    : public TypeHolder<StateAttribute::LINEWIDTH>
{};

template<>
struct AttributeType<LogicOp>
    : public TypeHolder<StateAttribute::LOGICOP>
{};

template<>
struct AttributeType<Material>
    : public TypeHolder<StateAttribute::MATERIAL>
{};

template<>
struct AttributeType<Multisample>
    : public TypeHolder<StateAttribute::MULTISAMPLE>
{};

template<>
struct AttributeType<Point>
    : public TypeHolder<StateAttribute::POINT>
{};

template<>
struct TexAttributeType<PointSprite>
    : public TypeHolder<StateAttribute::POINTSPRITE>
{};

template<>
struct AttributeType<PolygonMode>
    : public TypeHolder<StateAttribute::POLYGONMODE>
{};

template<>
struct AttributeType<PolygonOffset>
    : public TypeHolder<StateAttribute::POLYGONOFFSET>
{};

template<>
struct AttributeType<PolygonStipple>
    : public TypeHolder<StateAttribute::POLYGONSTIPPLE>
{};

template<>
struct AttributeType<Program>
    : public TypeHolder<StateAttribute::PROGRAM>
{};

template<>
struct AttributeType<Scissor>
    : public TypeHolder<StateAttribute::SCISSOR>
{};

template<>
struct AttributeType<ShadeModel>
    : public TypeHolder<StateAttribute::SHADEMODEL>
{};

template<>
struct AttributeType<Stencil>
    : public TypeHolder<StateAttribute::STENCIL>
{};

template<>
struct AttributeType<StencilTwoSided>
    : public TypeHolder<StateAttribute::STENCIL>
{};

// TexEnvCombine is not a subclass of TexEnv, so we can't do a
// typesafe access of the attribute.
#if 0
template<>
struct TexAttributeType<TexEnv>
    : public TypeHolder<StateAttribute::TEXENV>
{};

template<>
struct TexAttributeType<TexEnvCombine>
    : public TypeHolder<StateAttribute::TEXENV>
{};
#endif

template<>
struct TexAttributeType<TexEnvFilter>
    : public TypeHolder<StateAttribute::TEXENVFILTER>
{};

template<>
struct TexAttributeType<TexGen>
    : public TypeHolder<StateAttribute::TEXGEN>
{};

template<>
struct TexAttributeType<TexMat>
    : public TypeHolder<StateAttribute::TEXMAT>
{};

template<>
struct TexAttributeType<Texture>
    : public TypeHolder<StateAttribute::TEXTURE>
{};

template<>
struct AttributeType<VertexProgram>
    : public TypeHolder<StateAttribute::VERTEXPROGRAM>
{};

template<>
struct AttributeType<Viewport>
    : public TypeHolder<StateAttribute::VIEWPORT>
{};
} // namespace osgutils

template<typename AT>
inline AT* getStateAttribute(osg::StateSet* ss)
{
    return static_cast<AT*>(ss->getAttribute(osgutils::AttributeType<AT>::type));
}

template<typename AT>
inline const AT* getStateAttribute(const osg::StateSet* ss)
{
    return static_cast<const AT*>(ss->getAttribute(osgutils::AttributeType<AT>::type));
}

template<typename AT>
inline AT* getStateAttribute(unsigned int unit, osg::StateSet* ss)
{
    return static_cast<AT*>(ss->getTextureAttribute(unit, osgutils::TexAttributeType<AT>
                                                    ::type));
}

template<typename AT>
inline const AT* getStateAttribute(unsigned int unit, const osg::StateSet* ss)
{
    return static_cast<const AT*>(ss->getTextureAttribute(unit,
                                                          osgutils::TexAttributeType<AT>
                                                          ::type));
}
} // namespace simgear

#endif