diff --git a/Base/Scene/imstkScene.cpp b/Base/Scene/imstkScene.cpp index 9d70ae8ae98ba585b7e076cc686c385bf55f36cd..ea9919ef3ce8a9b03b318b4b144893a24a07f714 100644 --- a/Base/Scene/imstkScene.cpp +++ b/Base/Scene/imstkScene.cpp @@ -22,4 +22,19 @@ namespace imstk { +void Scene::initModule() +{ + std::cout<<std::endl<<m_name<<" : init"<<std::endl; +} + +void Scene::cleanUpModule() +{ + std::cout<<std::endl<<m_name<<" : cleanUp"<<std::endl; +} + +void Scene::runModule() +{ + std::cout<<"."<<std::flush; +} + } diff --git a/Base/Scene/imstkScene.h b/Base/Scene/imstkScene.h index f1a0735599afd6e76934944208017f97f03e1fca..e9906ed9211b57e560b1fcb4e64e0442814deead 100644 --- a/Base/Scene/imstkScene.h +++ b/Base/Scene/imstkScene.h @@ -21,6 +21,8 @@ #ifndef imstkScene_h #define imstkScene_h +#include <iostream> + #include "imstkModule.h" namespace imstk { @@ -28,10 +30,14 @@ namespace imstk { class Scene : public Module { public: + Scene(std::string name) : Module(name){} ~Scene() = default; -private: - Scene() = default; +protected: + + void initModule() override; + void runModule() override; + void cleanUpModule() override; }; diff --git a/CMakeLists.txt b/CMakeLists.txt index 85ee6dc2ee6608f9cacabed46939ddcc12881f18..699cdc4874746c55b97aa524390bbcde717ab950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,15 +69,15 @@ include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread") elseif(COMPILER_SUPPORTS_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -pthread") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() #-------------------------------------------------------------------------- -# Add Source code subdirectory +# Add Source code subdirectories #-------------------------------------------------------------------------- add_subdirectory(Base/Core) add_subdirectory(Base/Scene) @@ -97,3 +97,8 @@ install(EXPORT iMSTK_TARGETS COMPONENT Development DESTINATION ${${PROJECT_NAME}_INSTALL_SHARE_DIR} ) + +#-------------------------------------------------------------------------- +# Add Examples subdirectories +#-------------------------------------------------------------------------- +add_subdirectory(Examples/Sandbox) diff --git a/Examples/Sandbox/CMakeLists.txt b/Examples/Sandbox/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4aee98f70813a8088be07494580b2c97cfd00333 --- /dev/null +++ b/Examples/Sandbox/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# +# Copyright (c) Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +########################################################################### + +project(Sandbox) + +#----------------------------------------------------------------------------- +# Create executable +#----------------------------------------------------------------------------- +add_executable(${PROJECT_NAME} main.cpp) + +#----------------------------------------------------------------------------- +# Link libraries to executable +#----------------------------------------------------------------------------- +target_link_libraries(${PROJECT_NAME} + Scene +) diff --git a/Examples/Sandbox/main.cpp b/Examples/Sandbox/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b486f21933adaca87648409d74186b6708515bde --- /dev/null +++ b/Examples/Sandbox/main.cpp @@ -0,0 +1,33 @@ +#include <cstring> +#include <iostream> +#include <memory> +#include <thread> + +#include "imstkScene.h" + + +int main() +{ + std::cout << "****************" << std::endl + << "Starting Sandbox" << std::endl + << "****************" << std::endl; + + std::shared_ptr<imstk::Scene> scene1 = + std::make_shared<imstk::Scene>("Scene1"); + + std::thread t1([scene1]{scene1->exec();}); + + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + scene1->pause(); + std::this_thread::sleep_for(std::chrono::seconds(2)); + scene1->run(); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + scene1->pause(); + std::this_thread::sleep_for(std::chrono::seconds(2)); + scene1->terminate(); + + t1.join(); + + + return 0; +}