]> code.bitgloo.com Git - clyne/entityx.git/commitdiff
Remove Components*, moved to tags/ in a previous change.
authorAlec Thomas <alec@swapoff.org>
Tue, 2 Apr 2013 23:58:14 +0000 (19:58 -0400)
committerAlec Thomas <alec@swapoff.org>
Tue, 2 Apr 2013 23:58:14 +0000 (19:58 -0400)
CMakeLists.txt
entityx/Components.cc [deleted file]
entityx/Components.h [deleted file]
entityx/Components_test.cc [deleted file]

index 013c96e88ed6cff1b1d0ffd932cef8648b7d216c..2b6c52758ac55309b0bce2d195445d46706ff0b3 100644 (file)
@@ -127,7 +127,7 @@ set(Boost_USE_MULTITHREADED ON)
 set(Boost_USE_STATIC_RUNTIME OFF)
 find_package(Boost 1.48.0 REQUIRED COMPONENTS signals)
 
-set(sources entityx/Components.cc entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/Manager.cc)
+set(sources entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/Manager.cc)
 add_library(entityx STATIC ${sources})
 add_library(entityx_shared SHARED ${sources})
 target_link_libraries(
@@ -148,9 +148,9 @@ if (BUILD_TESTING)
     include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
     enable_testing()
     create_test(entity_test entityx/Entity_test.cc)
-    create_test(component_test entityx/Components_test.cc)
     create_test(event_test entityx/Event_test.cc)
     create_test(system_test entityx/System_test.cc)
+    create_test(tags_component_test entityx/tags/TagsComponent_test.cc)
     if (RUN_BENCHMARKS)
         message("-- Running benchmarks")
         create_test(benchmarks_test entityx/Benchmarks_test.cc)
diff --git a/entityx/Components.cc b/entityx/Components.cc
deleted file mode 100644 (file)
index 8d6e929..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Copyright (C) 2012 Alec Thomas <alec@swapoff.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: Alec Thomas <alec@swapoff.org>
- */
-
-#include "entityx/Components.h"
diff --git a/entityx/Components.h b/entityx/Components.h
deleted file mode 100644 (file)
index 9168cc5..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright (C) 2012 Alec Thomas <alec@swapoff.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: Alec Thomas <alec@swapoff.org>
- */
-
-#pragma once
-
-#include <string>
-#include <boost/unordered_set.hpp>
-#include "entityx/Entity.h"
-
-namespace entityx {
-
-/**
- * Allow entities to be tagged with strings.
- */
-class TagsComponent : public Component<TagsComponent> {
-  struct TagsPredicate {
-    TagsPredicate(const std::string &tag) : tag(tag) {}
-
-    bool operator () (EntityManager &manager, Entity::Id id) {
-      auto tags = manager.component<TagsComponent>(id);
-      return tags != nullptr && tags->tags.find(tag) != tags->tags.end();
-    }
-
-    std::string tag;
-  };
-
- public:
-  /**
-   * Construct a new TagsComponent with the given tags.
-   *
-   * eg. TagsComponent tags("a", "b", "c");
-   */
-  template <typename ... Args>
-  TagsComponent(const std::string &tag, const Args & ... tags) {
-    set_tags(tag, tags ...);
-  }
-
-  /**
-   * Filter the provided view to only those entities with the given tag.
-   */
-  static EntityManager::View view(const EntityManager::View &view, const std::string &tag) {
-    return EntityManager::View(view, TagsPredicate(tag));
-  }
-
-  boost::unordered_set<std::string> tags;
-
- private:
-  template <typename ... Args>
-  void set_tags(const std::string &tag1, const std::string &tag2, const Args & ... tags) {
-    this->tags.insert(tag1);
-    set_tags(tag2, tags ...);
-  }
-
-  void set_tags(const std::string &tag) {
-    tags.insert(tag);
-  }
-};
-
-}
diff --git a/entityx/Components_test.cc b/entityx/Components_test.cc
deleted file mode 100644 (file)
index d9a0ecd..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright (C) 2012 Alec Thomas <alec@swapoff.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: Alec Thomas <alec@swapoff.org>
- */
-
-#include <gtest/gtest.h>
-#include "entityx/Components.h"
-
-using namespace std;
-using namespace boost;
-using namespace entityx;
-
-
-struct Position : public Component<Position> {};
-
-
-template <typename T>
-int size(const T &t) {
-  int n = 0;
-  for (auto i : t) {
-    ++n;
-    (void)i; // Unused on purpose, suppress warning
-  }
-  return n;
-}
-
-
-TEST(TagsComponentTest, TestVariadicConstruction) {
-  auto tags = TagsComponent("player", "indestructible");
-  unordered_set<string> expected;
-  expected.insert("player");
-  expected.insert("indestructible");
-  ASSERT_TRUE(expected == tags.tags);
-}
-
-TEST(TagsComponentTest, TestEntitiesWithTag) {
-  EventManager ev;
-  EntityManager en(ev);
-  Entity a = en.create();
-  a.assign<Position>();
-  for (int i = 0; i < 99; ++i) {
-    auto e = en.create();
-    e.assign<Position>();
-    e.assign<TagsComponent>("positionable");
-  }
-  a.assign<TagsComponent>("player", "indestructible");
-  auto entities = en.entities_with_components<Position>();
-  ASSERT_EQ(100, size(entities));
-  ASSERT_EQ(1, size(TagsComponent::view(entities, "player")));
-}