Resolve compilation issues after reorganizations
diff --git a/scheduler/interval-generator.h b/scheduler/interval-generator.h
index ce95b5a..027e6ab 100644
--- a/scheduler/interval-generator.h
+++ b/scheduler/interval-generator.h
@@ -32,6 +32,8 @@
class IntervalGenerator
{
public:
+ virtual ~IntervalGenerator () { }
+
virtual double
nextInterval() = 0;
};
diff --git a/scheduler/random-interval-generator.h b/scheduler/random-interval-generator.h
index c0f6276..bf30156 100644
--- a/scheduler/random-interval-generator.h
+++ b/scheduler/random-interval-generator.h
@@ -44,12 +44,33 @@
// e.g. 9 ~ 11, percent = 0.2
// direction shifts the random range; e.g. in the above example, UP would produce a range of
// 10 ~ 12, DOWN of 8 ~ 10, and EVEN of 9 ~ 11
- RandomIntervalGenerator(double interval, double percent, Direction direction = EVEN);
- ~RandomIntervalGenerator(){}
+ RandomIntervalGenerator(double interval, double percent, Direction direction = EVEN)
+ : m_rng(time(NULL))
+ , m_dist(0.0, fractional(percent))
+ , m_random(m_rng, m_dist)
+ , m_direction(direction)
+ , m_percent(percent)
+ , m_interval(interval)
+ { }
+
+ virtual ~RandomIntervalGenerator(){}
virtual double
- nextInterval() _OVERRIDE;
+ nextInterval() _OVERRIDE
+ {
+ double percent = m_random();
+ double interval = m_interval;
+ switch (m_direction)
+ {
+ case UP: interval = m_interval * (1.0 + percent); break;
+ case DOWN: interval = m_interval * (1.0 - percent); break;
+ case EVEN: interval = m_interval * (1.0 - m_percent/2.0 + percent); break;
+ default: break;
+ }
+ return interval;
+ }
+
private:
inline double fractional(double x) { double dummy; return abs(modf(x, &dummy)); }
diff --git a/src/sync-core.cc b/src/sync-core.cc
index a0d7573..c64ce90 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -21,6 +21,9 @@
#include "sync-core.h"
+#include "one-time-task.h"
+#include "random-interval-generator.h"
+
const string SyncCore::RECOVER = "RECOVER";
const double SyncCore::WAIT = 0.05;
const double SyncCore::RANDOM_PERCENT = 0.5;
diff --git a/src/sync-core.h b/src/sync-core.h
index e94a6a9..d6dbd32 100644
--- a/src/sync-core.h
+++ b/src/sync-core.h
@@ -23,8 +23,10 @@
#define SYNC_CORE_H
#include "sync-log.h"
-#include <ccnx-wrapper.h>
-#include <event-scheduler.h>
+#include "ccnx-wrapper.h"
+#include "scheduler.h"
+#include "interval-generator.h"
+
#include <boost/function.hpp>
#include <boost/thread/shared_mutex.hpp>
diff --git a/test/test-event-scheduler.cc b/test/test-event-scheduler.cc
index 41ae4e0..0eacba0 100644
--- a/test/test-event-scheduler.cc
+++ b/test/test-event-scheduler.cc
@@ -1,4 +1,29 @@
-#include "event-scheduler.h"
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "scheduler.h"
+#include "simple-interval-generator.h"
+#include "one-time-task.h"
+#include "periodic-task.h"
+#include "random-interval-generator.h"
#include <boost/test/unit_test.hpp>
#include <map>
diff --git a/test/test-sync-core.cc b/test/test-sync-core.cc
index e91b0f5..1fbe4e6 100644
--- a/test/test-sync-core.cc
+++ b/test/test-sync-core.cc
@@ -1,5 +1,6 @@
#include "sync-core.h"
+
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
diff --git a/wscript b/wscript
index c3b9516..7b62859 100644
--- a/wscript
+++ b/wscript
@@ -81,7 +81,7 @@
target="chronoshare",
features=['cxx'],
source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']),
- use = "BOOST BOOST_FILESYSTEM scheduler ccnx",
+ use = "BOOST BOOST_FILESYSTEM SQLITE3 scheduler ccnx",
includes = "ccnx scheduler src",
)
@@ -95,11 +95,11 @@
includes = "ccnx scheduler src",
)
- # qt = bld (
- # target = "filewatcher",
- # features = "qt4 cxx cxxprogram",
- # defines = "WAF",
- # source = "filesystemwatcher/filesystemwatcher.cpp filesystemwatcher/simpleeventcatcher.cpp filesystemwatcher/main.cpp",
- # includes = "filesystemwatcher src include .",
- # use = "QTCORE QTGUI"
- # )
+ qt = bld (
+ target = "filewatcher",
+ features = "qt4 cxx cxxprogram",
+ defines = "WAF",
+ source = bld.path.ant_glob(['filesystemwatcher/*.cpp']),
+ includes = "filesystemwatcher . ",
+ use = "QTCORE QTGUI"
+ )