Time to get rid of the horrible coding style

This commit is contained in:
pd 2008-08-01 18:31:43 +02:00
parent 534ee610d8
commit efc594f888
53 changed files with 1137 additions and 1136 deletions

View file

@ -9,15 +9,15 @@
using namespace std;
static const char* ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char* ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
EchoClient::EchoClient( DBus::Connection& connection, const char* path, const char* name )
EchoClient::EchoClient(DBus::Connection &connection, const char *path, const char *name)
: DBus::ObjectProxy(connection, path, name)
{
}
void EchoClient::Echoed( const DBus::Variant& value )
void EchoClient::Echoed(const DBus::Variant &value)
{
cout << "!";
}
@ -26,13 +26,13 @@ void EchoClient::Echoed( const DBus::Variant& value )
* For some strange reason, libdbus frequently dies with an OOM
*/
static const int THREADS = 16;
static const int THREADS = 3;
static bool spin = true;
void* greeter_thread( void* arg )
void *greeter_thread(void *arg)
{
DBus::Connection* conn = reinterpret_cast<DBus::Connection*>(arg);
DBus::Connection *conn = reinterpret_cast<DBus::Connection *>(arg);
EchoClient client(*conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
@ -40,7 +40,7 @@ void* greeter_thread( void* arg )
snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
for(int i = 0; i < 100 && spin; ++i)
for (int i = 0; i < 30 && spin; ++i)
{
cout << client.Hello(idstr) << endl;
}
@ -52,7 +52,7 @@ void* greeter_thread( void* arg )
DBus::BusDispatcher dispatcher;
void niam( int sig )
void niam(int sig)
{
spin = false;
@ -76,7 +76,7 @@ int main()
pthread_t threads[THREADS];
for(int i = 0; i < THREADS; ++i)
for (int i = 0; i < THREADS; ++i)
{
pthread_create(threads+i, NULL, greeter_thread, &conn);
}
@ -85,7 +85,7 @@ int main()
cout << "terminating" << endl;
for(int i = 0; i < THREADS; ++i)
for (int i = 0; i < THREADS; ++i)
{
pthread_join(threads[i], NULL);
}

View file

@ -11,9 +11,9 @@ class EchoClient
{
public:
EchoClient( DBus::Connection& connection, const char* path, const char* name );
EchoClient(DBus::Connection &connection, const char *path, const char *name);
void Echoed( const DBus::Variant& value );
void Echoed(const DBus::Variant &value);
};
#endif//__DEMO_ECHO_CLIENT_H

View file

@ -5,10 +5,10 @@
#include <stdio.h>
#include <limits.h>
static const char* ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char* ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
EchoServer::EchoServer( DBus::Connection& connection )
EchoServer::EchoServer(DBus::Connection &connection)
: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH)
{
}
@ -18,23 +18,24 @@ DBus::Int32 EchoServer::Random()
return rand();
}
DBus::String EchoServer::Hello( const DBus::String& name )
DBus::String EchoServer::Hello(const DBus::String &name)
{
sleep (10);
return "Hello " + name + "!";
}
DBus::Variant EchoServer::Echo( const DBus::Variant& value )
DBus::Variant EchoServer::Echo(const DBus::Variant &value)
{
this->Echoed(value);
return value;
}
std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file )
std::vector< DBus::Byte > EchoServer::Cat(const DBus::String &file)
{
FILE* handle = fopen(file.c_str(), "rb");
FILE *handle = fopen(file.c_str(), "rb");
if(!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
DBus::Byte buff[1024];
@ -45,11 +46,11 @@ std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file )
return std::vector< DBus::Byte > (buff, buff + nread);
}
DBus::Int32 EchoServer::Sum( const std::vector<DBus::Int32>& ints )
DBus::Int32 EchoServer::Sum(const std::vector<DBus::Int32>& ints)
{
DBus::Int32 sum = 0;
for(size_t i = 0; i < ints.size(); ++i) sum += ints[i];
for (size_t i = 0; i < ints.size(); ++i) sum += ints[i];
return sum;
}
@ -69,7 +70,7 @@ std::map< DBus::String, DBus::String > EchoServer::Info()
DBus::BusDispatcher dispatcher;
void niam( int sig )
void niam(int sig)
{
dispatcher.leave();
}

View file

@ -11,17 +11,17 @@ class EchoServer
{
public:
EchoServer( DBus::Connection& connection );
EchoServer(DBus::Connection &connection);
DBus::Int32 Random();
DBus::String Hello( const DBus::String & name );
DBus::String Hello(const DBus::String &name);
DBus::Variant Echo( const DBus::Variant & value );
DBus::Variant Echo(const DBus::Variant &value);
std::vector< DBus::Byte > Cat( const DBus::String & file );
std::vector< DBus::Byte > Cat(const DBus::String &file);
DBus::Int32 Sum( const std::vector<DBus::Int32> & ints );
DBus::Int32 Sum(const std::vector<DBus::Int32> & ints);
std::map< DBus::String, DBus::String > Info();
};