This file is indexed.

/usr/include/tjutils/tjstatic.h is in libodin-dev 1.8.4-1ubuntu2.

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
/***************************************************************************
                          tjstatic.h  -  description
                             -------------------
    begin                : Sun Jul 7 2002
    copyright            : (C) 2001 by Thies H. Jochimsen
    email                : jochimse@cns.mpg.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 TJSTATIC_H
#define TJSTATIC_H


#include <tjutils/tjutils.h>
#include <tjutils/tjthread.h>

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


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

class Static {

 public:

  Static() {}
  virtual ~Static() {}

  // destroy all static objects manually
  static void destroy_all();

  static void append_to_destructor_list(Static* sp);

 protected:

  static STD_list<Static*>* destructor_list;
};

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


template<class T>
struct StaticAlloc : public virtual Static {

  StaticAlloc() {
  }

  ~StaticAlloc() {
    T::destroy_static();
  }
};


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

/**
  * This template class handles static members of all  classes that
  * must be initialised exactly once. The rationale behind this
  * is that some of the classes posses static members on which
  * a certain action has to be performed EXACTLY once BEFORE
  * anything else happens with that class. The 'StaticHandler' serves as
  * as a base class for classes that require this feature.
  * It makes this easier by keeping track of how often the static
  * members have been initialised so that this is done only once.
  * The following steps must be performed to make use of the
  * StaticHandler:
  *
  * -# Deriving the class C from the template class StaticHandler
  *    by adding 'public StaticHandler<C>' to the list of base
  *    classes
  * -# Adding the static member function
  *     'static void init_static();'
  *    to the public section of the class. This function should
  *    contain the actions that will be performed only once for
  *    the static members.
  * -# Adding the static member function
  *     'static void destroy_static();'
  *    to the public section of the class. This function should
  *    contain the actions to deallocate memory allocated by init_static()
  * -# Adding the line 'bool StaticHandler<C>::staticdone=false;'
  *    to the source code of the class C
  */
template<class T>
class StaticHandler {

 public:
  StaticHandler() {
    if(!staticdone) { // fast check
      staticdone=true; // must be assigned before call to T::init_static() to avoid infinite loops
      Static* sp=new StaticAlloc<T>;
      Static::append_to_destructor_list(sp);
      T::init_static();
    }
  }


 private:
  static bool staticdone;

};

/** @}
  */
#endif