This file is indexed.

/usr/include/x86_64-linux-gnu/zypp/Callback.h is in libzypp-dev 14.29.1-2.

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
/*---------------------------------------------------------------------\
|                          ____ _   __ __ ___                          |
|                         |__  / \ / / . \ . \                         |
|                           / / \ V /|  _/  _/                         |
|                          / /__ | | | | | |                           |
|                         /_____||_| |_| |_|                           |
|                                                                      |
\---------------------------------------------------------------------*/
/** \file zypp/Callback.h
 *
*/
#ifndef ZYPP_CALLBACK_H
#define ZYPP_CALLBACK_H

#include "zypp/base/NonCopyable.h"

///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////

  /** \todo Eliminate this! */
  namespace HACK {
    class Callback
    {
    };
  } // namespace HACK

  ///////////////////////////////////////////////////////////////////
  /** Callbacks light.
   *
   * \par The task report structure (SENDER SIDE).
   *
   * A default constructible struct derived from callback::ReportBase.
   * It \b must \b not conatin any data, just virtual methods.
   *
   * These are the functions the sender invokes, and which will be forwarded
   * to some receiver. If no receiver is present, the defined default
   * implementations are invoked.
   *
   * For methods returning non-void, define a reasonable return value,
   * because this is what you get back in case no receiver is listening.
   *
   * That way the sending side does not need to know whether some receiver
   * is listening. And it enables the receiver to return a reasonable value,
   * in case he's got no idea, what else to return.
   *
   * \code
   *   struct Foo : public callback::ReportBase
   *   {
   *     virtual void ping( int i )
   *     {}
   *     virtual int pong()
   *     { return -1; }
   *
   *   };
   * \endcode
   *
   * \par Sending a Task report (SENDER SIDE).
   *
   * Simply create a callback::SendReport<_Report>, where _Report
   * is your task report structure. Invoke the callback functions
   * as needed. That's it.
   *
   * \note Even creation and destruction of a callback::SendReport
   * are indicated to a receiver. So even in case of an Exception,
   * the receiver is able to recognize, that the task ended.
   * So don't create it without need.
   *
   * \code
   * {
   *   callback::SendReport<Foo> report;
   *   report->ping( 13 );
   *   int response = report->pong();
   * }
   * \endcode
   *
   * \par Receiving Task reports (RECEIVER SIDE).
   *
   * To receive task reports of type \c Foo the recipient class
   * derives from callback::ReceiveReport\<Foo\>. callback::ReceiveReport
   * inherits \c Foo and provides two additional virtual methods:
   *
   * \code
   *   virtual void reportbegin() {}
   *   virtual void reportend() {}
   * \endcode
   *
   * These two are automatically invoked, whenever the sender
   * creates a callback::SendReport instance, and when it gets
   * destructed. So even if the sending task is aborted without
   * sending an explicit notification, the reciever may notice it,
   * by overloading \c reportend.
   *
   * Overload the methods you're interested in.
   *
   * \note In case you must return some value and don't know which,
   * return the task structures default. The author of the task
   * structure had to provide this value, so it's probabely better
   * than anything you \e invent.
   * \code
   *   int somefunction()
   *   {
   *     ...// don't know what to return?
   *     return Foo::somefunction();
   *   }
   * \endcode
   *
   * \par Connecting the Receiver
   *
   * For this callback::ReceiveReport provides 4 methods:
   * \code
   *  void connect();
   *  void disconnect();
   *  bool connected() const;
   *  ReceiveReport * whoIsConnected() const;
   * \endcode
   *
   * \li \c connect Connect this ReceiveReport (in case some other
   * ReceiveReport is connected, it get disconnected. Remember its
   * a Callback light).
   * \li \c disconnect Disconnect this ReceiveReport in case it is
   * connected. If not connected nothing happens.
   * \li \c connected Test whether this ReceiveReport is currently
   * connected.
   * \li \c whoIsConnected Return a 'ReceiveReport*' to the currently
   * connected ReceiveReport, or \c NULL if none is connected.
   *
   * \par Passing Userdata via Callbacks
   *
   * For typesafe passing of user data via callbacks \see \ref UserData.
   *
   */
  namespace callback
  { /////////////////////////////////////////////////////////////////

    /**  */
    struct ReportBase
    {
      virtual ~ReportBase()
      {}
    };

    /**  */
    template<class _Report>
      class DistributeReport;

    /**  */
    template<class _Report>
      struct ReceiveReport : public _Report
      {
	typedef _Report                   ReportType;
	typedef ReceiveReport<_Report>    Receiver;
        typedef DistributeReport<_Report> Distributor;

        virtual ~ReceiveReport()
        { disconnect(); }

        ReceiveReport * whoIsConnected() const
        { return Distributor::instance().getReceiver(); }

        bool connected() const
        { return whoIsConnected() == this; }

        void connect()
        { Distributor::instance().setReceiver( *this ); }

        void disconnect()
        { Distributor::instance().unsetReceiver( *this ); }

        virtual void reportbegin()
        {}
        virtual void reportend()
        {}
      };

    /**  */
    template<class _Report>
      struct DistributeReport
      {
       public:
	typedef _Report                   ReportType;
	typedef ReceiveReport<_Report>    Receiver;
	typedef DistributeReport<_Report> Distributor;

         static DistributeReport & instance()
         {
           static DistributeReport _self;
           return _self;
         }

         Receiver * getReceiver() const
         { return _receiver == &_noReceiver ? 0 : _receiver; }

         void setReceiver( Receiver & rec_r )
         { _receiver = &rec_r; }

         void unsetReceiver( Receiver & rec_r )
         { if ( _receiver == &rec_r ) noReceiver(); }

         void noReceiver()
         { _receiver = &_noReceiver; }

      public:
         Receiver * operator->()
         { return _receiver; }

      private:
        DistributeReport()
        : _receiver( &_noReceiver )
        {}
        Receiver _noReceiver;
        Receiver * _receiver;
      };

    /**  */
    template<class _Report>
      struct SendReport : private zypp::base::NonCopyable
      {
	typedef _Report                   ReportType;
        typedef ReceiveReport<_Report>    Receiver;
        typedef DistributeReport<_Report> Distributor;

        SendReport()
        { Distributor::instance()->reportbegin(); }

        ~SendReport()
        { Distributor::instance()->reportend(); }

        static Receiver * whoIsConnected()
        { return Distributor::instance().getReceiver(); }

        static bool connected()
        { return whoIsConnected(); }

        Distributor & operator->()
        { return Distributor::instance(); }
      };

    /** Temporarily connect a ReceiveReport then restore the previous one.
     *
     * Pass the ReceiveReport you want to connect temporarily
     * to the ctor. The ReceiveReport is connected, a previously
     * connected ReceiveReport is remembered and re-connected in
     * the dtor.
     * Use the default ctpr to temporarily disconnect any connected report.
     * \code
     *  struct FooReceive : public callback::ReceiveReport<Foo>
     *  {..};
     *  struct FooReceive2 : public callback::ReceiveReport<Foo>
     *  {..};
     *
     *  FooReceive  r;
     *  FooReceive2 r2;
     *
     *  r.connect();
     *  ... // r receiving the report
     *  {
     *    callback::TempConnect<Foo> temp( r2 );
     *    ...// r2 receiving the report
     *  }
     *  ...// r receiving the report
     * \endcode
    */
    template<class _Report>
      struct TempConnect
      {
	typedef _Report                   ReportType;
        typedef ReceiveReport<_Report>    Receiver;
        typedef DistributeReport<_Report> Distributor;

        TempConnect()
        : _oldRec( Distributor::instance().getReceiver() )
        {
          Distributor::instance().noReceiver();
        }

        TempConnect( Receiver & rec_r )
        : _oldRec( Distributor::instance().getReceiver() )
        {
          rec_r.connect();
        }

        ~TempConnect()
        {
          if ( _oldRec )
            Distributor::instance().setReceiver( *_oldRec );
          else
            Distributor::instance().noReceiver();
        }
      private:
        Receiver * _oldRec;
      };

    /////////////////////////////////////////////////////////////////
  } // namespace callback
  ///////////////////////////////////////////////////////////////////
  /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_CALLBACK_H