/usr/include/dclib-0.3/dclib/core/ccallback.h is in libdc-dev 0.3.24~svn3121-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 | /***************************************************************************
ccallback.h - description
-------------------
begin : Thu Aug 1 2002
copyright : (C) 2002-2003 by Mathias Küster
email : mathen@users.berlios.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 CCALLBACK_H
#define CCALLBACK_H
/**
*@author Mathias Küster
*
* CObject replaced with templates by Edward Sheldrake.
*
* It's a callback, used when one class needs to
* communicate with another class, without knowing what the other
* class is. Virtual functions are also used for this, e.g. some
* valknut classes inherit a dclib class and implement DC_Callback()
* or similar.
*/
#include <dclib/dcos.h>
/**
* _CCallback0 / CCallback0<Receiver> now takes no parameters.
* Mainly used for CThread and CManager.
*/
class _CCallback0
{
public:
/** */
_CCallback0() {};
/** */
virtual ~_CCallback0() {};
/** */
virtual int notify() = 0;
};
template<class Receiver> class CCallback0 : public _CCallback0 {
public:
/** */
CCallback0(Receiver* object, int (Receiver::*method)())
: myObject(object),
myMethod(method)
{}
/** */
virtual ~CCallback0() {};
/** */
virtual int notify()
{
return (myObject->*myMethod)();
}
private:
/** */
Receiver* myObject;
/** */
int (Receiver::*myMethod)();
};
/**
* _CCallback1<Parameter> / CCallback1<Receiver, Parameter> takes one argument usually CDCMessage*
* but some are used to pass an int (a socket) around.
*/
template<typename Parameter> class _CCallback1
{
public:
/** Constructor - not created, CCallback is created */
_CCallback1() {};
/** Destructor */
virtual ~_CCallback1() {};
/** */
virtual int notify( Parameter ) = 0;
};
template<class Receiver, typename Parameter> class CCallback1 : public _CCallback1<Parameter>
{
public:
/** Constructor */
CCallback1( Receiver * recv, int (Receiver::*method)(Parameter) )
: m_pRecv( recv ), m_pMethod( method ) {};
/** */
virtual ~CCallback1() {};
/** */
virtual int notify( Parameter p )
{
return (m_pRecv->*m_pMethod)( p );
}
private:
/** Object whose method gets called */
Receiver * m_pRecv;
/** The method that gets called */
int (Receiver::*m_pMethod)( Parameter );
};
/**
* _CCallback2<Sender, Parameter> / CCallback2<Receiver, Sender, Parameter> notify
* takes two arguments - a pointer to the sender and the parameter.
*/
template<class Sender, typename Parameter> class _CCallback2
{
public:
/** Constructor - not created, CCallback is created */
_CCallback2() {};
/** Destructor */
virtual ~_CCallback2() {};
/** */
virtual int notify( Sender*, Parameter ) = 0;
};
template<class Receiver, class Sender, typename Parameter> class CCallback2: public _CCallback2<Sender,Parameter>
{
public:
/** Constructor */
CCallback2( Receiver * recv, int (Receiver::*method)( Sender*, Parameter ) )
: m_pRecv( recv ), m_pMethod( method ) {};
/** Destructor */
virtual ~CCallback2() {};
/** */
virtual int notify( Sender* sender, Parameter p )
{
return (m_pRecv->*m_pMethod)( sender, p );
}
private:
/** Object whose method gets called */
Receiver * m_pRecv;
/** The method that gets called */
int (Receiver::*m_pMethod)( Sender*, Parameter );
};
#endif
|