nrtb-core team mailing list archive
-
nrtb-core team
-
Mailing list archive
-
Message #00061
[Branch ~fpstovall/nrtb/cpp_common] Rev 25: Several changes:
------------------------------------------------------------
revno: 25
committer: fpstovall@xxxxxxxxx
branch nick: dev
timestamp: Fri 2010-12-31 09:48:07 -0500
message:
Several changes:
1. Removed POCO; it's the developer's responsibility to get the appropriate POCO for their system.
2. Alterations to the common Makefile, confreader, logger, and serializer to clean up the unit test process.
3. Continuing progress on transceiver.
removed:
common/POCO/
common/POCO/poco-1.4.0-all-doc.zip
common/POCO/poco-1.4.0-all.tar.gz
modified:
common/Makefile
common/confreader/Makefile
common/logger/Makefile
common/serializer/serializer.h
common/transceiver/transceiver.cpp
common/transceiver/transceiver.h
--
lp:~fpstovall/nrtb/cpp_common
https://code.launchpad.net/~fpstovall/nrtb/cpp_common
Your team NRTB Core is subscribed to branch lp:~fpstovall/nrtb/cpp_common.
To unsubscribe from this branch go to https://code.launchpad.net/~fpstovall/nrtb/cpp_common/+edit-subscription
=== modified file 'common/Makefile'
--- common/Makefile 2010-12-27 04:21:16 +0000
+++ common/Makefile 2010-12-31 14:48:07 +0000
@@ -34,6 +34,7 @@
doit:
@cd common_rl; make ${action}
+ @cd serializer; make ${action}
@cd point; make ${action}
@cd timer; make ${action}
@cd logger; make ${action}
=== removed directory 'common/POCO'
=== removed file 'common/POCO/poco-1.4.0-all-doc.zip'
Binary files common/POCO/poco-1.4.0-all-doc.zip 2010-12-20 02:30:32 +0000 and common/POCO/poco-1.4.0-all-doc.zip 1970-01-01 00:00:00 +0000 differ
=== removed file 'common/POCO/poco-1.4.0-all.tar.gz'
Binary files common/POCO/poco-1.4.0-all.tar.gz 2010-12-20 02:30:32 +0000 and common/POCO/poco-1.4.0-all.tar.gz 1970-01-01 00:00:00 +0000 differ
=== modified file 'common/confreader/Makefile'
--- common/confreader/Makefile 2010-12-31 14:37:14 +0000
+++ common/confreader/Makefile 2010-12-31 14:48:07 +0000
@@ -40,5 +40,5 @@
g++ -o conftest conftest.o confreader.o ../obj/common.o ../obj/log_setup.o -lPocoFoundation -lPocoUtil
clean:
- @rm -rvf *.o conftest ../include/confreader.h ../obj/confreader.o
+ @rm -rvf *.o conftest ../include/confreader.h ../obj/confreader.o conf_test.log
@echo all objects and executables have been erased.
=== modified file 'common/logger/Makefile'
--- common/logger/Makefile 2010-12-31 12:21:51 +0000
+++ common/logger/Makefile 2010-12-31 14:48:07 +0000
@@ -36,7 +36,7 @@
# g++ -g common_test.cpp -idirafter . -o common_test
clean:
- @rm -vf *.o log_test ../include/log_setup.h ../obj/log_setup.o
+ @rm -vf *.o log_test ../include/log_setup.h ../obj/log_setup.o test_output.log
=== modified file 'common/serializer/serializer.h'
--- common/serializer/serializer.h 2010-12-31 11:46:54 +0000
+++ common/serializer/serializer.h 2010-12-31 14:48:07 +0000
@@ -1,5 +1,5 @@
/***********************************************
- T his file is part of the NRTB project (https://*launchpad.net/nrtb).
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
NRTB is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,19 +18,27 @@
#ifndef nrtb_serializer_h
#define nrtb_serializer_h
-#include <boost/concept_check.hpp>
-
#include <Poco/Mutex.h>
namespace nrtb
{
-
+ /******************************************************************
+ * nrtb::serializer provides a simple, thread safe functor which
+ * returns a series of long long ints increasing by one each time
+ * it's called. By default it starts counting from zero, but may
+ * be started from any arbitrary integer in the range
+ * 0 < x < max long long.
+ * ***************************************************************/
class serializer
{
public:
+ // default constructor; counter starts from zero.
serializer();
+ // constructor which sets the starting number.
serializer(unsigned long long start);
+ // NOP distructor for inheritance safety
~serializer();
+ // functor method, returns the next value in the sequence.
unsigned long long operator ()();
private:
Poco::Mutex lock;
=== modified file 'common/transceiver/transceiver.cpp'
--- common/transceiver/transceiver.cpp 2010-12-30 03:05:40 +0000
+++ common/transceiver/transceiver.cpp 2010-12-31 14:48:07 +0000
@@ -16,5 +16,90 @@
**********************************************/
-#include "transciever.h"
+#include "transceiver.h"
+#include "../include/confreader.h"
+#include <Poco/Mutex.h>
+#include <Poco/ScopedLock.h>
+#include <stringstream>
+
+class serializer_type
+{
+public:
+ unsigned int operator()
+ {
+ Poco::ScopedLock<Poco::Mutex>(lock);
+ return ++counter;
+ };
+private:
+ Poco::Mutex lock;
+ unsigned int counter;
+ serializer_type()
+ {
+ counter = 0;
+ };
+};
+
+serializer_type serializer;
+
+using namespace nrtb;
+
+template <class out, class in>
+transceiver::transceiver(Poco::Net::StreamSocket socket)
+{
+ // get the configuration parameters.
+ conf_reader & config = conf_reader::get_instance();
+ send_time_limit = config.get<unsigned int>("transceiver.send_timeout",2);
+ attempt_recovery = config.get<bool>("transceiver.allow_recovery",true);
+ error_run_limit =
+ config.get<unsigned int>("transceiver.max_consecutive_errors",10);
+ sent_messages.resize(config.get<int>("transceiver.history_size",50));
+ // set up uid
+ uid = serializer();
+ // set up logging
+ std::stringstream s << logname << "_" << uid ;
+ log = Poco::Logger::get(s.str());
+};
+
+template <class out, class in>
+transceiver::~transceiver()
+{
+
+};
+
+template <class out, class in>
+in transceiver::get()
+{
+
+};
+
+template <class out, class in>
+void transceiver::send(out & sendme)
+{
+
+};
+
+template <class out, class in>
+void transceiver::nak_invalid_context(const unsigned long int msg_number)
+{
+
+};
+
+template <class out, class in>
+void transceiver::nak_validation_error(const unsigned long int msg_number)
+{
+
+};
+
+template <class out, class in>
+void transceiver::handle_inbound_nak()
+{
+
+};
+
+template <class out, class in>
+void transceiver::handle_outbound_nak()
+{
+
+};
+
=== modified file 'common/transceiver/transceiver.h'
--- common/transceiver/transceiver.h 2010-12-30 03:05:40 +0000
+++ common/transceiver/transceiver.h 2010-12-31 14:48:07 +0000
@@ -33,8 +33,8 @@
* traffic between NRTB components. This is the only form of
* IPC used by NRTB.
*
- * out_gpb is the channel wrapper for the outbound channel.
- * in_gpb is the channel wrapper for the inbound channel.
+ * out is the channel wrapper for the outbound channel.
+ * in is the channel wrapper for the inbound channel.
*
* The nrtb::confreader singleton will be queried for the
* following parameters:
@@ -47,14 +47,14 @@
* See https://blueprints.launchpad.net/nrtb/+spec/icp-spec for
* specification this class implements.
* ***************************************************************/
- template <class out_gpb, class in_gpb>
+ template <class out, class in>
class transceiver
{
public:
/// outbound messages will be of this type
- typedef out_gpb outbound_type;
+ typedef outbound_type out;
/// inbound messages will be of this type.
- typedef in_gpb inbound_type;
+ typedef inbound_type in;
/**************************************************************
* Creates the transceiver and associates it with a provided
* socket. Once created this class assumes it uniquely owns the
@@ -70,12 +70,12 @@
* gets the next message from the socket. If no messages are
* ready, blocks util one arrives.
* ***********************************************************/
- inbound_type & get();
+ in & get();
/**************************************************************
* Sends a message over the socket and adds it to the
* sent_messages buffer in case it's needed for error recovery.
* ***********************************************************/
- void send(outbound_type & sendme);
+ void send(out & sendme);
/**************************************************************
* Called by the data consumer when an inbound message was
* not valid in the current application context. msg_number
@@ -102,6 +102,7 @@
// Thrown if the socket is closed due to too many errors in a row
POCO_DECLARE_EXCEPTION(transceiver, consecutive_error_overrun, general_exception)
protected:
+ unsigned in uid;
const std::string logname = "transceiver:";
unsigned int send_time_limit;
bool attempt_recovery;
@@ -114,7 +115,7 @@
Poco::Net::SocketStream stream;
// buffer to hold previously sent messages; required for
// error recovery.
- boost::circular_buffer<outbound_type> sent_messages;
+ boost::circular_buffer<out> sent_messages;
// fence post for recovery efforts, zero if none in play
unsigned long long nak_fence_post;
// These methods implment actual nak recovery.
@@ -124,4 +125,4 @@
} // namespace nrtb
-#endif //nrtb_transceiver_h
\ No newline at end of file
+#endif //nrtb_transceiver_h//
\ No newline at end of file