casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
casa::QtDBusXmlApp Class Referenceabstract

Abstract parent of classes that want to register themselves with CASA's DBus server. More...

#include <QtDBusXmlApp.qo.h>

Inheritance diagram for casa::QtDBusXmlApp:
casa::QtDBusApp casa::PlotMSDBusApp

Static Public Member Functions

static bool dbusXmlCallNoRet (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, bool isAsync=false)
 Calls the given method on the object with the given name that is registered with CASA's DBus server, using the given parameters. More...
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, bool &retValue, bool *retValueSet=NULL)
 Like dbusXmlCallNoRet(), except that if the remote method has a return value of the given type, then the value is set accordingly. More...
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, int &retValue, bool *retValueSet=NULL)
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::uInt &retValue, bool *retValueSet=NULL)
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, double &retValue, bool *retValueSet=NULL)
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::String &retValue, bool *retValueSet=NULL)
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::Record &retValue, bool *retValueSet=NULL)
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::Array< bool > &retValue, bool *retValueSet=NULL)
 
static bool dbusXmlCall (const casacore::String &fromName, const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::Array< int > &retValue, bool *retValueSet=NULL)
 
- Static Public Member Functions inherited from casa::QtDBusApp
static QDBusConnection connection ()
 
static QString serviceOwner (const QString &service)
 
static QString serviceOwner (const std::string &service)
 
static bool serviceIsAvailable (const QString &service)
 
static bool serviceIsAvailable (const std::string &service)
 
static QString generateServiceName (const QString &name, const pid_t pid)
 

Protected Member Functions

 QtDBusXmlApp ()
 Constructor. More...
 
virtual ~QtDBusXmlApp ()
 Destructor. More...
 
virtual void dbusRunXmlMethod (const casacore::String &methodName, const casacore::Record &parameters, casacore::Record &retValue, const casacore::String &callerName, bool isAsync)=0
 ABSTRACT METHODS //. More...
 
virtual void dbusXmlReceived (const QtDBusXML &xml)
 VIRTUAL METHODS //. More...
 
bool dbusRegisterSelf (const casacore::String &name="")
 IMPLEMENTED METHODS //. More...
 
void dbusUnregisterSelf ()
 Unregisters this object with CASA's DBus server, if it is registered. More...
 
bool dbusSelfIsRegistered () const
 Returns true if this object is currently registered with CASA's DBus server, false otherwise. More...
 
casacore::String dbusSelfRegisteredName () const
 Returns the name that this object is registered with with CASA's DBus server, or an empty casacore::String if this application is not currently registered. More...
 
bool dbusXmlCallNoRet (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, bool isAsync=false)
 Calls the static version of the method with this application's name. More...
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, bool &retValue, bool *retValueSet=NULL)
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, int &retValue, bool *retValueSet=NULL)
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::uInt &retValue, bool *retValueSet=NULL)
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, double &retValue, bool *retValueSet=NULL)
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::String &retValue, bool *retValueSet=NULL)
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::Record &retValue, bool *retValueSet=NULL)
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::Array< bool > &retValue, bool *retValueSet=NULL)
 
bool dbusXmlCall (const casacore::String &objectName, const casacore::String &methodName, const casacore::Record &parameters, casacore::Array< int > &retValue, bool *retValueSet=NULL)
 
- Protected Member Functions inherited from casa::QtDBusApp
bool connectToDBus (QObject *object, const QString &dbus_name="")
 

Private Member Functions

void dbusSlot (QtDBusXML &xml)
 Method for when one of the slots in the adaptor is activated. More...
 

Static Private Member Functions

static bool dbusXmlCall (const casacore::String &from, const casacore::String &to, const casacore::String &methodName, bool methodIsAsync, const casacore::Record &parameters, casacore::Record *retValue)
 Private Static Methods //. More...
 

Private Attributes

bool dbusRegistered_
 Flag for whether the application is currently registered or not. More...
 
QString dbusName_
 Name that the application is registered with. More...
 
QtDBusXmlAppAdaptordbusAdaptor_
 DBus adaptor. More...
 

Friends

class QtDBusXmlAppAdaptor
 

Additional Inherited Members

- Public Member Functions inherited from casa::QtDBusApp
QString dbusServiceName (const QString &name, const pid_t pid)
 
QString dbusObjectName (const QString &name, const pid_t pid)
 
const QString & dbusServiceName (const QString &name="")
 
const QString & dbusObjectName (const QString &name="")
 
virtual QString dbusName () const =0
 
 QtDBusApp ()
 
virtual ~QtDBusApp ()
 
virtual bool connectToDBus (const QString &dbus_name="")=0
 Connects to the DBus server using the name provided (if non-null). More...
 

Detailed Description

Abstract parent of classes that want to register themselves with CASA's DBus server.

The class also provides public static methods for other code to send DBus messages without needing to subclass and register. This class hides the details of how the DBus communication happens behind the scenes and presents an interface using CASA objects like Records. Applications that want to use this DBus communication layer need to know about the following for each method call: The object name. Each object that registers with CASA's DBus server must do so with a unique name. Outside objects then can send messages to that object by using its name. Names have some restrictions; see dbusRegisterSelf(). You can check if a certain name is currently registered using dbusNameIsRegistered(). The method name. Each object keeps track of what methods it supports, and this process happens dynamically on a per-message basis. Whether to call asynchronously or not. See dbusXmlCallNoRet(). The method parameters. The parameters are set using name/value pairs in a Record. Like the method name, this is on a dynamic, per-object basis. IMPORTANT: not all types are currently supported; see QtDBusXML documentation to see what is currently implemented. The method return value. IMPORTANT: not all types are currently supported; see QtDBusXML documentation to see what is currently implemented.

If a class wants to receive DBus communications, it must take the following steps: 1) Subclass QtDBusXmlApp. 2) Implement the dbusRunXmlMethod() method, which is called when a DBus method call is received. For a discussion of the parameters to this method, see above. 3) Call dbusRegisterSelf() with a unique name.

Classes that wish to send but not receive messages do NOT need to subclass QtDBusXmlApp and can just use the public static methods to call methods on DBus-registered objects. For a discussion of the parameters to these static methods, see above.

Definition at line 77 of file QtDBusXmlApp.qo.h.

Constructor & Destructor Documentation

casa::QtDBusXmlApp::QtDBusXmlApp ( )
protected

Constructor.

virtual casa::QtDBusXmlApp::~QtDBusXmlApp ( )
protectedvirtual

Destructor.

Unregisters from the CASA DBus server if needed.

Member Function Documentation

bool casa::QtDBusXmlApp::dbusRegisterSelf ( const casacore::String name = "")
protected

IMPLEMENTED METHODS //.

Registers this object with CASA's DBus server, if it is not already, with the given name and returns whether or not the registration succeeded. If the name is blank, then the last set name is used, UNLESS this is the first time registering in which case the registration will fail. The registration name MUST contain only numbers, letters, and underscores, and MUST be unique for the DBus server; trying to register with a name that is already in use will result in registration failure. (Note, however, that the name needs ONLY to be unique within the CASA DBus application names rather than all system-wide DBus application names.) Trying to register when already registered (see dbusSelfIsRegistered()) will result in registration failure; to change names, you must unregister and then reregister with the new name.

virtual void casa::QtDBusXmlApp::dbusRunXmlMethod ( const casacore::String methodName,
const casacore::Record parameters,
casacore::Record retValue,
const casacore::String callerName,
bool  isAsync 
)
protectedpure virtual

ABSTRACT METHODS //.

Runs the method with the specified name using the given parameters and placing the return value, if any, into the given retValue record. NOTE: when defining the return value, the name doesn't matter because the first entry is used. The caller name, and whether this is an asynchronous call or not, are also provided but do not need to be used. Note, however, that asynchronous method calls will NOT use a return value even if one is set.

Implemented in casa::PlotMSDBusApp.

bool casa::QtDBusXmlApp::dbusSelfIsRegistered ( ) const
protected

Returns true if this object is currently registered with CASA's DBus server, false otherwise.

casacore::String casa::QtDBusXmlApp::dbusSelfRegisteredName ( ) const
protected

Returns the name that this object is registered with with CASA's DBus server, or an empty casacore::String if this application is not currently registered.

Referenced by dbusXmlCall(), and dbusXmlCallNoRet().

