From dd2e781d38d34a574bb173f70bb20f0aa3439246 Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Wed, 6 Apr 2016 18:10:54 +0200 Subject: Added a function to retrieve the Entity associated with a component in ComponentHandle --- entityx/Entity.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/entityx/Entity.h b/entityx/Entity.h index b55a45f..2382c11 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -201,6 +201,11 @@ public: */ void remove(); + /** + * Returns the Entity associated with the component + */ + Entity entity(); + bool operator == (const ComponentHandle &other) const { return manager_ == other.manager_ && id_ == other.id_; } @@ -1036,6 +1041,12 @@ inline void ComponentHandle::remove() { manager_->template remove(id_); } +template +inline Entity ComponentHandle::entity() { + assert(valid()); + return manager_->template get(id_); +} + } // namespace entityx -- cgit v1.2.3 From 76828e68aa9b30c4c6afac2fbbac1964d11226b6 Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Wed, 6 Apr 2016 22:07:07 +0200 Subject: Fixed shared library compilation. - Fixed that when ENTITYX_BUILD_SHARED=1 was compiling the static library and the shared_library. Now it only compiles one of them, shared or static, but not both. Using visual studio compiler, now, the shared library doesn't create a .lib file (because it doesn't export anything which is OK). This will be the next step. --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 993badb..8760165 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,11 +129,9 @@ message("-- Checking misc features") require(HAVE_STDINT_H "stdint.h") # Things to install -set(install_libs entityx) + set(sources entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/help/Timer.cc entityx/help/Pool.cc) -add_library(entityx STATIC ${sources}) -set_target_properties(entityx PROPERTIES DEBUG_POSTFIX -d FOLDER entityx) if (ENTITYX_BUILD_SHARED) message("-- Building shared libraries (-DENTITYX_BUILD_SHARED=0 to only build static librarires)") @@ -147,7 +145,11 @@ if (ENTITYX_BUILD_SHARED) VERSION ${ENTITYX_VERSION} SOVERSION ${ENTITYX_MAJOR_VERSION} FOLDER entityx) - list(APPEND install_libs entityx_shared) + set(install_libs entityx_shared) +else() + add_library(entityx STATIC ${sources}) + set_target_properties(entityx PROPERTIES DEBUG_POSTFIX -d FOLDER entityx) + set(install_libs entityx) endif (ENTITYX_BUILD_SHARED) if (ENTITYX_BUILD_TESTING) @@ -197,4 +199,5 @@ install( TARGETS ${install_libs} LIBRARY DESTINATION "${libdir}" ARCHIVE DESTINATION "${libdir}" + RUNTIME DESTINATION "bin" ) -- cgit v1.2.3 From 8f030a62a52c06896bd6c643a1e295267f2dd097 Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Sun, 10 Apr 2016 22:43:35 +0200 Subject: Minor fix due to copy-paste of entity() function --- entityx/Entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entityx/Entity.h b/entityx/Entity.h index 2382c11..f6fe020 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -1044,7 +1044,7 @@ inline void ComponentHandle::remove() { template inline Entity ComponentHandle::entity() { assert(valid()); - return manager_->template get(id_); + return manager_->get(id_); } -- cgit v1.2.3 From 1db0ab9d04e154345876c9ec7961063987198240 Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Wed, 13 Apr 2016 00:26:34 +0200 Subject: Fix ident. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8760165..4e0cf73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,9 +147,9 @@ if (ENTITYX_BUILD_SHARED) FOLDER entityx) set(install_libs entityx_shared) else() - add_library(entityx STATIC ${sources}) - set_target_properties(entityx PROPERTIES DEBUG_POSTFIX -d FOLDER entityx) - set(install_libs entityx) + add_library(entityx STATIC ${sources}) + set_target_properties(entityx PROPERTIES DEBUG_POSTFIX -d FOLDER entityx) + set(install_libs entityx) endif (ENTITYX_BUILD_SHARED) if (ENTITYX_BUILD_TESTING) @@ -199,5 +199,5 @@ install( TARGETS ${install_libs} LIBRARY DESTINATION "${libdir}" ARCHIVE DESTINATION "${libdir}" - RUNTIME DESTINATION "bin" + RUNTIME DESTINATION "bin" ) -- cgit v1.2.3 From 1958c636c971891326114458821369daa4b2a104 Mon Sep 17 00:00:00 2001 From: Daniel Guzmán Date: Wed, 13 Apr 2016 02:05:20 +0200 Subject: Dependencies for test projects added --- CMakeLists.txt | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e0cf73..7f8e240 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,14 +91,15 @@ macro(require FEATURE_NAME MESSAGE_STRING) endif() endmacro(require) -macro(create_test TARGET_NAME SOURCE) +macro(create_test TARGET_NAME SOURCE DEPENDENCIES) add_executable(${TARGET_NAME} ${SOURCE}) + set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX -d) + set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "entityx/tests") target_link_libraries( ${TARGET_NAME} - entityx + ${DEPENDENCIES} ${ARGN} ) - set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "entityx/tests") # Special case for benchmark tests if (${TARGET_NAME} MATCHES .*benchmark.*) @@ -136,9 +137,7 @@ set(sources entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/help/Ti if (ENTITYX_BUILD_SHARED) message("-- Building shared libraries (-DENTITYX_BUILD_SHARED=0 to only build static librarires)") add_library(entityx_shared SHARED ${sources}) - target_link_libraries( - entityx_shared - ) + set_target_properties(entityx_shared PROPERTIES OUTPUT_NAME entityx DEBUG_POSTFIX -d @@ -154,13 +153,13 @@ endif (ENTITYX_BUILD_SHARED) if (ENTITYX_BUILD_TESTING) enable_testing() - create_test(pool_test entityx/help/Pool_test.cc) - create_test(entity_test entityx/Entity_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) - create_test(dependencies_test entityx/deps/Dependencies_test.cc) - create_test(benchmarks_test entityx/Benchmarks_test.cc) + create_test(pool_test entityx/help/Pool_test.cc ${install_libs}) + create_test(entity_test entityx/Entity_test.cc ${install_libs}) + create_test(event_test entityx/Event_test.cc ${install_libs}) + create_test(system_test entityx/System_test.cc ${install_libs}) + create_test(tags_component_test entityx/tags/TagsComponent_test.cc ${install_libs}) + create_test(dependencies_test entityx/deps/Dependencies_test.cc ${install_libs}) + create_test(benchmarks_test entityx/Benchmarks_test.cc ${install_libs}) if (ENTITYX_RUN_BENCHMARKS) message("-- Running benchmarks") else () -- cgit v1.2.3 From 2dcddf58bd0112d2c8a8c242415d21552c00d563 Mon Sep 17 00:00:00 2001 From: Daniel Guzmán Date: Wed, 13 Apr 2016 02:12:53 +0200 Subject: Fix running tests --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f8e240..116b137 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,6 @@ endmacro(require) macro(create_test TARGET_NAME SOURCE DEPENDENCIES) add_executable(${TARGET_NAME} ${SOURCE}) - set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX -d) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "entityx/tests") target_link_libraries( ${TARGET_NAME} -- cgit v1.2.3