DCOPRef Class Reference
A DCOPRef(erence) encapsulates a remote DCOP object as a triple <app,obj,type> where type is optional. More...
#include <dcopref.h>
Public Types | |
enum | EventLoopFlag { NoEventLoop, UseEventLoop } |
Public Member Functions | |
DCOPRef () | |
DCOPRef (const DCOPRef &ref) | |
DCOPRef (const QCString &app, const QCString &obj="") | |
DCOPRef (DCOPObject *object) | |
DCOPRef (const QCString &app, const QCString &obj, const QCString &type) | |
bool | isNull () const |
QCString | app () const |
QCString | obj () const |
QCString | object () const |
QCString | type () const |
DCOPRef & | operator= (const DCOPRef &) |
void | setRef (const QCString &app, const QCString &obj="") |
void | setRef (const QCString &app, const QCString &obj, const QCString &type) |
void | clear () |
DCOPClient * | dcopClient () const |
void | setDCOPClient (DCOPClient *client) |
DCOPReply | call (const QCString &fun) |
DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop=NoEventLoop, int timeout=-1) |
template<class T1> DCOPReply | call (const QCString &fun, const T1 &t1) |
template<class T1> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1) |
template<class T1, class T2> DCOPReply | call (const QCString &fun, const T1 &t1, const T2 &t2) |
template<class T1, class T2> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1, const T2 &t2) |
template<class T1, class T2, class T3> DCOPReply | call (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3) |
template<class T1, class T2, class T3> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1, const T2 &t2, const T3 &t3) |
template<class T1, class T2, class T3, class T4> DCOPReply | call (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) |
template<class T1, class T2, class T3, class T4> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) |
template<class T1, class T2, class T3, class T4, class T5> DCOPReply | call (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5) |
template<class T1, class T2, class T3, class T4, class T5> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5) |
template<class T1, class T2, class T3, class T4, class T5, class T6> DCOPReply | call (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6) |
template<class T1, class T2, class T3, class T4, class T5, class T6> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6) |
template<class T1, class T2, class T3, class T4, class T5, class T6, class T7> DCOPReply | call (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7) |
template<class T1, class T2, class T3, class T4, class T5, class T6, class T7> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7) |
template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8> DCOPReply | call (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8) |
template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8> DCOPReply | callExt (const QCString &fun, EventLoopFlag useEventLoop, int timeout, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8) |
bool | send (const QCString &fun) |
template<class T1> bool | send (const QCString &fun, const T1 &t1) |
template<class T1, class T2> bool | send (const QCString &fun, const T1 &t1, const T2 &t2) |
template<class T1, class T2, class T3> bool | send (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3) |
template<class T1, class T2, class T3, class T4> bool | send (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) |
template<class T1, class T2, class T3, class T4, class T5> bool | send (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5) |
template<class T1, class T2, class T3, class T4, class T5, class T6> bool | send (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6) |
template<class T1, class T2, class T3, class T4, class T5, class T6, class T7> bool | send (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7) |
template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8> bool | send (const QCString &fun, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8) |
Detailed Description
A DCOPRef(erence) encapsulates a remote DCOP object as a triple <app,obj,type> where type is optional.It allows for calling and passing DCOP objects.
A DCOP reference makes it possible to return references to other DCOP objects in a DCOP interface, for example in the method giveMeAnotherObject() in an interface like this:
class Example : public DCOPObject { K_DCOP ... k_dcop: DCOPRef giveMeAnotherObject(); int doSomething( QString, float, bool ); ASYNC pingMe( QCString message ); UserType userFunction( UserType ); };
In addition, the reference can operate as a comfortable generic stub to call remote DCOP objects in cases where no DCOPStub is available. The advantage of using DCOPRef instead of the low-level functions DCOPClient::call() and DCOPClient::send() are the nicer syntax and the implicit runtime error checking.
Say you want to call the method "doSomething" from the above interface on an object called "example" that lives in application "foo". Using DCOPRef, you would write
DCOPRef example( "foo", "example" ); int result = example.call( "doSomething", QString("Hello World"), (float)2.5, true );
If it is important for you to know whether the call succeeded or not, you can use the slightly more elaborate pattern:
DCOPRef example( "foo", "example" ); DCOPReply reply = example.call( "doSomething", QString("Hello World"), (float)2.5, true ); if ( reply.isValid() ) { int result = reply; // ... }
Note that you must pass a QString for the first argument. If you use a regular char pointer, it will be converted to a QCString.
For curiosity, here is how you would achieve the exactly same functionality by using DCOPClient::call() directly:
QByteArray data, replyData; QCString replyType; QDataStream arg( data, IO_WriteOnly ); arg << QString("hello world" ), (float) 2.5 << true; if ( DCOPClient::mainClient()->call( app, obj, "doSomething(QString,float,bool)", data, replyType, replyData ) ) { if ( replyType == "int" ) { int result; QDataStream reply( replyData, IO_ReadOnly ); reply >> result; // ... } }
As you might see from the code snippet, the DCOPRef has to "guess" the names of the datatypes of the arguments to construct a dcop call. This is done through global inline overloads of the dcopTypeName function, for example
inline const char* dcopTypeName( const QString& ) { return "QString"; }
If you use custom data types that do support QDataStream but have no corrsponding dcopTypeName overload, you can either provide such an overload or use a DCOPArg wrapper that allows you to specify the type.
UserType userType; DCOPReply reply = example.call( "userFunction", DCOPArg( userType, "UserType" ) );
Similar, when you retrieve such a data type, you can use an explicit call to DCOPReply::get():
UserType userType; reply.get( userType, "UserType" );
The function send() works very similar to call(), only that it returns a simple bool on whether the signal could be sent or not:
if ( example.pingMe( "message" ) == false ) qWarning("could not ping example" );
A DCOP reference operates on DCOPClient::mainClient(), unless you explicitly specify another client with setDCOPClient().
- See also:
- DCOPArg
- Author:
- Matthias Ettrich <ettrich@kde.org>, Torben Weis <weis@kde.org>
Definition at line 278 of file dcopref.h.
Member Enumeration Documentation
|
Flag for allowing entering the event loop if the call blocks too long.
|
Constructor & Destructor Documentation
|
Creates a null reference.
|
|
Copy constructor. Definition at line 110 of file dcopref.cpp. |
|
Creates a reference for application
|
|
Creates a reference to an existing dcop object.
|
|
Creates a reference for application
|
Member Function Documentation
|
Tests whether this is a null reference.
References QCString::isNull(). |
|
Name of the application in which the object resides.
Referenced by DCOPRef(), and operator=(). |
|
Object ID of the referenced object.
Referenced by DCOPRef(), and operator=(). |
|
Definition at line 150 of file dcopref.cpp. |
|
Type of the referenced object. May be null (i.e. unknown).
Referenced by DCOPRef(), and operator=(). |
|
Assignment operator. Copies the references data. Definition at line 171 of file dcopref.cpp. |
|
Changes the referenced object. Resets the type to unknown (null). The type is not needed for call() and send().
|
|
Changes the referenced object.
|
|
Makes this a null reference.
|
|
Returns the dcop client the reference operates on. If no client has been set, this is the DCOPClient::mainClient().
References DCOPClient::mainClient(). |
|
Sets a specific dcop client for this reference. Otherwise DCOPClient::mainClient() is used.
|
|
Calls the function
|
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
|
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function
References QCString::sprintf(). |
|
Like call(), with additional arguments allowing entering the event loop and specifying timeout.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
|
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
|
Calls the function Unlike call() this method does not expect a return value.
References QCString::sprintf(). |
The documentation for this class was generated from the following files: