Resolve namespace std clash with boost.
struct NullDeleter can't be local.
Remove surplus ';'.
```c++
struct Collision : public Event<Collision> {
Collision(Entity left, Entity right) : left(left), right(right) {}
-
+
Entity left, right;
};
```
system_manager.add<MovementSystem>();
system_manager.add<CollisionSystem>();
}
-
+
void initialize() {
// Create some entities in random locations heading in random directions
for (int i = 0; i < 100; ++i) {
entity.assign<Direction>((rand() % 10) - 5, (rand() % 10) - 5);
}
}
-
+
void update(double dt) {
system_manager.update<MovementSystem>(dt);
system_manager.update<CollisionSystem>(dt);
- [CMake](http://cmake.org/)
- [Boost](http://boost.org) `1.48.0` or higher (links against `boost::signals`).
- [Glog](http://code.google.com/p/google-glog/) (tested with `0.3.2`).
-- [GTest](http://code.google.com/p/googletest/)
+- [GTest](http://code.google.com/p/googletest/) (needed for testing only)
-Once these dependencies are installed you should be able to build and install EntityX with:
+Once these dependencies are installed you should be able to build and install EntityX as follows. BUILD_TESTING is false by default.
```c++
-mkdir build && cd build && cmake .. && make && make test && make install
+mkdir build
+cd build
+cmake [-DBUILD_TESTING=true] ..
+make
+make install
```
-EntityX has currently only been tested on Mac OSX (Lion and Mountain Lion). Reports and patches for builds on other platforms are welcome.
+EntityX has currently only been tested on Mac OSX (Lion and Mountain Lion), and Linux Debian. Reports and patches for builds on other platforms are welcome.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution.
- *
+ *
* Author: Alec Thomas <alec@swapoff.org>
*/
#include <gtest/gtest.h>
#include "entityx/Entity.h"
-using namespace std;
+// using namespace std; // This will give name space conflicts with boost
using namespace boost;
using namespace entityx;
+using std::ostream;
+using std::vector;
template <typename T>
int size(const T &t) {
ASSERT_EQ(d, ud);
}
+// gcc 4.7.2 does not allow this struct to be declared locally inside the TEST_F.
+struct NullDeleter {template<typename T> void operator()(T*) {} };
+
TEST_F(EntityManagerTest, TestUnpackNullMissing) {
Entity::Id e = em.create();
auto p = em.assign<Position>(e);
- struct NullDeleter {template<typename T> void operator()(T*) {} };
shared_ptr<Position> up(reinterpret_cast<Position*>(0Xdeadbeef), NullDeleter());
shared_ptr<Direction> ud(reinterpret_cast<Direction*>(0Xdeadbeef), NullDeleter());
em.unpack<Position, Direction>(e, up, ud);
em.create();
}
ASSERT_EQ(10, receiver.created.size());
-};
+}
TEST_F(EntityManagerTest, TestEntityDestroyedEvent) {
struct EntityDestroyedEventReceiver : public Receiver<EntityDestroyedEventReceiver> {
em.destroy(e);
}
ASSERT_TRUE(entities == receiver.destroyed);
-};
+}
TEST_F(EntityManagerTest, TestComponentAddedEvent) {
struct ComponentAddedEventReceiver : public Receiver<ComponentAddedEventReceiver> {
}
ASSERT_EQ(10, receiver.position_events);
ASSERT_EQ(10, receiver.direction_events);
-};
+}
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution.
- *
+ *
* Author: Alec Thomas <alec@swapoff.org>
*/
#include "entityx/System.h"
-using namespace std;
+// using namespace std; // This will give name space conflicts with boost
using namespace boost;
using namespace entityx;
+using std::string;
struct Position : Component<Position> {
Position(float x = 0.0f, float y = 0.0f) : x(x), y(y) {}