casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtDBusApp.h
Go to the documentation of this file.
1 //# QtDBusXmlApp.qo.h: Abstract parent to use the CASA DBus server.
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef QTDBUSAPP_QO_H_
28 #define QTDBUSAPP_QO_H_
29 
30 #include <set>
31 #include <string>
32 #include <QString>
33 #include <QDBusConnection>
34 #include <sys/types.h>
35 
36 namespace casa {
37 
38  class QtDBusApp {
39  public:
40  static QDBusConnection connection( );
41  QString dbusServiceName( const QString &name, const pid_t pid );
42  QString dbusObjectName( const QString &name, const pid_t pid );
43  static QString serviceOwner( const QString &service );
44  static QString serviceOwner( const std::string &service );
45  const QString &dbusServiceName( const QString &name="" );
46  const QString &dbusObjectName( const QString &name="" );
47  static bool serviceIsAvailable(const QString &service);
48  static bool serviceIsAvailable(const std::string &service);
49 
50  virtual QString dbusName( ) const = 0;
51  static QString generateServiceName( const QString &name, const pid_t pid );
52 
53 
54  QtDBusApp( );
55  virtual ~QtDBusApp( );
56 
57  // Connects to the DBus server using the name provided (if non-null). Otherwise, the
58  // dbusName() method with the current process ID is used. Returns a boolean which
59  // indicates whether the connection succeeded or not.
60  virtual bool connectToDBus( const QString &dbus_name="" ) = 0;
61 
62  protected:
63 
64  bool connectToDBus( QObject *object, const QString &dbus_name="" );
65 
66  private:
67  static const QString &serviceBase( );
68  static const QString &objectBase( );
69  QString *service_name;
70  QString *object_name;
71  };
72 
73  inline std::string to_string(const QString &other) { return std::string((const char*) other.toLatin1().data()); }
74 
75 }
76 
77 #endif
virtual bool connectToDBus(const QString &dbus_name="")=0
Connects to the DBus server using the name provided (if non-null).
static const QString & serviceBase()
std::string to_string(const QString &other)
Definition: QtDBusApp.h:73
QString * object_name
Definition: QtDBusApp.h:70
static QString generateServiceName(const QString &name, const pid_t pid)
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
virtual ~QtDBusApp()
static const QString & objectBase()
QString * service_name
Definition: QtDBusApp.h:69
QString dbusObjectName(const QString &name, const pid_t pid)
QString dbusServiceName(const QString &name, const pid_t pid)
static bool serviceIsAvailable(const QString &service)
static QDBusConnection connection()
virtual QString dbusName() const =0
static QString serviceOwner(const QString &service)