get rid of publisher and fetcher
modify SyncAppSocket API
modify SyncLogic API
Tweak SeqNo
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 3bae752..b44c2e8 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -279,6 +279,7 @@
DiffState diff;
istringstream ss (dataBuffer);
ss >> diff;
+ vector<MissingDataInfo> v;
BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
{
DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
@@ -297,7 +298,12 @@
if (inserted || updated)
{
diffLog->update (info, seq);
- m_onUpdate (info->toString (), seq, oldSeq);
+ //m_onUpdate (info->toString (), seq, oldSeq);
+ MissingDataInfo mdi;
+ mdi.prefix = info->toString();
+ mdi.low = oldSeq;
+ mdi.high = seq;
+ v.push_back(mdi);
}
}
else if (diffLeaf->getOperation() == REMOVE)
@@ -314,6 +320,11 @@
}
}
+ if (!v.empty())
+ {
+ m_onUpdate(v);
+ }
+
insertToDiffLog (diffLog);
}
catch (Error::SyncXmlDecodingFailure &e)
@@ -470,7 +481,7 @@
bind (&SyncLogic::sendSyncInterest, this),
REEXPRESSING_INTEREST);
- m_ccnxHandle->sendInterest (os.str (),
+ m_ccnxHandle->sendInterestForString (os.str (),
bind (&SyncLogic::respondSyncData, this, _1, _2));
}
@@ -492,7 +503,7 @@
REEXPRESSING_RECOVERY_INTEREST);
}
- m_ccnxHandle->sendInterest (os.str (),
+ m_ccnxHandle->sendInterestForString (os.str (),
bind (&SyncLogic::respondSyncData, this, _1, _2));
}
@@ -502,7 +513,7 @@
{
_LOG_TRACE (">> D " << name);
// sending
- m_ccnxHandle->publishData (name,
+ m_ccnxHandle->publishStringData (name,
lexical_cast<string> (*state),
m_syncResponseFreshness); // in NS-3 it doesn't have any effect... yet
diff --git a/model/sync-logic.h b/model/sync-logic.h
index e205fc0..daa6e2f 100644
--- a/model/sync-logic.h
+++ b/model/sync-logic.h
@@ -50,6 +50,12 @@
namespace Sync {
+struct MissingDataInfo {
+ std::string prefix;
+ SeqNo low;
+ SeqNo high;
+};
+
/**
* \ingroup sync
* @brief A wrapper for SyncApp, which handles ccnx related things (process
@@ -61,7 +67,8 @@
#endif
{
public:
- typedef boost::function< void ( const std::string &/*prefix*/, const SeqNo &/*newSeq*/, const SeqNo &/*oldSeq*/ ) > LogicUpdateCallback;
+ //typedef boost::function< void ( const std::string &/*prefix*/, const SeqNo &/*newSeq*/, const SeqNo &/*oldSeq*/ ) > LogicUpdateCallback;
+ typedef boost::function< void (const std::vector<MissingDataInfo> & ) > LogicUpdateCallback;
typedef boost::function< void ( const std::string &/*prefix*/ ) > LogicRemoveCallback;
/**
diff --git a/model/sync-seq-no.h b/model/sync-seq-no.h
index 5dbe490..4f84482 100644
--- a/model/sync-seq-no.h
+++ b/model/sync-seq-no.h
@@ -122,6 +122,26 @@
}
bool
+ operator <= (const SeqNo &seq) const
+ {
+ return m_session <= seq.m_session || (m_session == seq.m_session && m_seq <= seq.m_seq);
+ }
+
+ SeqNo &
+ operator ++ ()
+ {
+ m_seq ++;
+ return *this;
+ }
+
+ SeqNo &
+ operator --()
+ {
+ m_seq --;
+ return *this;
+ }
+
+ bool
isValid () const
{
return m_valid;