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
diff --git a/wscript b/wscript
index eee1d9a..700e955 100644
--- a/wscript
+++ b/wscript
@@ -9,6 +9,7 @@
conf.load("compiler_cxx")
conf.check_cfg(atleast_pkgconfig_version='0.20')
conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL')
+ conf.define ('STANDALONE', 1)
conf.check_tool('boost')
conf.check_boost(lib='signals filesystem iostreams regex')
@@ -16,39 +17,39 @@
conf.check_boost(lib='signals filesystem iostreams regex', libpath="/usr/lib64")
def build (bld):
- module = bld.new_task_gen(features=['cxx', 'cxxshlib'])
+ module = bld.new_task_gen(target="sync", features=['cxx', 'cxxshlib'])
module.source = bld.path.ant_glob(['model/*.cc',
'helper/*.cc'])
module.uselib = 'BOOST BOOST_IOSTREAMS SSL'
-def build_ns3 (bld):
- deps = ['core', 'network', 'NDNabstraction']
- if bld.env['ENABLE_PYTHON_BINDINGS']:
- deps.append ('visualizer')
+# def build_ns3 (bld):
+# deps = ['core', 'network', 'NDNabstraction']
+# if bld.env['ENABLE_PYTHON_BINDINGS']:
+# deps.append ('visualizer')
- module = bld.create_ns3_module ('sync', deps)
- module.uselib = 'BOOST BOOST_IOSTREAMS SSL'
+# module = bld.create_ns3_module ('sync', deps)
+# module.uselib = 'BOOST BOOST_IOSTREAMS SSL'
- # tests = bld.create_ns3_module_test_library('sync')
- # tests.source = [
- # 'test/sync-test-suite.cc',
- # ]
+# # tests = bld.create_ns3_module_test_library('sync')
+# # tests.source = [
+# # 'test/sync-test-suite.cc',
+# # ]
- headers = bld.new_task_gen(features=['ns3header'])
- headers.module = 'sync'
- headers.source = [
- 'model/sync-app.h',
- ]
+# headers = bld.new_task_gen(features=['ns3header'])
+# headers.module = 'sync'
+# headers.source = [
+# 'model/sync-app.h',
+# ]
- # if not bld.env['ENABLE_NDN_ABSTRACT']:
- # bld.env['MODULES_NOT_BUILT'].append('NDNabstraction')
- # return
+# # if not bld.env['ENABLE_NDN_ABSTRACT']:
+# # bld.env['MODULES_NOT_BUILT'].append('NDNabstraction')
+# # return
- module.source = bld.path.ant_glob(['model/*.cc',
- 'helper/*.cc'])
+# module.source = bld.path.ant_glob(['model/*.cc',
+# 'helper/*.cc'])
- # if bld.env.ENABLE_EXAMPLES:
- # bld.add_subdirs('examples')
+# # if bld.env.ENABLE_EXAMPLES:
+# # bld.add_subdirs('examples')
- # bld.ns3_python_bindings()
+# # bld.ns3_python_bindings()