SingleApplication Class Reference

The SingleApplication class provides an crossplatform interface to detect a running instance, and to send command strings to that instance. More...

#include <singleapplication.h>

List of all members.

Public Slots

bool sendMessage (const QString &message, int timeout=500)

Signals

void messageReceived (const QString &message)

Public Member Functions

 SingleApplication (QObject *parent=0)
 SingleApplication (const QString &key, QObject *parent=0)
virtual ~SingleApplication ()
QString key () const
bool isRunning () const

Static Public Member Functions

static bool isRunning (const QString &key)
static bool sendMessage (const QString &key, const QString &message, int timeout=500)

Private Member Functions

 Q_DISABLE_COPY (SingleApplication)

Private Attributes

SingleApplicationPrivate *const d


Detailed Description

The SingleApplication class provides an crossplatform interface to detect a running instance, and to send command strings to that instance.

The SingleApplication component is basically imitating QtSingleApplication commercial class. Unlike QtSingleApplication the SingleApplication implementation uses Shared Memory to detect a running instance and so-called "Local Sockets" to communicate with it.


Constructor & Destructor Documentation

SingleApplication::SingleApplication ( QObject *  parent = 0  )  [explicit]

Creates a SingleApplication object with the parent parent and the default key.

See also:
key(), QCoreApplication::applicationName()

SingleApplication::SingleApplication ( const QString &  key,
QObject *  parent = 0 
) [explicit]

Creates a SingleApplication object with the parent parent and the key key.

See also:
key()

SingleApplication::~SingleApplication (  )  [virtual]

The destructor destroys the SingleApplication object, but the underlying shared memory and local server are not removed from the system unless application exit.

Note: If another instance of application with the same key is started again it WILL find this instance.


Member Function Documentation

bool SingleApplication::isRunning ( const QString &  key  )  [static]

This is an overloaded static member function, provided for convenience.

Returns true if another instance of this application has started; otherwise returns false.

bool SingleApplication::isRunning (  )  const

Returns true if another instance of this application has started; otherwise returns false.

This function does not find instances of this application that are being run by a different user.

QString SingleApplication::key (  )  const

Returns the key of this single application.

void SingleApplication::messageReceived ( const QString &  message  )  [signal]

This signal is emitted when the current instance receives a message from another instance of this application.

See also:
sendMessage()

SingleApplication::Q_DISABLE_COPY ( SingleApplication   )  [private]

bool SingleApplication::sendMessage ( const QString &  message,
int  timeout = 500 
) [slot]

Tries to send the text message to the currently running instance. The SingleApplication object in the running instance will emit the messageReceived() signal when it receives the message.

This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within timeout milliseconds this function return false.

See also:
messageReceived()

bool SingleApplication::sendMessage ( const QString &  key,
const QString &  message,
int  timeout = 500 
) [static]

This is an overloaded static member function, provided for convenience.

Tries to send the text message to the currently running instance.


Member Data Documentation


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

Generated on Sat Jun 13 13:55:23 2009 for PLCEdit by  doxygen 1.5.9