void casa::QtDBusXmlApp::dbusSlot ( QtDBusXML xml)
private

Method for when one of the slots in the adaptor is activated.

First sends to dbusXmlReceived(), then to dbusRunXmlMethod().

void casa::QtDBusXmlApp::dbusUnregisterSelf ( )
protected

Unregisters this object with CASA's DBus server, if it is registered.

static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
bool &  retValue,
bool *  retValueSet = NULL 
)
static

Like dbusXmlCallNoRet(), except that if the remote method has a return value of the given type, then the value is set accordingly.

If there is no return value or it is a different type, the value is not set. If retValueSet is given, it will be set to true if the return value was set and false otherwise.

Referenced by dbusXmlCall().

static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
int &  retValue,
bool *  retValueSet = NULL 
)
static
static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::uInt retValue,
bool *  retValueSet = NULL 
)
static
static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
double &  retValue,
bool *  retValueSet = NULL 
)
static
static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::String retValue,
bool *  retValueSet = NULL 
)
static
static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::Record retValue,
bool *  retValueSet = NULL 
)
static
static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::Array< bool > &  retValue,
bool *  retValueSet = NULL 
)
static
static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::Array< int > &  retValue,
bool *  retValueSet = NULL 
)
static
bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
bool &  retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 203 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
int &  retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 208 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::uInt retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 213 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
double &  retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 218 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::String retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 223 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::Record retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 228 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::Array< bool > &  retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 233 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
casacore::Array< int > &  retValue,
bool *  retValueSet = NULL 
)
inlineprotected

Definition at line 238 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCall().

static bool casa::QtDBusXmlApp::dbusXmlCall ( const casacore::String from,
const casacore::String to,
const casacore::String methodName,
bool  methodIsAsync,
const casacore::Record parameters,
casacore::Record retValue 
)
staticprivate

Private Static Methods //.

Helper method for calling remote methods.

static bool casa::QtDBusXmlApp::dbusXmlCallNoRet ( const casacore::String fromName,
const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
bool  isAsync = false 
)
static

Calls the given method on the object with the given name that is registered with CASA's DBus server, using the given parameters.

The given from name is sent to the remote object, but not used otherwise. If isAsync is true, then the remote method runs asynchronously, which means that control returns immediately after sending the message. This method does NOT give a return value, even if the remote method does. Returns true for success, false for failure. Will fail if the given object name is not registered with CASA's DBus server.

Referenced by dbusXmlCallNoRet().

bool casa::QtDBusXmlApp::dbusXmlCallNoRet ( const casacore::String objectName,
const casacore::String methodName,
const casacore::Record parameters,
bool  isAsync = false 
)
inlineprotected

Calls the static version of the method with this application's name.

Definition at line 198 of file QtDBusXmlApp.qo.h.

References dbusSelfRegisteredName(), and dbusXmlCallNoRet().

virtual void casa::QtDBusXmlApp::dbusXmlReceived ( const QtDBusXML xml)
inlineprotectedvirtual

VIRTUAL METHODS //.

Method that can be overridden if the subclass wants to be informed whenever ANY dbus message is received, even if this object is not the intended recipient. Note that most applications won't need to do this (and probably shouldn't) since dbusRunXmlMethod() will be called with the appropriate parameters if this object is the intended recipient.

Reimplemented in casa::PlotMSDBusApp.

Definition at line 165 of file QtDBusXmlApp.qo.h.

Friends And Related Function Documentation

friend class QtDBusXmlAppAdaptor
friend

Definition at line 80 of file QtDBusXmlApp.qo.h.

Member Data Documentation

QtDBusXmlAppAdaptor* casa::QtDBusXmlApp::dbusAdaptor_
private

DBus adaptor.

Definition at line 254 of file QtDBusXmlApp.qo.h.

QString casa::QtDBusXmlApp::dbusName_
private

Name that the application is registered with.

Definition at line 251 of file QtDBusXmlApp.qo.h.

bool casa::QtDBusXmlApp::dbusRegistered_
private

Flag for whether the application is currently registered or not.

Definition at line 248 of file QtDBusXmlApp.qo.h.


The documentation for this class was generated from the following file: