From afc7ee4c5aa15b8c1f22d4dc1d889918f7a41ca0 Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Mon, 4 Oct 2010 01:09:17 +0300 Subject: [PATCH] added .gitignore and started converting to use libplp for debug --- .gitignore | 2 ++ autobuild.sh | 3 ++- configure.ac | 2 +- src/plpbus/BusClient.cc | 27 ++++++++++++++------------- src/plpbus/BusMessage.cc | 20 +++++++++++--------- src/plpbus/OrbServerImpl.cc | 24 +++++++++++++----------- 6 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54c1281 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +m4 +autom4te.cache diff --git a/autobuild.sh b/autobuild.sh index c318591..bb273c0 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -1,11 +1,12 @@ #!/bin/sh +export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig if ! [ -e Makefile ] ; then echo "No Makefile available, generating it." libtoolize --automake --force --copy autoreconf --force --install - PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --prefix=/usr/local + ./configure --prefix=/usr/local else echo "Makefile found, no need to generate it." fi diff --git a/configure.ac b/configure.ac index e3655ff..02b65ca 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ AM_PROG_CC_C_O PKG_PROG_PKG_CONFIG() -PKG_CHECK_MODULES(SRC, omniDynamic4) +PKG_CHECK_MODULES(SRC, omniDynamic4 libplp) AC_SUBST(SRC_CFLAGS) AC_SUBST(SRC_LIBS) diff --git a/src/plpbus/BusClient.cc b/src/plpbus/BusClient.cc index 8c93e1d..b69787b 100644 --- a/src/plpbus/BusClient.cc +++ b/src/plpbus/BusClient.cc @@ -5,6 +5,8 @@ * Author: lamikr */ +#include + #include "BusClient.hh" #include "BusMessageInternal.hh" @@ -54,7 +56,7 @@ class OrbClientImpl : public virtual POA_plpbus_orb::OrbClient BusClient::BusClient() { - cout << "created" << endl; + log_debug("created\n");; _orb = NULL; _poa = NULL; } @@ -65,7 +67,7 @@ BusClient::~BusClient() _orb->destroy(); _orb = NULL; } - cout << "destroyed" << endl; + log_debug("destroyed\n"); } int BusClient::init(const char *server_name) { @@ -75,10 +77,10 @@ int BusClient::init(const char *server_name) { argc = 0; argv = NULL; - cout << "init() started" << endl; + log_info("init() started\n");; _orb = CORBA::ORB_init(argc, argv); if (_orb != NULL) { - cout << "ORB_init() done, finding server: " << server_name << endl; + log_debug("ORB_init() done, finding server: %s\n", server_name); server_obj = find_server_object_by_name(_orb, CONST_CONTEXT_NAME__PLPBUS, CONST_CONTEXT_KIND__PLPBUS, @@ -86,22 +88,21 @@ int BusClient::init(const char *server_name) { CONST_CONTEXT_NAME__PLPBUS); if (CORBA::is_nil(server_obj) == false) { _server = plpbus_orb::OrbServer::_narrow(server_obj); - cout << "Server object found: " << server_name << endl; + log_info("Server object found: %s", server_name); } else { - cerr << "Could not find server object: " << server_name << endl; + log_error("Could not find server object: %s\n", server_name); } } return 0; } int BusClient::add_client_listener(IClientListener *listener_param) { - cout << "add_client_listener() started" << endl; + log_debug("add_client_listener() started\n"); if (_poa == NULL) { OrbClientImpl *client_cb; PortableServer::ObjectId_var oid; - cout << "register_callback() 1" << endl; _poa = create_poa(_orb); client_cb = new OrbClientImpl(listener_param); oid = _poa->activate_object(client_cb); @@ -109,7 +110,7 @@ int BusClient::add_client_listener(IClientListener *listener_param) { client_cb->_remove_ref(); _server->add_event_listener(_client, "event_message", CONST_DEFAULT_EVENT_INTERVAL); } - cout << "add_client_listener() done" << endl; + log_debug("add_client_listener() done\n"); return 0; } @@ -226,17 +227,17 @@ CORBA::Object_var BusClient::find_server_object_by_name(CORBA::ORB_var orb_param ret_val = ns_root_context->resolve(service_data); } catch(CosNaming::NamingContext::NotFound& ex) { - cerr << "Could not find service from the name server. " << endl; + log_error("Could not find service from the name server.\n"); } catch(CORBA::TRANSIENT& ex) { - cerr << "Could not find service from the name server. " << endl; + log_error("Could not find service from the name server.\n"); } catch(CORBA::SystemException& ex) { - cerr << "Could not find service from the name server, unknown error." << endl; + log_error("Could not find service from the name server, unknown error.\n"); } } else { - cerr << "Could not find naming service. " << endl; + log_error("Could not find naming service.\n"); } return ret_val; } diff --git a/src/plpbus/BusMessage.cc b/src/plpbus/BusMessage.cc index 2e52f1f..bc05f07 100644 --- a/src/plpbus/BusMessage.cc +++ b/src/plpbus/BusMessage.cc @@ -5,6 +5,8 @@ * Author: lamikr */ +#include + #include "BusMessage.hh" using namespace std; @@ -169,14 +171,14 @@ void BusMessage::printout_dataitem(long index, plpbus_orb::DataItem *item) { const char *val; item->value >>= val; - cout << " [" << index << "] name: " << item->name << ", value: " << val << endl; + log_debug(" [%d], value: %s\n", index, val); } break; case tk_long: { long val; item->value >>= val; - cout << " [" << index << "] name: " << item->name << ", value: " << val << endl; + log_debug(" [%d], value: %ld\n", index, val); //val_str = strdup("long"); } break; @@ -184,7 +186,7 @@ void BusMessage::printout_dataitem(long index, plpbus_orb::DataItem *item) { { double val; item->value >>= val; - cout << " [" << index << "] name: " << item->name << ", value: " << val << endl; + log_debug(" [%d], value: %f\n", index, val); //val_str = strdup("double"); } break; @@ -192,20 +194,20 @@ void BusMessage::printout_dataitem(long index, plpbus_orb::DataItem *item) { { float val; item->value >>= val; - cout << " [" << index << "] name: " << item->name << ", value: " << val << endl; + log_debug(" [%d] name: %s, value: %f\n", index, val); //val_str = strdup("float"); } break; default: - cout << " [" << index << "] name: " << item->name << ", value unknown. " << endl; + log_error(" [%d] name, value unknown\n", index); } } else { - cout << " [" << index << "] Invalid dataItem, name or value NULL." << endl; + log_error(" [%d] Invalid data item name name or value\n", index); } } else { - cout << " [" << index << "] dataItem NULL." << endl; + log_error(" [%d] dataItem NULL.", index); } } @@ -214,10 +216,10 @@ void BusMessage::printout() { DataItem item; count = _dataItemSeq.length(); - cout << "BusMessage.printout(): parameter count: " << count << endl; + log_debug("BusMessage.printout(): parameter count: %l\n", count); for (long ii = 0; ii < count; ii++) { item = _dataItemSeq[ii]; printout_dataitem(ii, &item); } - cout << "BusMessage.printout() done" << endl; + log_debug("BusMessage.printout() done\n");; } diff --git a/src/plpbus/OrbServerImpl.cc b/src/plpbus/OrbServerImpl.cc index d12846e..fc0eecc 100644 --- a/src/plpbus/OrbServerImpl.cc +++ b/src/plpbus/OrbServerImpl.cc @@ -5,6 +5,8 @@ * Author: lamikr */ +#include + #include "ServerEventThread.hh" #include "OrbServerImpl.hh" #include "ClientServerCommon.hh" @@ -28,7 +30,7 @@ OrbServerImpl::OrbServerImpl() OrbServerImpl::~OrbServerImpl() { - cout << "OrbServerImpl destroyed." << endl; + log_info("OrbServerImpl destroyed.\n"); } void OrbServerImpl::send_message_and_request_response(OrbClient_ptr response_listener_param, @@ -39,16 +41,16 @@ void OrbServerImpl::send_message_and_request_response(OrbClient_ptr response_lis msg_rsp = NULL; if (CORBA::is_nil(response_listener_param) == false) { if (_listener != NULL) { - cout << "send_message_and_request_response(): " << msg_req << ", server_callback != NULL" << endl; + log_debug("send_message_and_request_response(): %s, server callback != NULL\n", msg_req); _listener->request_received(msg_req, &msg_rsp); response_listener_param->receive_response_message(msg_rsp); } else { - cout << "send_message_and_request_response() error! " << msg_req << ", server_callback == NULL" << endl; + log_error("send_message_and_request_response() error, server callback == NULL\n"); } } else { - cerr << "invalid callback object received.\n"; + log_error("invalid callback object received.\n"); } } @@ -59,11 +61,11 @@ char *OrbServerImpl::send_message_and_wait_response(const char* msg_req_param, : err_flg = 0; msg_rsp = NULL; if (_listener != NULL) { - cout << "send_message_and_wait_response(): " << msg_req_param << ", server_callback != NULL" << endl; + log_debug("send_message_and_wait_response(): %s, server_callback != NULL\n", msg_req_param); _listener->request_received(msg_req_param, &msg_rsp); } else { - cout << "send_message_and_wait_response() error! " << msg_req_param << ", server_callback == NULL" << endl; + log_error("send_message_and_wait_response() error, server callback == NULL\n"); msg_rsp = strdup(msg_req_param); err_flg = -1; } @@ -79,17 +81,17 @@ void OrbServerImpl::send_dataitem_message_and_request_response(OrbClient_ptr res if (CORBA::is_nil(response_listener_param) == false) { if (_listener != NULL) { msg_req = new BusMessageInternal(msg_req_param); - cout << "send_dataitem_message_and_request_response(), server_callback != NULL" << endl; - cout << "msg_req:" << endl; + log_debug("send_dataitem_message_and_request_response(), server_callback != NULL\n"); + log_debug("msg_req:\n"); msg_req->printout(); msg_rsp = NULL; _listener->request_received(msg_req, &msg_rsp); - cout << "msg_rsp length:" << msg_rsp->_dataItemSeq.length() << endl; + log_debug("msg_rsp length: %d\n", msg_rsp->_dataItemSeq.length()); msg_rsp->printout(); response_listener_param->receive_response_dataitem_sequence(msg_rsp->_dataItemSeq); } else { - cout << "send_dataitem_message_and_request_response() error, server_callback == NULL" << endl; + log_error("send_dataitem_message_and_request_response() error, server_callback == NULL\n"); } } } @@ -115,7 +117,7 @@ void OrbServerImpl::add_event_listener(OrbClient_ptr client_param, ServerEventThread *srvr_thread; if (CORBA::is_nil(client_param) == false) { - cout << "add_event_listener()" << endl; + log_debug("add_event_listener()\n"); server_thread_mutex.lock(); _server_thread_count++; server_thread_mutex.unlock(); -- 2.41.1