Adding pre-compile directives to make it compile as a standalone library
diff --git a/model/sync-full-state.cc b/model/sync-full-state.cc
index 1ec8249..dcc4399 100644
--- a/model/sync-full-state.cc
+++ b/model/sync-full-state.cc
@@ -22,7 +22,9 @@
#include "sync-full-state.h"
+#ifndef STANDALONE
#include "ns3/simulator.h"
+#endif // STANDALONE
#include <boost/make_shared.hpp>
#include <boost/lambda/lambda.hpp>
@@ -39,7 +41,7 @@
FullState::FullState ()
- : m_lastUpdated (0)
+// m_lastUpdated is initialized to "not_a_date_time" in STANDALONE mode and to "0" time in NS-3 mode
{
}
@@ -47,10 +49,14 @@
{
}
-ns3::Time
+TimeDurationType
FullState::getTimeFromLastUpdate () const
{
+#ifndef STANDALONE
return ns3::Simulator::Now () - m_lastUpdated;
+#else
+ return boost::posix_time::second_clock::universal_time () - m_lastUpdated;
+#endif // STANDALONE
}
DigestConstPtr
@@ -74,7 +80,12 @@
void
FullState::update (NameInfoConstPtr info, const SeqNo &seq)
{
+#ifndef STANDALONE
m_lastUpdated = ns3::Simulator::Now ();
+#else
+ m_lastUpdated = boost::posix_time::second_clock::universal_time ();
+#endif // STANDALONE
+
m_digest.reset ();
LeafContainer::iterator item = m_leaves.find (*info);
@@ -91,7 +102,12 @@
void
FullState::remove (NameInfoConstPtr info)
{
+#ifndef STANDALONE
m_lastUpdated = ns3::Simulator::Now ();
+#else
+ m_lastUpdated = boost::posix_time::second_clock::universal_time ();
+#endif // STANDALONE
+
m_digest.reset ();
m_leaves.erase (*info);
diff --git a/model/sync-full-state.h b/model/sync-full-state.h
index 479647a..7ec703c 100644
--- a/model/sync-full-state.h
+++ b/model/sync-full-state.h
@@ -23,7 +23,16 @@
#ifndef SYNC_FULL_STATE_H
#define SYNC_FULL_STATE_H
+#ifndef STANDALONE
#include "ns3/nstime.h"
+typedef ns3::Time TimeType;
+typedef ns3::Time TimeDurationType;
+#else
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+typedef boost::posix_time::ptime TimeType;
+typedef boost::posix_time::time_duration TimeDurationType;
+#endif // STANDALONE
+
#include "sync-state.h"
namespace Sync {
@@ -46,7 +55,7 @@
*
* This value can be used to randomize reconciliation waiting time in SyncApp
*/
- ns3::Time
+ TimeDurationType
getTimeFromLastUpdate () const;
/**
@@ -65,7 +74,7 @@
remove (NameInfoConstPtr info);
private:
- ns3::Time m_lastUpdated; ///< @brief Time when state was updated last time
+ TimeType m_lastUpdated; ///< @brief Time when state was updated last time
DigestPtr m_digest;
};
diff --git a/model/sync-name-info.cc b/model/sync-name-info.cc
index d4928cd..8f730e3 100644
--- a/model/sync-name-info.cc
+++ b/model/sync-name-info.cc
@@ -21,7 +21,6 @@
*/
#include "sync-name-info.h"
-#include "ns3/ccnx-name-components.h"
#include <boost/lexical_cast.hpp>
diff --git a/model/sync-ns3-name-info.cc b/model/sync-ns3-name-info.cc
index dc3b561..d1c8e31 100644
--- a/model/sync-ns3-name-info.cc
+++ b/model/sync-ns3-name-info.cc
@@ -20,6 +20,8 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
+#ifndef STANDALONE
+
#include "sync-ns3-name-info.h"
#include "ns3/ccnx-name-components.h"
@@ -89,3 +91,6 @@
} // Sync
+
+#endif
+
diff --git a/model/sync-ns3-name-info.h b/model/sync-ns3-name-info.h
index 3931c5b..b6aea0b 100644
--- a/model/sync-ns3-name-info.h
+++ b/model/sync-ns3-name-info.h
@@ -20,6 +20,8 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
+#ifndef STANDALONE
+
#ifndef SYNC_CCNX_NAME_INFO_H
#define SYNC_CCNX_NAME_INFO_H
@@ -70,3 +72,5 @@
} // Sync
#endif // SYNC_CCNX_NAME_INFO_H
+
+#endif // STANDALONE