This file is indexed.

/usr/include/Ice/OutgoingAsync.h is in libzeroc-ice35-dev 3.5.1-6+b3.

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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#ifndef ICE_OUTGOING_ASYNC_H
#define ICE_OUTGOING_ASYNC_H

#include <IceUtil/Monitor.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/Timer.h>
#include <IceUtil/Exception.h>
#include <IceUtil/UniquePtr.h>
#include <Ice/OutgoingAsyncF.h>
#include <Ice/InstanceF.h>
#include <Ice/ReferenceF.h>
#include <Ice/CommunicatorF.h>
#include <Ice/ConnectionIF.h>
#include <Ice/Current.h>
#include <Ice/BasicStream.h>
#include <Ice/ObserverHelper.h>

#ifdef ICE_CPP11
#   include <functional> // for std::function
#endif

namespace IceInternal
{

class CallbackBase;
typedef IceUtil::Handle<CallbackBase> CallbackBasePtr;

}

namespace Ice
{

class ICE_API AsyncResult : virtual public IceUtil::Shared, private IceUtil::noncopyable
{
public:

    virtual bool operator==(const AsyncResult&) const;
    virtual bool operator<(const AsyncResult&) const;

    virtual Int getHash() const;

    virtual CommunicatorPtr getCommunicator() const
    {
        return _communicator;
    }

    virtual ConnectionPtr getConnection() const
    {
        return 0;
    }

    virtual ObjectPrx getProxy() const
    {
        return 0;
    }

    bool isCompleted() const;
    void waitForCompleted();

    bool isSent() const;
    void waitForSent();

    void throwLocalException() const;

    bool sentSynchronously() const
    {
        return _sentSynchronously; // No lock needed, immutable once __send() is called
    }

    LocalObjectPtr getCookie() const
    {
        return _cookie; // No lock needed, cookie is immutable
    }

    const std::string& getOperation() const
    {
        return _operation;
    }

    ::IceInternal::BasicStream*
    __getOs()
    {
        return &_os;
    }

    ::IceInternal::BasicStream* __startReadParams()
    {
        _is.startReadEncaps();
        return &_is;
    }
    void __endReadParams()
    {
        _is.endReadEncaps();
    }
    void __readEmptyParams()
    {
        _is.skipEmptyEncaps();
    }
    void __readParamEncaps(const ::Ice::Byte*& encaps, ::Ice::Int& sz)
    {
        _is.readEncaps(encaps, sz);
    }

    bool __wait();
    void __throwUserException();
    void __exceptionAsync(const Exception&);

    static void __check(const AsyncResultPtr&, const ::IceProxy::Ice::Object*, const ::std::string&);
    static void __check(const AsyncResultPtr&, const Connection*, const ::std::string&);
    static void __check(const AsyncResultPtr&, const Communicator*, const ::std::string&);

    virtual void __exception(const Exception&); // Required to be public for AsynchronousException
    void __sent(); // Required to be public for AsynchronousSent

    virtual void __attachRemoteObserver(const Ice::ConnectionInfoPtr& c, const Ice::EndpointPtr& endpt, 
                                        Ice::Int requestId, Ice::Int sz)
    {
        _remoteObserver.attach(_observer.getRemoteObserver(c, endpt, requestId, sz));
    }

    IceInternal::InvocationObserver& __getObserver()
    {
        return _observer;
    }

protected:

    static void __check(const AsyncResultPtr&, const ::std::string&);

    AsyncResult(const CommunicatorPtr&, const IceInternal::InstancePtr&, const std::string&,
                const IceInternal::CallbackBasePtr&, const LocalObjectPtr&);

    void __sentAsync();
    void __response();

    void __warning(const std::exception&) const;
    void __warning() const;

    virtual ~AsyncResult(); // Must be heap-allocated.

    const CommunicatorPtr _communicator;
    const IceInternal::InstancePtr _instance;
    const std::string& _operation;
    const IceInternal::CallbackBasePtr _callback;
    const LocalObjectPtr _cookie;

