- NO FUNCTIONAL CODE CHANGES!!!!
- changed code formating from tabs to spaces and others - used astyle with this option: --style=ansi --indent=spaces=2 -M --pad-oper --unpad-paren --pad-header --align-pointer=name --lineend=linux
This commit is contained in:
parent
b100e9d32a
commit
1c8e43e6d6
76 changed files with 5691 additions and 5492 deletions
|
@ -20,16 +20,16 @@ std::list <std::string> testList;
|
|||
pthread_mutex_t clientMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t clientCondition = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
TestApp::TestApp ()
|
||||
{
|
||||
testList.push_back ("test1");
|
||||
testList.push_back ("testByte");
|
||||
|
||||
TestApp::TestApp()
|
||||
{
|
||||
testList.push_back("test1");
|
||||
testList.push_back("testByte");
|
||||
|
||||
cout << "initialize DBus..." << endl;
|
||||
initDBus ();
|
||||
initDBus();
|
||||
}
|
||||
|
||||
void TestApp::initDBus ()
|
||||
void TestApp::initDBus()
|
||||
{
|
||||
DBus::_init_threading();
|
||||
|
||||
|
@ -39,68 +39,68 @@ void TestApp::initDBus ()
|
|||
|
||||
DBus::Connection conn = DBus::Connection::SessionBus();
|
||||
|
||||
TestAppIntro testComIntro (conn, clientCondition, testResult);
|
||||
TestAppIntro testComIntro(conn, clientCondition, testResult);
|
||||
g_testComIntro = &testComIntro;
|
||||
|
||||
cout << "Start server..." << endl;
|
||||
TestAppIntroProvider testComProviderIntro (conn, &testComIntro);
|
||||
conn.request_name ("DBusCpp.Test.Com.Intro");
|
||||
|
||||
mTestToDBusPipe = dispatcher.add_pipe (TestApp::testHandler, NULL);
|
||||
TestAppIntroProvider testComProviderIntro(conn, &testComIntro);
|
||||
conn.request_name("DBusCpp.Test.Com.Intro");
|
||||
|
||||
mTestToDBusPipe = dispatcher.add_pipe(TestApp::testHandler, NULL);
|
||||
|
||||
cout << "Start client thread..." << endl;
|
||||
pthread_create (&testThread, NULL, TestApp::testThreadRunner, &conn);
|
||||
pthread_create(&testThread, NULL, TestApp::testThreadRunner, &conn);
|
||||
|
||||
dispatcher.enter();
|
||||
|
||||
pthread_join (testThread, NULL);
|
||||
pthread_join(testThread, NULL);
|
||||
|
||||
cout << "Testresult = " << string (testResult ? "OK" : "NOK") << endl;
|
||||
cout << "Testresult = " << string(testResult ? "OK" : "NOK") << endl;
|
||||
}
|
||||
|
||||
void *TestApp::testThreadRunner (void *arg)
|
||||
{
|
||||
for (std::list <std::string>::const_iterator tl_it = testList.begin ();
|
||||
tl_it != testList.end ();
|
||||
void *TestApp::testThreadRunner(void *arg)
|
||||
{
|
||||
for (std::list <std::string>::const_iterator tl_it = testList.begin();
|
||||
tl_it != testList.end();
|
||||
++tl_it)
|
||||
{
|
||||
const string &testString = *tl_it;
|
||||
|
||||
cout << "write to pipe" << endl;
|
||||
mTestToDBusPipe->write (testString.c_str (), testString.length () + 1);
|
||||
mTestToDBusPipe->write(testString.c_str(), testString.length() + 1);
|
||||
|
||||
struct timespec abstime;
|
||||
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
abstime.tv_sec += 1;
|
||||
|
||||
pthread_mutex_lock (&clientMutex);
|
||||
if (pthread_cond_timedwait (&clientCondition, &clientMutex, &abstime) == ETIMEDOUT)
|
||||
|
||||
pthread_mutex_lock(&clientMutex);
|
||||
if (pthread_cond_timedwait(&clientCondition, &clientMutex, &abstime) == ETIMEDOUT)
|
||||
{
|
||||
cout << "client timeout!" << endl;
|
||||
testResult = false;
|
||||
}
|
||||
pthread_mutex_unlock (&clientMutex);
|
||||
}
|
||||
pthread_mutex_unlock(&clientMutex);
|
||||
}
|
||||
|
||||
cout << "leave!" << endl;
|
||||
dispatcher.leave ();
|
||||
|
||||
dispatcher.leave();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TestApp::testHandler (const void *data, void *buffer, unsigned int nbyte)
|
||||
void TestApp::testHandler(const void *data, void *buffer, unsigned int nbyte)
|
||||
{
|
||||
char *str = (char*) buffer;
|
||||
char *str = (char *) buffer;
|
||||
cout << "buffer1: " << str << ", size: " << nbyte << endl;
|
||||
|
||||
|
||||
cout << "run it!" << endl;
|
||||
if (string (str) == "test1")
|
||||
if (string(str) == "test1")
|
||||
{
|
||||
g_testComIntro->test1 ();
|
||||
g_testComIntro->test1();
|
||||
}
|
||||
else if (string (str) == "testByte")
|
||||
else if (string(str) == "testByte")
|
||||
{
|
||||
g_testComIntro->testByte (4);
|
||||
g_testComIntro->testByte(4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,15 @@
|
|||
class TestApp
|
||||
{
|
||||
public:
|
||||
TestApp ();
|
||||
TestApp();
|
||||
|
||||
private:
|
||||
void initDBus ();
|
||||
void initDBus();
|
||||
|
||||
static void testHandler(const void *data, void *buffer, unsigned int nbyte);
|
||||
static void *testThreadRunner(void *arg);
|
||||
static void *testThreadRunnerProvider(void *arg);
|
||||
|
||||
static void testHandler (const void *data, void *buffer, unsigned int nbyte);
|
||||
static void *testThreadRunner (void *arg);
|
||||
static void *testThreadRunnerProvider (void *arg);
|
||||
|
||||
// variables
|
||||
pthread_t testThread;
|
||||
};
|
||||
|
|
|
@ -15,24 +15,24 @@ class TestAppIntro :
|
|||
public DBus::ObjectProxy
|
||||
{
|
||||
public:
|
||||
TestAppIntro (DBus::Connection& connection, pthread_cond_t &condition, bool &testResult) :
|
||||
DBus::ObjectProxy (connection, "/DBusCpp/Test/Com/Intro", "DBusCpp.Test.Com.Intro"),
|
||||
mCondition (condition),
|
||||
mTestResult (testResult)
|
||||
TestAppIntro(DBus::Connection &connection, pthread_cond_t &condition, bool &testResult) :
|
||||
DBus::ObjectProxy(connection, "/DBusCpp/Test/Com/Intro", "DBusCpp.Test.Com.Intro"),
|
||||
mCondition(condition),
|
||||
mTestResult(testResult)
|
||||
{}
|
||||
|
||||
void test1Result ()
|
||||
void test1Result()
|
||||
{
|
||||
cout << "Test1Result" << endl;
|
||||
mTestResult = true;
|
||||
pthread_cond_signal (&mCondition);
|
||||
pthread_cond_signal(&mCondition);
|
||||
}
|
||||
|
||||
void testByteResult (const uint8_t& Byte)
|
||||
void testByteResult(const uint8_t &Byte)
|
||||
{
|
||||
printf ("TestByteResult: %d\n", Byte);
|
||||
printf("TestByteResult: %d\n", Byte);
|
||||
mTestResult = true;
|
||||
pthread_cond_signal (&mCondition);
|
||||
pthread_cond_signal(&mCondition);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -9,27 +9,27 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
class TestAppIntroProvider :
|
||||
class TestAppIntroProvider :
|
||||
public DBusCpp::Test::Com::Intro_adaptor,
|
||||
public DBus::IntrospectableAdaptor,
|
||||
public DBus::ObjectAdaptor
|
||||
{
|
||||
public:
|
||||
TestAppIntroProvider (DBus::Connection& connection, TestAppIntro *testComIntro) :
|
||||
TestAppIntroProvider(DBus::Connection &connection, TestAppIntro *testComIntro) :
|
||||
DBus::ObjectAdaptor(connection, "/DBusCpp/Test/Com/Intro"),
|
||||
mTestAppIntro (testComIntro)
|
||||
mTestAppIntro(testComIntro)
|
||||
{}
|
||||
|
||||
void test1 ()
|
||||
void test1()
|
||||
{
|
||||
cout << "Test1" << endl;
|
||||
mTestAppIntro->test1Result ();
|
||||
mTestAppIntro->test1Result();
|
||||
}
|
||||
|
||||
void testByte (const uint8_t& Byte)
|
||||
void testByte(const uint8_t &Byte)
|
||||
{
|
||||
printf ("TestByte: %d\n", Byte);
|
||||
mTestAppIntro->testByteResult (Byte);
|
||||
printf("TestByte: %d\n", Byte);
|
||||
mTestAppIntro->testByteResult(Byte);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
TestApp testCom;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <dbuscxx_test_generator-client.h>
|
||||
|
||||
int main (int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <dbuscxx_test_generator-server.h>
|
||||
|
||||
int main (int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue