aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--entityx/3rdparty/simplesignal.h17
-rw-r--r--entityx/Entity.h5
-rw-r--r--entityx/Event.h16
-rw-r--r--entityx/Manager.h4
-rw-r--r--entityx/System.h10
-rw-r--r--entityx/help/NonCopyable.h23
-rw-r--r--entityx/help/Timer.cc37
-rw-r--r--entityx/help/Timer.h27
-rw-r--r--entityx/python/PythonSystem.cc7
-rw-r--r--entityx/tags/TagsComponent.h4
11 files changed, 122 insertions, 36 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba530fa..6cae773 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,10 +13,10 @@ set(ENTITYX_RUN_BENCHMARKS false CACHE BOOL "Run benchmarks (in conjunction with
set(ENTITYX_MAX_COMPONENTS 64 CACHE STRING "Set the maximum number of components.")
set(ENTITYX_USE_CPP11_STDLIB false CACHE BOOL "For Clang, specify whether to use libc++ (-stdlib=libc++).")
# Check for which shared_ptr implementation to use.
-set(ENTITYX_USE_STD_SHARED_PTR false CACHE BOOL "Use std::shared_ptr<T> rather than boost::shared_ptr<T>?")
-set(ENTITYX_BUILD_SHARED true CACHE BOOL "Build shared libraries?")
-set(ENTITYX_BUILD_PYTHON true CACHE BOOL "Build entityx::python?")
-set(ENTITYX_BOOST_SP_DISABLE_THREADS false CACHE BOOL "Disable multi-threading support in boost::shared_ptr")
+set(ENTITYX_USE_STD_SHARED_PTR true CACHE BOOL "Use std::shared_ptr<T> rather than boost::shared_ptr<T>?")
+set(ENTITYX_BUILD_SHARED false CACHE BOOL "Build shared libraries?")
+set(ENTITYX_BUILD_PYTHON false CACHE BOOL "Build entityx::python?")
+set(ENTITYX_BOOST_SP_DISABLE_THREADS true CACHE BOOL "Disable multi-threading support in boost::shared_ptr")
include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
include(CheckCXXSourceCompiles)
diff --git a/entityx/3rdparty/simplesignal.h b/entityx/3rdparty/simplesignal.h
index eaca148..0af2644 100644
--- a/entityx/3rdparty/simplesignal.h
+++ b/entityx/3rdparty/simplesignal.h
@@ -6,7 +6,6 @@
#include <assert.h>
#include <stdint.h>
#include <vector>
-#include <boost/function.hpp>
namespace Simple {
@@ -46,7 +45,7 @@ struct CollectorDefault<void> {
template<class Collector, class R, class... Args>
struct CollectorInvocation<Collector, R (Args...)> {
inline bool
- invoke (Collector &collector, const boost::function<R (Args...)> &cbf, Args... args)
+ invoke (Collector &collector, const std::function<R (Args...)> &cbf, Args... args)
{
return collector (cbf (args...));
}
@@ -56,7 +55,7 @@ struct CollectorInvocation<Collector, R (Args...)> {
template<class Collector, class... Args>
struct CollectorInvocation<Collector, void (Args...)> {
inline bool
- invoke (Collector &collector, const boost::function<void (Args...)> &cbf, Args... args)
+ invoke (Collector &collector, const std::function<void (Args...)> &cbf, Args... args)
{
cbf (args...); return collector();
}
@@ -66,7 +65,7 @@ struct CollectorInvocation<Collector, void (Args...)> {
template<class Collector, class R, class... Args>
class ProtoSignal<R (Args...), Collector> : private CollectorInvocation<Collector, R (Args...)> {
protected:
- typedef boost::function<R (Args...)> CbFunction;
+ typedef std::function<R (Args...)> CbFunction;
typedef typename CbFunction::result_type Result;
typedef typename Collector::CollectorResult CollectorResult;
private:
@@ -237,7 +236,7 @@ public:
* The overhead of an unused signal is intentionally kept very low, around the size of a single pointer.
* Note that the Signal template types is non-copyable.
*/
-template <typename SignalSignature, class Collector = Lib::CollectorDefault<typename boost::function<SignalSignature>::result_type> >
+template <typename SignalSignature, class Collector = Lib::CollectorDefault<typename std::function<SignalSignature>::result_type> >
struct Signal /*final*/ :
Lib::ProtoSignal<SignalSignature, Collector>
{
@@ -247,15 +246,15 @@ struct Signal /*final*/ :
Signal (const CbFunction &method = CbFunction()) : ProtoSignal (method) {}
};
-/// This function creates a boost::function by binding @a object to the member function pointer @a method.
-template<class Instance, class Class, class R, class... Args> boost::function<R (Args...)>
+/// This function creates a std::function by binding @a object to the member function pointer @a method.
+template<class Instance, class Class, class R, class... Args> std::function<R (Args...)>
slot (Instance &object, R (Class::*method) (Args...))
{
return [&object, method] (Args... args) { return (object .* method) (args...); };
}
-/// This function creates a boost::function by binding @a object to the member function pointer @a method.
-template<class Class, class R, class... Args> boost::function<R (Args...)>
+/// This function creates a std::function by binding @a object to the member function pointer @a method.
+template<class Class, class R, class... Args> std::function<R (Args...)>
slot (Class *object, R (Class::*method) (Args...))
{
return [object, method] (Args... args) { return (object ->* method) (args...); };
diff --git a/entityx/Entity.h b/entityx/Entity.h
index 17e3be0..6b37ed2 100644
--- a/entityx/Entity.h
+++ b/entityx/Entity.h
@@ -25,6 +25,7 @@
#include "entityx/config.h"
#include "entityx/Event.h"
+#include "entityx/help/NonCopyable.h"
namespace entityx {
@@ -239,7 +240,7 @@ struct ComponentRemovedEvent : public Event<ComponentRemovedEvent<T>> {
/**
* Manages Entity::Id creation and component assignment.
*/
-class EntityManager : boost::noncopyable, public enable_shared_from_this<EntityManager> {
+class EntityManager : entityx::help::NonCopyable, public enable_shared_from_this<EntityManager> {
public:
typedef std::bitset<entityx::MAX_COMPONENTS> ComponentMask;
@@ -252,7 +253,7 @@ class EntityManager : boost::noncopyable, public enable_shared_from_this<EntityM
class View {
public:
- typedef boost::function<bool (const ptr<EntityManager> &, const Entity::Id &)> Predicate;
+ typedef std::function<bool (const ptr<EntityManager> &, const Entity::Id &)> Predicate;
/// A predicate that matches valid entities with the given component mask.
class ComponentMaskPredicate {
diff --git a/entityx/Event.h b/entityx/Event.h
index c375aa1..e60e7d7 100644
--- a/entityx/Event.h
+++ b/entityx/Event.h
@@ -11,14 +11,12 @@
#pragma once
#include <stdint.h>
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/unordered_map.hpp>
#include <list>
#include <utility>
+#include <unordered_map>
#include "entityx/config.h"
#include "entityx/3rdparty/simplesignal.h"
+#include "entityx/help/NonCopyable.h"
namespace entityx {
@@ -104,7 +102,7 @@ class Receiver : public BaseReceiver {
*
* Subscriptions are automatically removed when receivers are destroyed..
*/
-class EventManager : boost::noncopyable {
+class EventManager : entityx::help::NonCopyable {
public:
EventManager();
virtual ~EventManager();
@@ -132,7 +130,7 @@ class EventManager : boost::noncopyable {
void subscribe(Receiver &receiver) { //NOLINT
void (Receiver::*receive)(const E &) = &Receiver::receive;
auto sig = signal_for(E::family());
- auto wrapper = EventCallbackWrapper<E>(boost::bind(receive, &receiver, _1));
+ auto wrapper = EventCallbackWrapper<E>(std::bind(receive, &receiver, std::placeholders::_1));
auto connection = sig->connect(wrapper);
static_cast<BaseReceiver&>(receiver).connections_.push_back(
std::make_pair(EventSignalWeakPtr(sig), connection));
@@ -189,12 +187,12 @@ class EventManager : boost::noncopyable {
// Functor used as an event signal callback that casts to E.
template <typename E>
struct EventCallbackWrapper {
- EventCallbackWrapper(boost::function<void(const E &)> callback) : callback(callback) {}
+ EventCallbackWrapper(std::function<void(const E &)> callback) : callback(callback) {}
void operator()(const BaseEvent* event) { callback(*(static_cast<const E*>(event))); }
- boost::function<void(const E &)> callback;
+ std::function<void(const E &)> callback;
};
- boost::unordered_map<int, EventSignalPtr> handlers_;
+ std::unordered_map<int, EventSignalPtr> handlers_;
};
} // namespace entityx
diff --git a/entityx/Manager.h b/entityx/Manager.h
index 5151df5..3a7e99a 100644
--- a/entityx/Manager.h
+++ b/entityx/Manager.h
@@ -10,10 +10,10 @@
#pragma once
-#include <boost/timer.hpp>
#include "entityx/Entity.h"
#include "entityx/Event.h"
#include "entityx/System.h"
+#include "entityx/help/Timer.h"
namespace entityx {
@@ -58,7 +58,7 @@ class Manager {
ptr<SystemManager> system_manager;
private:
- boost::timer timer_;
+ help::Timer timer_;
bool running_ = false;
};
diff --git a/entityx/System.h b/entityx/System.h
index e4dcfec..132b8b9 100644
--- a/entityx/System.h
+++ b/entityx/System.h
@@ -11,13 +11,13 @@
#pragma once
-#include <boost/noncopyable.hpp>
-#include <boost/unordered_map.hpp>
+#include <unordered_map>
#include <stdint.h>
#include <cassert>
#include "entityx/config.h"
#include "entityx/Entity.h"
#include "entityx/Event.h"
+#include "entityx/help/NonCopyable.h"
namespace entityx {
@@ -25,7 +25,7 @@ namespace entityx {
/**
* Base System class. Generally should not be directly used, instead see System<Derived>.
*/
-class BaseSystem : boost::noncopyable {
+class BaseSystem : entityx::help::NonCopyable {
public:
typedef uint64_t Family;
@@ -72,7 +72,7 @@ class System : public BaseSystem {
};
-class SystemManager : boost::noncopyable, public enable_shared_from_this<SystemManager> {
+class SystemManager : entityx::help::NonCopyable, public enable_shared_from_this<SystemManager> {
public:
SystemManager(ptr<EntityManager> entity_manager,
ptr<EventManager> event_manager) :
@@ -150,7 +150,7 @@ class SystemManager : boost::noncopyable, public enable_shared_from_this<SystemM
bool initialized_ = false;
ptr<EntityManager> entity_manager_;
ptr<EventManager> event_manager_;
- boost::unordered_map<BaseSystem::Family, ptr<BaseSystem>> systems_;
+ std::unordered_map<BaseSystem::Family, ptr<BaseSystem>> systems_;
};
} // namespace entityx
diff --git a/entityx/help/NonCopyable.h b/entityx/help/NonCopyable.h
new file mode 100644
index 0000000..5f193ee
--- /dev/null
+++ b/entityx/help/NonCopyable.h
@@ -0,0 +1,23 @@
+// Inspired heavily by boost::noncopyable
+
+#pragma once
+
+namespace entityx {
+namespace help {
+
+class NonCopyable
+{
+ protected:
+
+ NonCopyable() = default;
+ ~NonCopyable() = default;
+
+
+ NonCopyable( const NonCopyable& ) = delete;
+ NonCopyable& operator=( const NonCopyable& ) = delete;
+
+};
+
+
+} // namespace help
+} // namespace entityx \ No newline at end of file
diff --git a/entityx/help/Timer.cc b/entityx/help/Timer.cc
new file mode 100644
index 0000000..de25df0
--- /dev/null
+++ b/entityx/help/Timer.cc
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2013 Antony Woods <antony@teamwoods.org>
+ * All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.
+ *
+ * Author: Antony Woods <antony@teamwoods.org>
+ */
+
+#include "entityx/help/Timer.h"
+
+namespace entityx {
+namespace help {
+
+Timer::Timer()
+{
+
+}
+
+Timer::~Timer()
+{
+
+}
+
+void Timer::restart()
+{
+
+}
+
+double Timer::elapsed()
+{
+ return 1.0;
+}
+
+} // namespace help
+} // namespace entityx \ No newline at end of file
diff --git a/entityx/help/Timer.h b/entityx/help/Timer.h
new file mode 100644
index 0000000..eaf51ab
--- /dev/null
+++ b/entityx/help/Timer.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2013 Antony Woods <antony@teamwoods.org>
+ * All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.
+ *
+ * Author: Antony Woods <antony@teamwoods.org>
+ */
+
+#pragma once
+
+namespace entityx {
+namespace help {
+
+class Timer
+{
+public:
+ Timer();
+ ~Timer();
+
+ void restart();
+ double elapsed();
+};
+
+} // namespace help
+} // namespace entityx \ No newline at end of file
diff --git a/entityx/python/PythonSystem.cc b/entityx/python/PythonSystem.cc
index bb59e7d..032b283 100644
--- a/entityx/python/PythonSystem.cc
+++ b/entityx/python/PythonSystem.cc
@@ -15,6 +15,7 @@
#include <iostream>
#include <sstream>
#include "entityx/python/PythonSystem.h"
+#include "entityx/help/NonCopyableEvent.h"
namespace py = boost::python;
@@ -103,7 +104,7 @@ BOOST_PYTHON_MODULE(_entityx) {
py::class_<PythonEntityXLogger>("Logger", py::no_init)
.def("write", &PythonEntityXLogger::write);
- py::class_<BaseEvent, ptr<BaseEvent>, boost::noncopyable>("BaseEvent", py::no_init);
+ py::class_<BaseEvent, ptr<BaseEvent>, entityx::help::NonCopyable>("BaseEvent", py::no_init);
py::class_<PythonEntity>("Entity", py::init<Entity>())
.def_readonly("_entity", &PythonEntity::_entity)
@@ -121,12 +122,12 @@ BOOST_PYTHON_MODULE(_entityx) {
.def("get_component", &get_component<PythonComponent>)
.staticmethod("get_component");
- py::class_<EntityManager, ptr<EntityManager>, boost::noncopyable>("EntityManager", py::no_init)
+ py::class_<EntityManager, ptr<EntityManager>, entityx::help::NonCopyable>("EntityManager", py::no_init)
.def("create", &EntityManager::create);
void (EventManager::*emit)(const BaseEvent &) = &EventManager::emit;
- py::class_<EventManager, ptr<EventManager>, boost::noncopyable>("EventManager", py::no_init)
+ py::class_<EventManager, ptr<EventManager>, entityx::help::NonCopyable>("EventManager", py::no_init)
.def("emit", emit);
py::implicitly_convertible<PythonEntity, Entity>();
diff --git a/entityx/tags/TagsComponent.h b/entityx/tags/TagsComponent.h
index b208c63..6fcb937 100644
--- a/entityx/tags/TagsComponent.h
+++ b/entityx/tags/TagsComponent.h
@@ -10,8 +10,8 @@
#pragma once
-#include <boost/unordered_set.hpp>
#include <string>
+#include <unordered_set>
#include "entityx/Entity.h"
namespace entityx {
@@ -50,7 +50,7 @@ class TagsComponent : public Component<TagsComponent> {
return EntityManager::View(view, TagsPredicate(tag));
}
- boost::unordered_set<std::string> tags;
+ std::unordered_set<std::string> tags;
private:
template <typename ... Args>