separate ccnx handle for sync and app data
diff --git a/model/sync-app-socket.cc b/model/sync-app-socket.cc
index fb6779d..2f1d174 100644
--- a/model/sync-app-socket.cc
+++ b/model/sync-app-socket.cc
@@ -29,13 +29,12 @@
{
SyncAppSocket::SyncAppSocket (const string &syncPrefix, CcnxWrapper::DataCallback dataCallback)
- : m_ccnxHandle (new CcnxWrapper())
- , m_fetcher (m_ccnxHandle, dataCallback)
- , m_publisher (m_ccnxHandle)
+ : m_appHandle (new CcnxWrapper())
+ , m_fetcher (m_appHandle, dataCallback)
+ , m_publisher (m_appHandle)
, m_syncLogic (syncPrefix,
bind (&AppDataFetch::onUpdate, m_fetcher, _1, _2, _3),
- bind (&AppDataFetch::onRemove, m_fetcher, _1),
- m_ccnxHandle)
+ bind (&AppDataFetch::onRemove, m_fetcher, _1))
{
}
diff --git a/model/sync-app-socket.h b/model/sync-app-socket.h
index 465cc5c..7c01cf2 100644
--- a/model/sync-app-socket.h
+++ b/model/sync-app-socket.h
@@ -76,7 +76,7 @@
void start() {m_syncLogic.start();}
private:
- CcnxWrapperPtr m_ccnxHandle;
+ CcnxWrapperPtr m_appHandle;
AppDataFetch m_fetcher;
AppDataPublish m_publisher;
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 7f24e04..c143498 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -37,12 +37,11 @@
SyncLogic::SyncLogic (const std::string &syncPrefix,
LogicUpdateCallback onUpdate,
- LogicRemoveCallback onRemove,
- CcnxWrapperPtr ccnxHandle)
+ LogicRemoveCallback onRemove)
: m_syncPrefix (syncPrefix)
, m_onUpdate (onUpdate)
+ , m_ccnxHandle(new CcnxWrapper())
, m_onRemove (onRemove)
- , m_ccnxHandle (ccnxHandle)
, m_randomGenerator (static_cast<unsigned int> (std::time (0)))
, m_rangeUniformRandom (m_randomGenerator, uniform_int<> (20,100))
{
diff --git a/model/sync-logic.h b/model/sync-logic.h
index 547c01f..780c515 100644
--- a/model/sync-logic.h
+++ b/model/sync-logic.h
@@ -26,6 +26,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/random.hpp>
+#include <memory>
#include "sync-ccnx-wrapper.h"
#include "sync-interest-table.h"
@@ -59,8 +60,7 @@
*/
SyncLogic (const std::string &syncPrefix,
LogicUpdateCallback onUpdate,
- LogicRemoveCallback onRemove,
- CcnxWrapperPtr ccnxHandle);
+ LogicRemoveCallback onRemove);
~SyncLogic ();
@@ -121,7 +121,7 @@
std::string m_syncPrefix;
LogicUpdateCallback m_onUpdate;
LogicRemoveCallback m_onRemove;
- CcnxWrapperPtr m_ccnxHandle;
+ std::auto_ptr<CcnxWrapper> m_ccnxHandle;
Scheduler m_delayedChecksScheduler;
diff --git a/test/test_scheduler.cc b/test/test_scheduler.cc
index 9a72251..2871d95 100644
--- a/test/test_scheduler.cc
+++ b/test/test_scheduler.cc
@@ -124,7 +124,7 @@
BOOST_AUTO_TEST_CASE (SyncLogicTest)
{
SyncLogic *logic = 0;
- BOOST_CHECK_NO_THROW (logic = new SyncLogic ("/prefix", funcUpdate, funcRemove, make_shared<CcnxWrapper> ()));
+ BOOST_CHECK_NO_THROW (logic = new SyncLogic ("/prefix", funcUpdate, funcRemove));
Scheduler &scheduler = logic->getScheduler ();
BOOST_CHECK_EQUAL (scheduler.getEventsSize (), 0);