    IceUtil::Monitor<IceUtil::Mutex> _monitor;
    IceInternal::BasicStream _is;
    IceInternal::BasicStream _os;

    static const unsigned char OK;
    static const unsigned char Done;
    static const unsigned char Sent;
    static const unsigned char EndCalled;

    unsigned char _state;
    bool _sentSynchronously;
    IceUtil::UniquePtr<Exception> _exception;
    IceInternal::InvocationObserver _observer;
    IceInternal::ObserverHelperT<Ice::Instrumentation::RemoteObserver> _remoteObserver;
};

}

namespace IceInternal
{

//
// See comments in OutgoingAsync.cpp
//
extern ICE_API CallbackBasePtr __dummyCallback;

class LocalExceptionWrapper;

//
// This interface is used by the connection to handle OutgoingAsync
// and BatchOutgoingAsync messages.
//
class ICE_API OutgoingAsyncMessageCallback : virtual public IceUtil::Shared
{
public:

    virtual ~OutgoingAsyncMessageCallback()
    {
    }

    //
    // Called by the connection when the message is confirmed sent. The connection is locked
    // when this is called so this method can call the sent callback. Instead, this method
    // returns true if there's a sent callback and false otherwise. If true is returned, the
    // connection will call the __sent() method bellow (which in turn should call the sent
    // callback).
    //
    virtual bool __sent(Ice::ConnectionI*) = 0;

    //
    // Called by the connection to call the user sent callback.
    //
    virtual void __sent() = 0;

    //
    // Called by the connection when the request failed. The boolean indicates whether or
    // not the message was possibly sent (this is useful for retry to figure out whether
    // or not the request can't be retried without breaking at-most-once semantics.)
    //
    virtual void __finished(const Ice::LocalException&, bool) = 0;
};

class ICE_API OutgoingAsync : public OutgoingAsyncMessageCallback, public Ice::AsyncResult, private IceUtil::TimerTask
{
public:

    OutgoingAsync(const Ice::ObjectPrx&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&);

    void __prepare(const std::string&, Ice::OperationMode, const Ice::Context*);

    virtual Ice::ObjectPrx
    getProxy() const
    {
        return _proxy;
    }

    virtual bool __sent(Ice::ConnectionI*);
    virtual void __sent();
    virtual void __finished(const Ice::LocalException&, bool);

    void __finished(const LocalExceptionWrapper&);
    void __finished();

    bool __send(bool);

    BasicStream* __startWriteParams(Ice::FormatType format)
    {
        _os.startWriteEncaps(_encoding, format);
        return &_os;
    }
    void __endWriteParams()
    {
        _os.endWriteEncaps();
    }
    void __writeEmptyParams()
    {
        _os.writeEmptyEncaps(_encoding);
    }
    void __writeParamEncaps(const ::Ice::Byte* encaps, ::Ice::Int size)
    {
        if(size == 0)
        {
            _os.writeEmptyEncaps(_encoding);
        }
        else
        {
            _os.writeEncaps(encaps, size);
        }
    }

    ::IceInternal::BasicStream*
    __getIs()
    {
        return &_is;
    }

protected:

    Ice::ObjectPrx _proxy;

private:

    int handleException(const Ice::LocalException&, bool);
    int handleException(const LocalExceptionWrapper&);

    void runTimerTask(); // Implementation of TimerTask::runTimerTask()
    Ice::ConnectionIPtr _timerTaskConnection;

    Handle< IceDelegate::Ice::Object> _delegate;
    Ice::EncodingVersion _encoding;
    int _cnt;
    Ice::OperationMode _mode;
};

class ICE_API BatchOutgoingAsync : public OutgoingAsyncMessageCallback, public Ice::AsyncResult
{
public:

    BatchOutgoingAsync(const Ice::CommunicatorPtr&, const InstancePtr&, const std::string&, const CallbackBasePtr&,
                       const Ice::LocalObjectPtr&);

