This file is indexed.

/usr/include/tjutils/tjhandler.h is in libodin-dev 1.8.8-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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/***************************************************************************
                          tjhandler.h  -  description
                             -------------------
    begin                : Mon Aug 19 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 TJHANDLER_H
#define TJHANDLER_H

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

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


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


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

template<class I> class Handled; // forawrd declaration



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

template<class I>
class Handler {


 public:

  Handler();

  Handler(const Handler& handler);

  Handler& operator = (const Handler& handler);

  ~Handler();

  const Handler& clear_handledobj() const;

  const Handler& set_handled(I handled) const;

  I get_handled() const;


 private:
  friend class Handled<I>;

  const Handler& handled_remove(Handled<I>* handled) const;

  mutable I handledobj;

};


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


template<class I>
class Handled {

 public:
  Handled();
  ~Handled();

  bool is_handled() const {return bool(handlers.size());}
  
 private:
  friend class Handler<I>;
  
  const Handled& set_handler(const Handler<I>& handler) const;
  const Handled& erase_handler(const Handler<I>& handler) const;

  mutable STD_list< const Handler<I>* > handlers;
};


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

class SingletonBase; // forward declaration

// mapping between singletons and labels
typedef STD_map<STD_string, SingletonBase*> SingletonMap;


class SingletonBase {

 public:
  virtual void* get_ptr() const = 0;

  static SingletonMap* get_singleton_map();
  static void set_singleton_map_external(SingletonMap* extmap);

 protected:
  SingletonBase();
  virtual ~SingletonBase() {}

  static STD_string get_singleton_label(SingletonBase* sing_ptr);
  static void* get_external_map_ptr(const STD_string& sing_label);

  static SingletonMap* singleton_map;
  static SingletonMap* singleton_map_external;
};


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


/**
  * Helper class to enable locking of resources while accessing them with pointer-like syntax.
  */
template<class T>
class LockProxy {

 public:
  LockProxy(volatile T* r, Mutex* m) : presource(const_cast<T*>(r)), pmutex(m) {if(pmutex) pmutex->lock();}
  ~LockProxy() {if(pmutex) pmutex->unlock();}
  T* operator -> () {return presource;}

 private:
  T* presource;
  Mutex* pmutex;
};


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



/**
  * Template class to manage singleton objects of type T,
  * i.e. those objects which are exist only once in the
  * program. The instantiation must be a static field of
  * of a certain class. The init/destroy member functions
  * are used to create/destroy the singleton.
  * If 'thread_safe' is set to 'true', use a mutex to manage multi-threaded
  * access to the singleton object.
  *
  * Its main purpose is to
  * share singletons across DLL boundaries on Windows
  * and/or thread-safe access to global resources.
  * This class has an pointer-to-T-like interface.
  */
template<class T, bool thread_safe> // VxWorks does not support default-template args
class SingletonHandler : public SingletonBase {

 public:

  SingletonHandler() {
    // do nothing because members are already initialized by init()
  }


/**
  * Initialize the singleton with the unique identifier 'unique_label'.
  * The singleton object will be allocated if it does not already exist
  * somewhere in the program.
  */
  void init (const char* unique_label);

/**
  * Deletes the singleton
  */
  void destroy ();


/**
  * Copies this to 'destination'
  */
  void copy(T& destination) const;

/**
  * Returns unlocked ptr to object (know what you are doing)
  */
  T* unlocked_ptr() {return get_map_ptr();}


  // emulate pointer syntax:

/**
  * Returns mutex-locked pointer to handled singleton
  */
  LockProxy<T> operator -> () {return LockProxy<T>(get_map_ptr(),mutex);}

/**
  * Returns read-only pointer to handled singleton
  */
  const T* operator -> () const {return get_map_ptr();}

/**
  * Returns whether singleton is already initialized
  */
  operator bool () const {return (bool)get_map_ptr();}



 private:

  // implement virtual function of SingletonBase
  void* get_ptr() const {return ptr;}

  T* get_map_ptr() const;

  // Use pointers to avoid the need for static initialization
  mutable T* ptr;
  STD_string* singleton_label;
  Mutex* mutex;

};



/** @}
  */
#endif