This file is indexed.

/usr/include/itpp/protocol/events.h is in libitpp-dev 4.3.1-6.

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
/*!
 * \file
 * \brief Definitions of an event-based simulation class
 * \author Anders Persson and Tony Ottosson
 *
 * -------------------------------------------------------------------------
 *
 * Copyright (C) 1995-2010  (see AUTHORS file for a list of contributors)
 *
 * This file is part of IT++ - a C++ library of mathematical, signal
 * processing, speech processing, and communications classes and functions.
 *
 * IT++ 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 3 of the License, or (at your option) any
 * later version.
 *
 * IT++ 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 General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along
 * with IT++.  If not, see <http://www.gnu.org/licenses/>.
 *
 * -------------------------------------------------------------------------
 */

#ifndef EVENTS_H
#define EVENTS_H

#include <itpp/base/itassert.h>

#if (defined(_MSC_VER) && defined(ITPP_SHARED_LIB) && !(defined(itpp_EXPORTS) || defined(itpp_debug_EXPORTS)))

#ifndef ITPP_PROTOCOL_EXCLUDED
#define ITPP_PROTOCOL_EXCLUDED
#pragma message( "PROTOCOL definitions are not available for MSVC shared builds" )
#endif

#else


#include <queue>
#include <deque>

namespace itpp
{

//! \addtogroup protocol
//@{

// typedef long double Ttype; //!< 128-bit floating point time
typedef double Ttype; //!< 64-bit floating point time
// typedef long unsigned int Ttype; //!< 64-bit unsigned integer time

class Event_Queue;
class Base_Event;
class Base_Signal;

/*!
  \brief Base Event Class

  An abstract Base class of Events that can be used to derive new events. All Event classes
  need to define the exec() function which is called when the event expires. An event has an
  execution time and an id.
*/
class Base_Event
{
public:
  friend class Base_Signal;

  friend class Event_Queue;

  friend struct Compare_Base_Event_Times;

  //! Schedule an event at time \c delta_time from now
  Base_Event(const Ttype delta_time) {  // The event will occur in 'delta_time' time units from now!
    it_assert(delta_time >= 0, "Only causal simulations are possible");
    active = true;
    delta_t = delta_time;
    expire_t = 0; // Will be set correctly upon calling Event_Queue::add().
    id = global_id++;
  }

  //! Destructor
  virtual ~Base_Event() {}

  //! Cancel an event
  void cancel() { active = false; }

protected:
  //! ADD DOCUMENTATION HERE
  virtual void exec(void) = 0;
  //! ADD DOCUMENTATION HERE
  Ttype delta_t;
  //! ADD DOCUMENTATION HERE
  Ttype expire_t;
  //! ADD DOCUMENTATION HERE
  bool active;
  //! ADD DOCUMENTATION HERE
  unsigned long long int id;
  //! ADD DOCUMENTATION HERE
  static unsigned long long int global_id;
};

//! Compare to events, Returns true if expire time of event1 is larger than the expire time of event2
struct Compare_Base_Event_Times {
  //! ADD DOCUMENTATION HERE
  bool operator()(Base_Event *event1, Base_Event *event2) {
    if (event1->expire_t == event2->expire_t) // Equal expire times.
      return (event1->id > event2->id); // Base comparison on the event id.
    else
      return (event1->expire_t > event2->expire_t); // Different expire times. Regular comparison.
  }
};

/*!
  \brief Event Queue class

  A class for storing and executing events. Events can be added to the queue and when the start() is
  called all events will be executed. Observe that Events need to be created before they are added to the
  queue by calling an appropriate constructor. However, expired events are destroyed automatically (the destructor is called).

*/
class Event_Queue
{
public:
  friend class Base_Signal;

  //! Constructor
  Event_Queue() {}
  //! Destructor
  ~Event_Queue() {}

  //! Add event to Queue
  static void add(Base_Event *e);
  //! Return current time
  static Ttype now() {return t;}
  //! Start executing events
  static void start();
  //! Stop execution of events
  static void stop();
  //! Remove all events
  static void clear();
protected:
  //static void cancel_all(Base_Signal *s);
private:
  typedef std::deque<Base_Event*, std::allocator< Base_Event* > >::iterator Base_Event_Iterator;
  static void _run();
  static bool keep_running;
  static Ttype t; // Current time.
  static std::priority_queue < Base_Event*,
  std::deque<Base_Event*, std::allocator<Base_Event*> >,
  Compare_Base_Event_Times > event_queue; // Queue for the Events.
};

/*!
  \brief An Event class that executes a function when the event expires.

  Since Events are objects you need supply both a pointer to the object and the function pointer to create the Event
*/
template <class ObjectType>
class Event : public Base_Event
{
public:
  //! Construct an Event to expire delta_time from now by calling the function (*object_pointer.*object_function_pointer)()
  Event(ObjectType *object_pointer, void (ObjectType::*object_function_pointer)(), const Ttype delta_time) : Base_Event(delta_time) {
    po = object_pointer;
    pm = object_function_pointer;
  }

  //! Destructor
  virtual ~Event() {}

  //! Execute (call) the assigned function
  virtual void exec(void) {(*po.*pm)(); }

private:
  void (ObjectType::*pm)(); // Pointer to class member function to be executed on event expire.
  ObjectType *po; // Pointer to object who's member function is to be executed on event expire.
};

/*!
  \brief An Event class that executes a function with some data as input when the event expires.

  Since Events are objects you need supply both a pointer to the object and the function pointer to create the Event
*/
template <class ObjectType, class DataType> class Data_Event : public Base_Event
{
public:
  //! Construct an Event to expire delta_time from now by calling the function (*object_pointer.*object_function_pointer)(data)
  Data_Event(ObjectType *object_pointer,
             void (ObjectType::*object_function_pointer)(DataType data),
             DataType data, const Ttype delta_time) : Base_Event(delta_time) {
    po = object_pointer;
    pm = object_function_pointer;
    u = data;
  }

  //! Destructor
  virtual ~Data_Event() {}

  //! Execute (call) the assigned function with user data.
  virtual void exec(void) {
    (*po.*pm)(u);
  }

private:
  void (ObjectType::*pm)(DataType data); // Pointer to class member function to be executed on event expire.
  ObjectType* po; // Pointer to object who's member function is to be executed on event expire.
  DataType u; // User data.
};

//@}

} // namespace itpp

#endif

#endif // #ifndef EVENTS_H