    virtual bool __sent(Ice::ConnectionI*);
    virtual void __sent();
    virtual void __finished(const Ice::LocalException&, bool);
};

class ICE_API ProxyBatchOutgoingAsync : public BatchOutgoingAsync
{
public:

    ProxyBatchOutgoingAsync(const Ice::ObjectPrx&, const std::string&, const CallbackBasePtr&,
                            const Ice::LocalObjectPtr&);

    void __send();

    virtual Ice::ObjectPrx
    getProxy() const
    {
        return _proxy;
    }

private:
    
    Ice::ObjectPrx _proxy;
};

class ICE_API ConnectionBatchOutgoingAsync : public BatchOutgoingAsync
{
public:

    ConnectionBatchOutgoingAsync(const Ice::ConnectionIPtr&, const Ice::CommunicatorPtr&, const InstancePtr&,
                                 const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&);

    void __send();

    virtual Ice::ConnectionPtr getConnection() const;

private:

    const Ice::ConnectionIPtr _connection;
};

class ICE_API CommunicatorBatchOutgoingAsync : public Ice::AsyncResult
{
public:

    CommunicatorBatchOutgoingAsync(const Ice::CommunicatorPtr&, const InstancePtr&, const std::string&,
                                   const CallbackBasePtr&, const Ice::LocalObjectPtr&);

    void flushConnection(const Ice::ConnectionIPtr&);
    void ready();

private:

    void check(bool);

    int _useCount;
};

//
// Base class for all callbacks.
//
class ICE_API CallbackBase : public IceUtil::Shared
{
public:

    void checkCallback(bool obj, bool cb)
    {
        if(!obj)
        {
            throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "callback object cannot be null");
        }
        if(!cb)
        {
            throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "callback cannot be null");
        }
    }

    virtual void __completed(const ::Ice::AsyncResultPtr&) const = 0;
    virtual CallbackBasePtr __verify(::Ice::LocalObjectPtr&) = 0;
    virtual void __sent(const ::Ice::AsyncResultPtr&) const = 0;
    virtual bool __hasSentCallback() const = 0;
};

//
// Base class for generic callbacks.
//
class ICE_API GenericCallbackBase : virtual public CallbackBase
{
};

//
// Generic callback template that requires the caller to down-cast the
// proxy and the cookie that are obtained from the AsyncResult.
//
template<class T>
class AsyncCallback : public GenericCallbackBase
{
public:

    typedef T callback_type;
    typedef IceUtil::Handle<T> TPtr;

    typedef void (T::*Callback)(const ::Ice::AsyncResultPtr&);

    AsyncCallback(const TPtr& instance, Callback cb, Callback sentcb = 0) :
        callback(instance), completed(cb), sent(sentcb)
    {
        checkCallback(instance, cb != 0);
    }

    virtual void __completed(const ::Ice::AsyncResultPtr& result) const
    {
        (callback.get()->*completed)(result);
    }

    virtual CallbackBasePtr __verify(::Ice::LocalObjectPtr&)
    {
        return this; // Nothing to do, the cookie is not type-safe.
    }

    virtual void __sent(const ::Ice::AsyncResultPtr& result) const
    {
        if(sent)
        {
            (callback.get()->*sent)(result);
        }
    }

    virtual bool __hasSentCallback() const
    {
        return sent != 0;
    }

    TPtr callback;
    Callback completed;
    Callback sent;
};

#ifdef ICE_CPP11

template<typename T> struct callback_type
{
    static const int value = 1;
};

template<> struct callback_type<void(const ::Ice::AsyncResultPtr&)>
{
    static const int value = 2;
};

template<> struct callback_type<void(const ::Ice::Exception&)>
{
    static const int value = 3;
};

template<typename Callable, typename = void> struct callable_type
{
    static const int value = 1;
};

