Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

DbusConnection Class Reference

Communication class to facilitate bi-directional communication with Traplas using Dbus. This class offers synchronous and an option to implement asynchronous communications. Asynchronous communications at the moment functions much like synchrounous communications, with the possibility of doing things between dbus_g_proxy_begin_call() and dbus_g_proxy_end_call(). More...

#include <DbusConnection.h>

Inheritance diagram for DbusConnection:

Inheritance graph
[legend]
Collaboration diagram for DbusConnection:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DbusConnection (string nthisapp, string nthatapp, MessageController *ptr)
 ~DbusConnection ()
bool sendMessage (shared_ptr< vector< shared_ptr< string > > > messagebody)

Private Member Functions

void dbus_init ()

Private Attributes

shared_ptr< queue< shared_ptr<
vector< shared_ptr< string > > > > > 
outqueue
pthread_mutex_t mutex
pthread_cond_t cond
pthread_t sendthread
pthread_t receivethread
bool sendthread_run
string thisapp
string thatapp
GMainLoop * mainloop
DBusGProxy * remote_object
MessageControllermsgcontroller

Friends

void * sendThread (void *)
void * receiveThread (void *)
gboolean _send_message (SomeObject *, char **, GError **)

Detailed Description

Communication class to facilitate bi-directional communication with Traplas using Dbus. This class offers synchronous and an option to implement asynchronous communications. Asynchronous communications at the moment functions much like synchrounous communications, with the possibility of doing things between dbus_g_proxy_begin_call() and dbus_g_proxy_end_call().

Definition at line 93 of file DbusConnection.h.


Constructor & Destructor Documentation

DbusConnection::DbusConnection string  nthisapp,
string  nthatapp,
MessageController ptr
 

Constructor. It initialises Dbus and launches the sendThread and receiveThread.

Parameters:
nthisapp The name of this application on the DBus ipc messaging bus.
nthatapp The name of Traplas on the Dbus messaging bus.
ptr A reference to the MessageController.

Definition at line 225 of file DbusConnection.cpp.

References cond, dbus_init(), mainloop, msgcontroller, mutex, outqueue, receiveThread, receivethread, sendThread, sendthread, sendthread_run, thatapp, and thisapp.

Here is the call graph for this function:

DbusConnection::~DbusConnection  ) 
 

Definition at line 248 of file DbusConnection.cpp.

References mainloop, receivethread, remote_object, sendthread, and sendthread_run.


Member Function Documentation

void DbusConnection::dbus_init  )  [private]
 

Initialises Dbus. It connects to the (D)bus, registers the method _send_message on the bus to allow other application on the bus to call it and it creates a remote_object so it can call another function in another application (Traplas in this case).

Definition at line 178 of file DbusConnection.cpp.

References lose_gerror(), mainloop, SomeObject::mc, msgcontroller, remote_object, SOME_TYPE_OBJECT, thatapp, and thisapp.

Referenced by DbusConnection().

Here is the call graph for this function:

bool DbusConnection::sendMessage shared_ptr< vector< shared_ptr< string > > >  messagebody  )  [virtual]
 

Method used by the MessageController to send messages to Traplas. The message is placed in the outgoing queue.

Parameters:
messagebody A reference to the message.

Implements Comm.

Definition at line 264 of file DbusConnection.cpp.

References cond, mutex, and outqueue.


Friends And Related Function Documentation

gboolean _send_message SomeObject ,
char **  ,
GError ** 
[friend]
 

Function called by the glib_mainloop when a message is received. It sends the message to the MessageController.

void* receiveThread void *  mainloop  )  [friend]
 

This thread contains the glib_mainloop which handles the incoming messages from Traplas.

Definition at line 90 of file DbusConnection.cpp.

Referenced by DbusConnection().

void* sendThread void *  att  )  [friend]
 

This thread looks at the outgoing queue and sends messages from that queue to Traplas using Dbus.

Definition at line 100 of file DbusConnection.cpp.

Referenced by DbusConnection().


Member Data Documentation

pthread_cond_t DbusConnection::cond [private]
 

Definition at line 96 of file DbusConnection.h.

Referenced by DbusConnection(), sendMessage(), and sendThread().

GMainLoop* DbusConnection::mainloop [private]
 

Definition at line 106 of file DbusConnection.h.

Referenced by dbus_init(), DbusConnection(), and ~DbusConnection().

MessageController* DbusConnection::msgcontroller [private]
 

Definition at line 114 of file DbusConnection.h.

Referenced by dbus_init(), and DbusConnection().

pthread_mutex_t DbusConnection::mutex [private]
 

Definition at line 95 of file DbusConnection.h.

Referenced by DbusConnection(), sendMessage(), and sendThread().

shared_ptr< queue< shared_ptr< vector< shared_ptr< string > > > > > DbusConnection::outqueue [private]
 

Definition at line 94 of file DbusConnection.h.

Referenced by DbusConnection(), sendMessage(), and sendThread().

pthread_t DbusConnection::receivethread [private]
 

Definition at line 99 of file DbusConnection.h.

Referenced by DbusConnection(), and ~DbusConnection().

DBusGProxy* DbusConnection::remote_object [private]
 

Definition at line 107 of file DbusConnection.h.

Referenced by dbus_init(), sendThread(), and ~DbusConnection().

pthread_t DbusConnection::sendthread [private]
 

Definition at line 98 of file DbusConnection.h.

Referenced by DbusConnection(), and ~DbusConnection().

bool DbusConnection::sendthread_run [private]
 

Definition at line 100 of file DbusConnection.h.

Referenced by DbusConnection(), sendThread(), and ~DbusConnection().

string DbusConnection::thatapp [private]
 

Definition at line 103 of file DbusConnection.h.

Referenced by dbus_init(), and DbusConnection().

string DbusConnection::thisapp [private]
 

Definition at line 102 of file DbusConnection.h.

Referenced by dbus_init(), and DbusConnection().


The documentation for this class was generated from the following files:
Generated on Mon Jun 19 10:22:13 2006 for TraplasVisualisation by  doxygen 1.4.4