QtDBusApp.h

Go to the documentation of this file.
00001 //# QtDBusXmlApp.qo.h: Abstract parent to use the CASA DBus server.
00002 //# Copyright (C) 2009
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef QTDBUSAPP_QO_H_
00028 #define QTDBUSAPP_QO_H_
00029 
00030 #include <set>
00031 #include <string>
00032 #include <QString>
00033 #include <QDBusConnection>
00034 #include <sys/types.h>
00035 
00036 namespace casa {
00037 
00038     class QtDBusApp {
00039         public:
00040             static QDBusConnection connection( );
00041             QString dbusServiceName( const QString &name, const pid_t pid );
00042             QString dbusObjectName( const QString &name, const pid_t pid );
00043             static QString serviceOwner( const QString &service );
00044             static QString serviceOwner( const std::string &service );
00045             const QString &dbusServiceName( const QString &name="" );
00046             const QString &dbusObjectName( const QString &name="" );
00047             static bool serviceIsAvailable(const QString &service);
00048             static bool serviceIsAvailable(const std::string &service);
00049 
00050             virtual QString dbusName( ) const = 0;
00051             static QString generateServiceName( const QString &name, const pid_t pid );
00052 
00053 
00054             QtDBusApp( );
00055             virtual ~QtDBusApp( );
00056 
00057             // Connects to the DBus server using the name provided (if non-null). Otherwise, the
00058             // dbusName() method with the current process ID is used.  Returns a boolean which
00059             // indicates whether the connection succeeded or not.
00060             virtual bool connectToDBus( const QString &dbus_name="" ) = 0;
00061 
00062         protected:
00063 
00064             bool connectToDBus( QObject *object,  const QString &dbus_name="" );
00065 
00066         private:
00067             static const QString &serviceBase( );
00068             static const QString &objectBase( );
00069             QString *service_name;
00070             QString *object_name;
00071     };
00072 
00073     inline std::string to_string(const QString &other) { return std::string((const char*) other.toAscii().data()); }
00074 
00075 }
00076 
00077 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1