template<class Callable> struct callable_type<Callable, typename ::std::enable_if< ::std::is_class<Callable>::value && 
                                                                                   !::std::is_bind_expression<Callable>::value>::type>
{
    template<typename T, T> struct TypeCheck;
    template<typename T> struct AsyncResultCallback
    {
        typedef void (T::*ok)(const ::Ice::AsyncResultPtr&) const;
    };
    template<typename T> struct ExceptionCallback
    {
        typedef void (T::*ok)(const ::Ice::Exception&) const;
    };

    typedef char (&other)[1];
    typedef char (&asyncResult)[2];
    typedef char (&exception)[3];

    template<typename T> static other check(...);
    template<typename T> static asyncResult check(TypeCheck<typename AsyncResultCallback<T>::ok, &T::operator()>*);
    template<typename T> static exception check(TypeCheck<typename ExceptionCallback<T>::ok, &T::operator()>*);

    enum { value = sizeof(check<Callable>(0)) };
};

template<> struct callable_type<void(*)(const ::Ice::AsyncResultPtr&)> 
{
    static const int value = 2;
};

template<> struct callable_type<void(*)(const ::Ice::Exception&)>
{
    static const int value = 3;
};

template<typename Callable, typename Callback> struct is_callable
{
    static const bool value = callable_type<Callable>::value == callback_type<Callback>::value;
};

template<class S> class Function : public std::function<S>
{

public:

    template<typename T> Function(T f, typename ::std::enable_if<is_callable<T, S>::value>::type* = 0) : std::function<S>(f)
    {
    }
    
    Function()
    {
    }
    
    Function(::std::nullptr_t) : ::std::function<S>(nullptr)
    {
    }
};

class Cpp11AsyncCallback : public GenericCallbackBase
{
public:

    Cpp11AsyncCallback(const ::std::function<void (const ::Ice::AsyncResultPtr&)>& completed,
                       const ::std::function<void (const ::Ice::AsyncResultPtr&)>& sent) :
        _completed(completed), 
        _sent(sent)
    {
        checkCallback(true, completed != nullptr);
    }

    virtual void __completed(const ::Ice::AsyncResultPtr& result) const
    {
        _completed(result);
    }

    virtual CallbackBasePtr __verify(::Ice::LocalObjectPtr&)
    {
        return this; // Nothing to do, the cookie is not type-safe.
    }

    virtual void __sent(const ::Ice::AsyncResultPtr& result) const
    {
        if(_sent != nullptr)
        {
            _sent(result);
        }
    }
    
    virtual bool __hasSentCallback() const
    {
        return _sent != nullptr;
    }
    
    ::std::function< void (const ::Ice::AsyncResultPtr&)> _completed;
    ::std::function< void (const ::Ice::AsyncResultPtr&)> _sent;
};
#endif

}

namespace Ice
{

typedef IceUtil::Handle< ::IceInternal::GenericCallbackBase> CallbackPtr;

template<class T> CallbackPtr
newCallback(const IceUtil::Handle<T>& instance,
            void (T::*cb)(const ::Ice::AsyncResultPtr&),
            void (T::*sentcb)(const ::Ice::AsyncResultPtr&) = 0)
{
    return new ::IceInternal::AsyncCallback<T>(instance, cb, sentcb);
}

template<class T> CallbackPtr
newCallback(T* instance,
            void (T::*cb)(const ::Ice::AsyncResultPtr&),
            void (T::*sentcb)(const ::Ice::AsyncResultPtr&) = 0)
{
    return new ::IceInternal::AsyncCallback<T>(instance, cb, sentcb);
}

#ifdef ICE_CPP11
inline CallbackPtr
newCallback(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed,
            const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = 
                  ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
    return new ::IceInternal::Cpp11AsyncCallback(completed, sent);
}
#endif

//
// Operation callbacks are specified in Proxy.h
//

//
// Interfaces for the deprecated AMI mapping.
//

class ICE_API AMISentCallback 
{
public:

    virtual ~AMISentCallback() { }

    virtual void ice_sent() = 0;
};

class ICE_API AMICallbackBase : virtual public IceUtil::Shared
{
public:

    virtual void ice_exception(const Exception&) = 0;

    void __exception(const Exception&);
    void __sent(bool);
};

}

#endif