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)
#include <assert.h>
#include <stdint.h>
#include <vector>
-#include <boost/function.hpp>
namespace Simple {
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...));
}
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();
}
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:
* 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>
{
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...); };
#include "entityx/config.h"
#include "entityx/Event.h"
+#include "entityx/help/NonCopyable.h"
namespace entityx {
/**
* 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;
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 {
#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 {
*
* Subscriptions are automatically removed when receivers are destroyed..
*/
-class EventManager : boost::noncopyable {
+class EventManager : entityx::help::NonCopyable {
public:
EventManager();
virtual ~EventManager();
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));
// 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
#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 {
ptr<SystemManager> system_manager;
private:
- boost::timer timer_;
+ help::Timer timer_;
bool running_ = false;
};
#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 {
/**
* 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;
};
-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) :
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
--- /dev/null
+// 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
#include <iostream>
#include <sstream>
#include "entityx/python/PythonSystem.h"
+#include "entityx/help/NonCopyableEvent.h"
namespace py = boost::python;
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)
.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>();
#pragma once
-#include <boost/unordered_set.hpp>
#include <string>
+#include <unordered_set>
#include "entityx/Entity.h"
namespace entityx {
return EntityManager::View(view, TagsPredicate(tag));
}
- boost::unordered_set<std::string> tags;
+ std::unordered_set<std::string> tags;
private:
template <typename ... Args>