From be03c3a3d4e8824c3b909648b46910b4cdbc72e1 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Wed, 21 Aug 2013 20:34:10 -0400 Subject: Switch to boost::signals2. --- CHANGELOG.md | 22 ---------------------- CHANGES.md | 22 ++++++++++++++++++++++ CMakeLists.txt | 3 +-- README.md | 5 +++-- entityx/Event.h | 7 ++++--- entityx/python/PythonSystem.h | 6 +++--- entityx/python/entityx/tests/deep_subclass_test.py | 4 +++- 7 files changed, 36 insertions(+), 33 deletions(-) delete mode 100644 CHANGELOG.md create mode 100644 CHANGES.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index acc0008..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,22 +0,0 @@ -# Change Log - -## 2013-08-18 - Destroying an entity invalidates all other references - -Previously, `Entity::Id` was a simple integer index (slot) into vectors in the `EntityManager`. EntityX also maintains a list of deleted entity slots that are reused when new entities are created. This reduces the size and frequency of vector reallocation. The downside though, was that if a slot was reused, entity IDs referencing the entity before reallocation would be invalidated on reuse. - -Each slot now also has a version number and a "valid" bit associated with it. When an entity is allocated the version is incremented and the valid bit set. When an entity is destroyed, the valid bit is cleared. `Entity::Id` now contains all of this information and can correctly determine if an ID is still valid across destroy/create. - -## 2013-08-17 - Python scripting, and a more robust build system - -Two big changes in this release: - -1. Python scripting support (alpha). - - Bridges the EntityX entity-component system into Python. - - Components and entities can both be defined in Python. - - Systems must still be defined in C++, for performance reasons. - - Note that there is one major design difference between the Python ECS model and the C++ model: entities in Python can receive and handle events. - - See the [README](https://github.com/alecthomas/entityx/blob/master/entityx/python/README.md) for help, and the [C++](https://github.com/alecthomas/entityx/blob/master/entityx/python/PythonSystem_test.cc) and [Python](https://github.com/alecthomas/entityx/tree/master/entityx/python/entityx/tests) test source for more examples. - -2. Made the build system much more robust, including automatic feature selection with manual override. diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..acc0008 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,22 @@ +# Change Log + +## 2013-08-18 - Destroying an entity invalidates all other references + +Previously, `Entity::Id` was a simple integer index (slot) into vectors in the `EntityManager`. EntityX also maintains a list of deleted entity slots that are reused when new entities are created. This reduces the size and frequency of vector reallocation. The downside though, was that if a slot was reused, entity IDs referencing the entity before reallocation would be invalidated on reuse. + +Each slot now also has a version number and a "valid" bit associated with it. When an entity is allocated the version is incremented and the valid bit set. When an entity is destroyed, the valid bit is cleared. `Entity::Id` now contains all of this information and can correctly determine if an ID is still valid across destroy/create. + +## 2013-08-17 - Python scripting, and a more robust build system + +Two big changes in this release: + +1. Python scripting support (alpha). + - Bridges the EntityX entity-component system into Python. + - Components and entities can both be defined in Python. + - Systems must still be defined in C++, for performance reasons. + + Note that there is one major design difference between the Python ECS model and the C++ model: entities in Python can receive and handle events. + + See the [README](https://github.com/alecthomas/entityx/blob/master/entityx/python/README.md) for help, and the [C++](https://github.com/alecthomas/entityx/blob/master/entityx/python/PythonSystem_test.cc) and [Python](https://github.com/alecthomas/entityx/tree/master/entityx/python/entityx/tests) test source for more examples. + +2. Made the build system much more robust, including automatic feature selection with manual override. diff --git a/CMakeLists.txt b/CMakeLists.txt index e53de9a..23206e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,6 @@ require(HAVE_STDINT_H "stdint.h") set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost 1.48.0 REQUIRED COMPONENTS signals) find_package(Boost 1.48.0 COMPONENTS python) include_directories(${Boost_INCLUDE_DIR}) @@ -135,7 +134,7 @@ if (Boost_PYTHON_LIBRARY) endif (Boost_PYTHON_LIBRARY) if (ENTITYX_BUILD_TESTING) - find_package(Boost 1.48.0 REQUIRED COMPONENTS signals timer system) + find_package(Boost 1.48.0 REQUIRED COMPONENTS timer system) add_subdirectory(gtest-1.6.0) include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) enable_testing() diff --git a/README.md b/README.md index 0df1d74..a72ba20 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,11 @@ You can also contact me directly via [email](mailto:alec@swapoff.org) or [Twitte ## Recent Notable Changes +- 2013-08-21 - Switch to `boost::signals2`. - 2013-08-18 - Destroying an entity invalidates all other references - 2013-08-17 - Python scripting, and a more robust build system -See the [ChangeLog](https://github.com/alecthomas/entityx/blob/master/CHANGELOG.md) for details. +See the [ChangeLog](https://github.com/alecthomas/entityx/blob/master/CHANGES.md) for details. ## Overview @@ -255,7 +256,7 @@ EntityX has the following build and runtime requirements: - A C++ compiler that supports a basic set of C++11 features (ie. recent clang, recent gcc, and maybe (untested) VC++ with the [Nov 2012 CTP](http://www.microsoft.com/en-us/download/details.aspx?id=35515)). - [CMake](http://cmake.org/) -- [Boost](http://boost.org) `1.48.0` or higher (links against `boost::signals`). +- [Boost](http://boost.org) `1.48.0` or higher (links against `boost::signals2`). Once these dependencies are installed you should be able to build and install EntityX as below. The following options can be passed to cmake to modify how EntityX is built: diff --git a/entityx/Event.h b/entityx/Event.h index 8d3de61..040306c 100644 --- a/entityx/Event.h +++ b/entityx/Event.h @@ -14,8 +14,9 @@ #include #include #include -#include +#include #include +#include #include "entityx/config.h" @@ -66,7 +67,7 @@ class BaseReceiver { private: friend class EventManager; - std::list connections_; + std::list connections_; }; @@ -131,7 +132,7 @@ class EventManager : public entityx::enable_shared_from_this, boos } private: - typedef boost::signal EventSignal; + typedef boost::signals2::signal EventSignal; typedef entityx::shared_ptr EventSignalPtr; EventManager() {} diff --git a/entityx/python/PythonSystem.h b/entityx/python/PythonSystem.h index 7001f23..5c6333c 100644 --- a/entityx/python/PythonSystem.h +++ b/entityx/python/PythonSystem.h @@ -23,9 +23,9 @@ namespace std { // This may or may not work... it definitely does not work on OSX. -template inline T * get_pointer(const std::shared_ptr &p) { - return p.get(); -} +// template inline T * get_pointer(const std::shared_ptr &p) { +// return p.get(); +// } } diff --git a/entityx/python/entityx/tests/deep_subclass_test.py b/entityx/python/entityx/tests/deep_subclass_test.py index 9c576b2..801b487 100644 --- a/entityx/python/entityx/tests/deep_subclass_test.py +++ b/entityx/python/entityx/tests/deep_subclass_test.py @@ -21,4 +21,6 @@ class DeepSubclassTest2(DeepSubclassTest): assert self.direction assert self.position assert self.position2 - assert self.position is self.position2 + assert self.position.x == self.position2.x and self.position.y == self.position2.y + self.position.x += 1 + assert self.position.x == self.position2.x and self.position.y == self.position2.y -- cgit v1.2.3