This file is indexed.

/usr/include/tjutils/tjindex.h is in libodin-dev 1.8.8-2ubuntu1.

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
/***************************************************************************
                          tjindex.h  -  description
                             -------------------
    begin                : Tue Aug 13 2002
    copyright            : (C) 2000-2014 by Thies H. Jochimsen
    email                : thies@jochimsen.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef TJINDEX_H
#define TJINDEX_H

#include <tjutils/tjutils.h>
#include <tjutils/tjstatic.h>
#include <tjutils/tjlabel.h>
#include <tjutils/tjhandler.h>



/**
  * @addtogroup tjutils
  * @{
  */


class Index {
 public:
  static const char* get_compName();
};


//////////////////////////////////////////////////////////

// mapping between UniquIndex types and typenames
struct UniqueIndexMap : public STD_map<STD_string, STD_list<unsigned int> >, public Labeled {

  UniqueIndexMap() : contiguous(true) {}

  unsigned int get_index(STD_list<unsigned int>::iterator& index, const STD_string& type, unsigned int max_instances);

  void remove_index(const STD_list<unsigned int>::iterator& index, const STD_string& type);


 private:
  bool contiguous; // cache whether list of indices is contiguous for fast assignment of indices
  unsigned int assign_index(STD_list<unsigned int>::iterator& index, const STD_string& type); // Get the next lowest index which is available
};


//////////////////////////////////////////////////////////

// keeps track of all index lists
class UniqueIndexBase : public StaticHandler<UniqueIndexBase> {

 public:

  // for StaticHandler
  static void init_static()    {indices_map.init("indices_map");}
  static void destroy_static() {indices_map.destroy();}

 protected:

  UniqueIndexBase() {} // Use only as base class

  static SingletonHandler<UniqueIndexMap,true> indices_map; // global lists of indices

};


//////////////////////////////////////////////////////////


/**
  * This template class provides a unique index, i.e. an unique
  * unsigned integer number for all instances of the (derived) class.
  * A new index for the object is created whenever a call to 'get_index()'
  * is issued the first time. The assigned index is removed from the list
  * of assigned indices if the object is destroyed.
  * Please note that the index of temporary objects is deleted from
  * the list of indices, even it is assigned to another object.
  * The class T must have two static member functions, 'get_typename()'
  * and 'get_max_instances()' to return a unique label and the
  * maximum number of instances per class, respectively.
  */
template<class T>
class UniqueIndex : public UniqueIndexBase {

 public:
  UniqueIndex() {init();}

  UniqueIndex(const UniqueIndex<T>&) {init();}

  UniqueIndex<T>& operator = (const UniqueIndex<T>&) {erase(); init(); return *this;}

  ~UniqueIndex() {erase();}


/**
  * Returns a unique index for this object.
  */
  unsigned int get_index() const {
    return indices_map->get_index(index, T::get_typename(), T::get_max_instances());
  }


 private:
  void init() { // Start with unassigned index (pointing to end())
    index=indices_map->operator[](T::get_typename()).end();
  }

  void erase() { // Remove index
    indices_map->remove_index(index, T::get_typename());
  }


  mutable STD_list<unsigned int>::iterator index;


};

/** @}
  */
#endif