Commit 24a1c504 authored by Stanislav Bohm's avatar Stanislav Bohm

ENH: Moved from C++14 to C++11 (to support older compilers)

parent e12fe38c
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall")
add_library(libloom
data/externfile.cpp
data/externfile.h
......@@ -27,6 +27,7 @@ add_library(libloom
loomcomm.pb.cc
loomplan.pb.h
loomplan.pb.cc
compat.h
log.h
log.cpp
types.h
......
#ifndef LIBLOOM_COMPAT_H
#define LIBLOOM_COMPAT_H
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
namespace std {
template<class T> struct _Unique_if {
typedef unique_ptr<T> _Single_object;
};
template<class T> struct _Unique_if<T[]> {
typedef unique_ptr<T[]> _Unknown_bound;
};
template<class T, size_t N> struct _Unique_if<T[N]> {
typedef void _Known_bound;
};
template<class T, class... Args>
typename _Unique_if<T>::_Single_object
make_unique(Args&&... args) {
return unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template<class T>
typename _Unique_if<T>::_Unknown_bound
make_unique(size_t n) {
typedef typename remove_extent<T>::type U;
return unique_ptr<T>(new U[n]());
}
template<class T, class... Args>
typename _Unique_if<T>::_Known_bound
make_unique(Args&&...) = delete;
}
#endif // LIBLOOM_COMPAT_H
......@@ -3,7 +3,7 @@
#include "utils.h"
#include "loomcomm.pb.h"
#include "compat.h"
using namespace loom;
......
......@@ -3,6 +3,7 @@
#include "data.h"
#include "task.h"
#include "compat.h"
#include<uv.h>
......
......@@ -34,7 +34,7 @@ public:
return task->get_id();
}
const auto& get_inputs() {
const std::vector<Id>& get_inputs() {
return task->get_inputs();
}
......
......@@ -2,6 +2,7 @@
#define LIBLOOM_UNPACKING_H
#include "data.h"
#include "compat.h"
#include <memory>
......
......@@ -233,7 +233,7 @@ void Worker::register_connection(InterConnection &connection)
auto i = std::find_if(
nonregistered_connections.begin(),
nonregistered_connections.end(),
[&](auto& p) { return p.get() == &connection; });
[&](std::unique_ptr<InterConnection>& p) { return p.get() == &connection; });
assert(i != nonregistered_connections.end());
c = std::move(*i);
nonregistered_connections.erase(i);
......@@ -246,7 +246,7 @@ void Worker::unregister_connection(InterConnection &connection)
auto i = std::find_if(
nonregistered_connections.begin(),
nonregistered_connections.end(),
[&](auto& p) { return p.get() == &connection; });
[&](std::unique_ptr<InterConnection>& p) { return p.get() == &connection; });
assert(i != nonregistered_connections.end());
nonregistered_connections.erase(i);
return;
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall")
add_library(loom-server-lib OBJECT
server.cpp
server.h
......
......@@ -2,6 +2,7 @@
#include "dummyworker.h"
#include "server.h"
#include <libloom/compat.h>
#include <libloom/utils.h>
#include <libloom/log.h>
#include <libloom/loomcomm.pb.h>
......
......@@ -3,6 +3,7 @@
#include "clientconn.h"
#include "server.h"
#include "libloom/compat.h"
#include "libloom/log.h"
#include "libloom/loomcomm.pb.h"
......
#include "server.h"
#include "resendtask.h"
#include "libloom/compat.h"
#include "libloom/utils.h"
#include "libloom/log.h"
#include "libloom/loomcomm.pb.h"
......@@ -34,7 +35,7 @@ void Server::remove_worker_connection(WorkerConnection &conn)
auto i = std::find_if(
connections.begin(),
connections.end(),
[&](auto& p) { return p.get() == &conn; } );
[&](std::unique_ptr<WorkerConnection>& p) { return p.get() == &conn; } );
assert(i != connections.end());
connections.erase(i);
}
......@@ -58,7 +59,7 @@ void Server::remove_freshconnection(FreshConnection &conn)
auto i = std::find_if(
fresh_connections.begin(),
fresh_connections.end(),
[&](auto& p) { return p.get() == &conn; } );
[&](std::unique_ptr<FreshConnection>& p) { return p.get() == &conn; } );
assert(i != fresh_connections.end());
fresh_connections.erase(i);
}
......
......@@ -37,7 +37,7 @@ public:
return task_manager;
}
auto& get_connections() {
const std::vector<std::unique_ptr<WorkerConnection>>& get_connections() {
return connections;
}
......
#include "taskmanager.h"
#include "server.h"
#include "libloom/compat.h"
#include "libloom/loomplan.pb.h"
#include "libloom/log.h"
......
......@@ -75,7 +75,7 @@ public:
owners.push_back(wconn);
}
const auto& get_owners() const {
const std::vector<WorkerConnection*>& get_owners() const {
return owners;
}
......@@ -88,7 +88,7 @@ public:
state = FINISHED;
}
const auto& get_inputs() {
const Vector& get_inputs() {
return inputs;
}
......
......@@ -24,7 +24,7 @@ public:
void send_task(TaskNode *task);
void send_data(loom::Id id, const std::string &address, bool with_size);
auto& get_tasks() {
std::unordered_map<loom::Id, TaskNode*>& get_tasks() {
return tasks;
}
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall")
add_executable(loom-worker
loomrun.pb.cc
loomrun.pb.h
......
#include "basictasks.h"
#include "libloom/compat.h"
#include "libloom/databuilder.h"
#include "libloom/data/rawdata.h"
#include "libloom/data/externfile.h"
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall")
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${PROJECT_SOURCE_DIR}/tests)
......
#include "catch/catch.hpp"
#include <uv.h>
#include "src/server/server.h"
#include "libloom/compat.h"
#include "libloom/loomplan.pb.h"
#include <uv.h>
typedef std::unordered_set<TaskNode*> TaskSet;
typedef
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment