├── .gitattributes ├── .travis.yml ├── CMakeLists.txt ├── Jamfile.v2 ├── Jamroot.jam ├── README.md ├── boost-build.jam ├── conan.cmake ├── doc ├── Jamfile.jam ├── Thumbs.db ├── acknowledgements.qbk ├── app.ai ├── app.gif ├── application.qbk ├── apptypes.qbk ├── aspect.ai ├── aspect.gif ├── aspects.qbk ├── bibliography.qbk ├── context.qbk ├── customization.qbk ├── dependencies.qbk ├── designoverview.qbk ├── examples.qbk ├── faq.qbk ├── handlingerrors.qbk ├── introduction.qbk ├── otherfeatures.qbk ├── platforms.qbk ├── posixspecifics.qbk ├── reference.qbk ├── revisionhistory.qbk ├── roadmap.qbk ├── scm.gif ├── scm.png ├── scm_pause.gif ├── scm_stop.gif ├── terminal.gif ├── todo.qbk ├── tutorial.qbk ├── useaspecthandler.qbk ├── win_buid_utility.cmd └── windowsspecifics.qbk ├── example ├── Jamfile.v2 ├── application_mode_select.cpp ├── handling_errors_ec_version.cpp ├── handling_errors_ex_version.cpp ├── limit_single_instance.cpp ├── limit_single_instance_boost_interprocess_named_mutex.cpp ├── limit_single_instance_callback.cpp ├── limit_single_instance_callback_with_global_context.cpp ├── my_own_termination_handler.cpp ├── my_own_wait_for_termination_request.cpp ├── myexception.cpp ├── new_application_mode │ ├── Jamfile.v2 │ ├── apache_httpd.cpp │ └── apache_httpd_mode.hpp ├── path.cpp ├── pid.cpp ├── selfpipe │ ├── Jamfile.v2 │ └── selfpipe.cpp ├── setup │ ├── initializers.hpp │ ├── posix │ │ ├── debian │ │ │ └── howto.txt │ │ ├── ubuntu │ │ │ ├── howto.txt │ │ │ └── skeleton │ │ └── work_in_progress.txt │ └── windows │ │ ├── setup.cpp │ │ └── setup │ │ └── service_setup.hpp ├── simple_application.cpp ├── simple_application_with_global_context.cpp ├── simple_server_application.cpp ├── simple_server_application_help.cpp ├── simple_server_application_with_auto_handler.cpp ├── simple_server_application_with_auto_handler_and_global_context.cpp ├── termination_handler.cpp ├── termination_handler_with_global_context.cpp ├── test.cpp ├── tutorial │ ├── Jamfile.v2 │ ├── main_stage1.cpp │ ├── main_stage2.cpp │ ├── main_stage3.cpp │ ├── main_stage4.cpp │ ├── myfunctor_stage1.hpp │ ├── myfunctor_stage2.hpp │ ├── myfunctor_stage3.hpp │ └── myfunctor_stage4.hpp ├── wait_for_termination_request.cpp └── work_queue │ ├── Jamfile.v2 │ ├── work_queue.cpp │ └── work_queue.hpp ├── include └── boost │ ├── application.hpp │ └── application │ ├── application_mode_register.hpp │ ├── aspect_map.hpp │ ├── aspects │ ├── args.hpp │ ├── limit_single_instance.hpp │ ├── path.hpp │ ├── pause_handler.hpp │ ├── process_id.hpp │ ├── resume_handler.hpp │ ├── run_mode.hpp │ ├── selfpipe.hpp │ ├── status.hpp │ ├── termination_handler.hpp │ └── wait_for_termination_request.hpp │ ├── auto_app.hpp │ ├── auto_handler.hpp │ ├── base_type.hpp │ ├── common_application.hpp │ ├── config.hpp │ ├── context.hpp │ ├── detail │ ├── application_impl.hpp │ ├── csbl.hpp │ ├── ensure_single_instance.hpp │ ├── posix │ │ ├── common_application_impl.hpp │ │ ├── limit_single_instance_impl.hpp │ │ ├── path_impl.hpp │ │ ├── process_id_impl.hpp │ │ ├── server_application_impl.hpp │ │ └── wait_for_termination_request_impl.hpp │ └── windows │ │ ├── common_application_impl.hpp │ │ ├── limit_single_instance_impl.hpp │ │ ├── path_impl.hpp │ │ ├── process_id_impl.hpp │ │ ├── server_application_impl.hpp │ │ └── wait_for_termination_request_impl.hpp │ ├── handler.hpp │ ├── launch.hpp │ ├── server_application.hpp │ ├── signal_binder.hpp │ ├── system_error.hpp │ └── version.hpp ├── index.html ├── test ├── Jamfile.v2 ├── args_aspect_test.cpp ├── aspect_map_test.cpp ├── auto_app_test.cpp ├── auto_handler_global_context_test.cpp ├── auto_handler_test.cpp ├── ensure_single_instance_test.cpp ├── global_context_test.cpp ├── handler_test.cpp ├── launch_test.cpp ├── myapp.cpp ├── myapp.h ├── myexception_test.cpp ├── path_aspect_test.cpp ├── signal_binder_test.cpp ├── simple_common_application_test.cpp ├── simple_server_application_test.cpp └── tunit_test.cpp └── vc11ide ├── application_mode_apache_httpd_mod.vcxproj ├── application_mode_apache_httpd_mod.vcxproj.filters ├── application_mode_select.vcxproj ├── application_mode_select.vcxproj.filters ├── boost_application.opensdf ├── boost_application.sln ├── boost_application.suo ├── boost_application.v11.suo ├── boost_application.v14.suo ├── limit_single_instance.vcxproj ├── limit_single_instance.vcxproj.filters ├── limit_single_instance_boost_interprocess_named_mutex.vcxproj ├── limit_single_instance_boost_interprocess_named_mutex.vcxproj.filters ├── limit_single_instance_callback.vcxproj ├── limit_single_instance_callback.vcxproj.filters ├── limit_single_instance_callback_with_global_context.vcxproj ├── limit_single_instance_callback_with_global_context.vcxproj.filters ├── my_own_termination_handler.filters ├── my_own_termination_handler.vcxproj ├── my_own_wait_for_termination_request.vcxproj ├── my_own_wait_for_termination_request.vcxproj.filters ├── myexception.vcxproj ├── myexception.vcxproj.filters ├── path.vcxproj ├── path.vcxproj.filters ├── pid.vcxproj ├── pid.vcxproj.filters ├── service_setup_ex.vcxproj ├── service_setup_ex.vcxproj.filters ├── simple_application.vcxproj ├── simple_application.vcxproj.filters ├── simple_application_with_global_context.vcxproj ├── simple_application_with_global_context.vcxproj.filters ├── simple_server_application.vcxproj ├── simple_server_application.vcxproj.filters ├── simple_server_application_with_auto_handler.vcxproj ├── simple_server_application_with_auto_handler.vcxproj.filters ├── simple_server_application_with_auto_handler_and_global_context.vcxproj ├── simple_server_application_with_auto_handler_and_global_context.vcxproj.filters ├── termination_handler.vcxproj ├── termination_handler.vcxproj.filters ├── termination_handler_with_global_context.vcxproj ├── termination_handler_with_global_context.vcxproj.filters ├── test_args_aspect_test.vcxproj ├── test_aspect_map_test.vcxproj ├── test_auto_app_test.vcxproj ├── test_auto_handler_global_context_test.vcxproj ├── test_auto_handler_test.vcxproj ├── test_ensure_single_instance_test.vcxproj ├── test_global_context_test.vcxproj ├── test_handler_test.vcxproj ├── test_launch_test.vcxproj ├── test_myexception_test.vcxproj ├── test_path_aspect_test.vcxproj ├── test_signal_binder_test.filters ├── test_signal_binder_test.vcxproj ├── test_simple_common_application_test.vcxproj ├── test_simple_server_application_test.vcxproj ├── test_tunit_test.vcxproj ├── time_based_plugin_job.vcxproj ├── time_based_plugin_job.vcxproj.filters ├── tutorial_stage1.vcxproj ├── tutorial_stage1.vcxproj.filters ├── tutorial_stage2.vcxproj ├── tutorial_stage2.vcxproj.filters ├── tutorial_stage3.vcxproj ├── tutorial_stage3.vcxproj.filters ├── tutorial_stage4.vcxproj ├── tutorial_stage4.vcxproj.filters ├── wait_for_termination_request.vcxproj ├── wait_for_termination_request.vcxproj.filters ├── work_queue.vcxproj └── work_queue.vcxproj.filters /.travis.yml: -------------------------------------------------------------------------------- 1 | # Use, modification, and distribution are 2 | # subject to the Boost Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | # 5 | # Copyright Antony Polukhin 2014. 6 | 7 | os: 8 | - linux 9 | 10 | env: 11 | - CXX_STANDARD=c++98 12 | - CXX_STANDARD=c++0x 13 | 14 | before_install: 15 | # Set this to the name of your Boost library 16 | # Autodetect library name by using the following code: - PROJECT_TO_TEST=`git rev-parse --show-toplevel` 17 | - PROJECT_TO_TEST=application 18 | # Autodetect branch 19 | - BRANCH_TO_TEST=$TRAVIS_BRANCH 20 | - BOOST_BRANCH_TO_TEST=master 21 | 22 | # From this point and below code is same for all the Boost libs 23 | # Cloning Boost libraries (fast nondeep cloning) 24 | - PROJECT_DIR=`pwd` 25 | - BOOST=$HOME/boost-local 26 | - git init $BOOST 27 | - cd $BOOST 28 | - git remote add --no-tags -t $BOOST_BRANCH_TO_TEST origin https://github.com/boostorg/boost.git 29 | - git fetch --depth=1 30 | - git checkout $BOOST_BRANCH_TO_TEST 31 | - git submodule update --init --merge 32 | - git remote set-branches --add origin $BOOST_BRANCH_TO_TEST 33 | - git pull --recurse-submodules 34 | - git submodule update --init 35 | - git checkout $BOOST_BRANCH_TO_TEST 36 | - git submodule foreach "git reset --quiet --hard; git clean -fxd" 37 | - git reset --hard; git clean -fxd 38 | - git status 39 | - rm -rf $BOOST/libs/$PROJECT_TO_TEST 40 | - mv $PROJECT_DIR/../Boost.Application/ $BOOST/libs/$PROJECT_TO_TEST 41 | - PROJECT_DIR=$BOOST/libs/$PROJECT_TO_TEST 42 | - ./bootstrap.sh 43 | - ./b2 headers 44 | 45 | script: 46 | - if [ "$CCFLAGS" != "" ]; then FLAGS="cxxflags=\"$CCFLAGS\" linkflags=\"$LINKFLAGS\""; else FLAGS=""; fi 47 | - cd $BOOST/libs/$PROJECT_TO_TEST/test/ 48 | # remove my env specific files 49 | - rm ../Jamroot.jam ../boost-build.jam 50 | # `--coverage` flags required to generate coverage info for Coveralls 51 | - ../../../b2 cxxflags="--coverage -std=$CXX_STANDARD" linkflags="--coverage" link=shared 52 | 53 | after_success: 54 | # Copying Coveralls data to a separate folder 55 | - mkdir -p $PROJECT_DIR/coverals 56 | - find ../../../bin.v2/ -name "*.gcda" -exec cp "{}" $PROJECT_DIR/coverals/ \; 57 | - find ../../../bin.v2/ -name "*.gcno" -exec cp "{}" $PROJECT_DIR/coverals/ \; 58 | 59 | # Preparing Coveralls data by 60 | # ... installing the tools 61 | - sudo apt-get install -qq python-yaml lcov 62 | # ... changind data format to a readable one 63 | - lcov --directory $PROJECT_DIR/coverals --base-directory ./ --capture --output-file $PROJECT_DIR/coverals/coverage.info 64 | 65 | # ... erasing /test/ /example/ folder data 66 | - cd $BOOST 67 | - lcov --remove $PROJECT_DIR/coverals/coverage.info "/usr*" "*/$PROJECT_TO_TEST/test/*" "*/$PROJECT_TO_TEST/tests/*" "*/$PROJECT_TO_TEST/examples/*" "*/$PROJECT_TO_TEST/example/*" -o $PROJECT_DIR/coverals/coverage.info 68 | 69 | # ... erasing data that is not related to this project directly 70 | - OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$PROJECT_TO_TEST\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'` 71 | - echo $OTHER_LIBS 72 | - eval "lcov --remove $PROJECT_DIR/coverals/coverage.info $OTHER_LIBS -o $PROJECT_DIR/coverals/coverage.info" 73 | 74 | # Sending data to Coveralls 75 | - cd $PROJECT_DIR 76 | - gem install coveralls-lcov 77 | - coveralls-lcov coverals/coverage.info 78 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.11) 2 | project(Boost.Application CXX) 3 | include(conan.cmake) 4 | 5 | set(CXX_STANDART 17) 6 | 7 | file(GLOB_RECURSE SRC_LIST ./include/**/*.cpp) 8 | file(GLOB_RECURSE HEADER_LIST ./include/**/*.hpp) 9 | 10 | file(GLOB_RECURSE TEST_SRC_LIST ./test/*.cpp) 11 | file(GLOB_RECURSE TEST_HEADER_LIST ./test/*.hpp) 12 | 13 | file(GLOB_RECURSE APP_SRC_LIST ./test/myapp.cpp) 14 | file(GLOB_RECURSE APP_HEADER_LIST ./test/myapp.hpp) 15 | 16 | conan_cmake_run(REQUIRES boost/1.70.0@conan/stable 17 | BASIC_SETUP 18 | BUILD missing) 19 | 20 | 21 | add_library(myapp STATIC ${APP_SRC_LIST} ${APP_HEADER_LIST}) 22 | 23 | 24 | include_directories(include) 25 | 26 | enable_testing() 27 | foreach(item ${TEST_SRC_LIST}) 28 | get_filename_component(temp_name ${item} NAME) 29 | if(NOT (${temp_name} STREQUAL myapp.cpp )) 30 | add_definitions(-DBOOST_TEST_STATIC_LINK -DBOOST_TEST_MAIN) 31 | add_executable(${temp_name} ${SRC_LIST} ${HEADER_LIST} ${item} ${TEST_HEADER_LIST}) 32 | target_link_libraries(${temp_name} ${CONAN_LIBS} rt myapp) 33 | add_test(NAME ${temp_name}_test COMMAND ${temp_name}) 34 | endif() 35 | endforeach() 36 | -------------------------------------------------------------------------------- /Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Copyright Rene Rivera 2007. 2 | # 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # (See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | # Usage: 8 | # 9 | # bjam [options | properties | targets] 10 | # 11 | # Options: 12 | # 13 | # --boost= The directotory of a Boost source tree. 14 | # Default; BOOST env var (if found) 15 | # Default; ../boost (if found) 16 | # 17 | # --boost-build= 18 | # The directory for the Boost.Build v2 files. 19 | # Default; BOOST_BUILD_PATH env var (if found) 20 | # Default; BOOST_BUILD env var (if found) 21 | # Default; /tools/build/v2 (if found) 22 | 23 | #~ If we have the Boost sources we can use the project... 24 | 25 | if [ GLOB $(BOOST) : [ modules.peek project : JAMFILE ] ] 26 | { 27 | use-project C:\\boost_1_54_0 : $(BOOST) ; 28 | } 29 | -------------------------------------------------------------------------------- /Jamroot.jam: -------------------------------------------------------------------------------- 1 | 2 | import modules ; 3 | 4 | local boost = [ modules.peek : BOOST ] ; 5 | 6 | project sandbox : requirements $(boost) ; 7 | 8 | # This seems to prevent some Boost.Build errors that otherwise occur :-( 9 | use-project C:\\boost_1_54_0 : $(boost) ; 10 | -------------------------------------------------------------------------------- /boost-build.jam: -------------------------------------------------------------------------------- 1 | # Copyright Rene Rivera 2007. 2 | # 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # (See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | # For instructions see Jamfile.v2, or "bjam --help". 8 | 9 | local rule if-has-file ( file + : dir * ) 10 | { 11 | local result ; 12 | if $(dir) 13 | { 14 | result = [ GLOB $(dir) : $(file) ] ; 15 | } 16 | return $(result[1]:P) ; 17 | } 18 | 19 | #~ Attempts to find the Boost source tree... 20 | 21 | local boost-src = [ if-has-file LICENSE_1_0.txt : 22 | [ MATCH --boost=(.*) : $(ARGV) ] 23 | $(BOOST) 24 | $(.boost-build-file:D)/../boost 25 | $(.boost-build-file:D)/../Trunk 26 | ] ; 27 | 28 | # error handling: 29 | if ! $(boost-src) 30 | { 31 | ECHO Unable to find the Boost source tree in the locations searched. ; 32 | ECHO Try setting the environment variable BOOST to point to your ; 33 | ECHO Boost tree, or else invoke bjam with the --boost=path option. ; 34 | ECHO The Boost include path will not be automatically set. ; 35 | ECHO The paths searched were [ MATCH --boost=(.*) : $(ARGV) ] $(BOOST) $(.boost-build-file:D)/../boost $(.boost-build-file:D)/../Trunk ; 36 | ECHO But the file LICENSE_1_0.txt was not found in any of them ; 37 | } 38 | 39 | #~ Attempts to find the Boost.Build files... 40 | 41 | local boost-build-src = [ if-has-file bootstrap.jam : 42 | [ MATCH --boost-build=(.*) : $(ARGV) ] 43 | $(BOOST_BUILD_PATH) 44 | $(BOOST_BUILD) 45 | $(boost-src)/tools/build/v2 46 | ] ; 47 | 48 | # error handling: 49 | if ! $(boost-build-src) 50 | { 51 | ECHO Unable to find the Boost.Build source tree in the locations searched. ; 52 | ECHO Try setting the environment variable BOOST_BUILD to point to your ; 53 | ECHO Boost.Build tree, or else invoke bjam with the --boost-build=path option. ; 54 | ECHO The paths searched were [ MATCH --boost-build=(.*) : $(ARGV) ] $(BOOST_BUILD_PATH) $(BOOST_BUILD) $(boost-src)/tools/build/v2 ; 55 | ECHO But bootstrap.jam was not found in any of these ; 56 | ECHO More failures will very likely follow... ; 57 | } 58 | 59 | #~ Set some common vars to refer to the Boost sources... 60 | 61 | BOOST ?= $(boost-src) ; 62 | BOOST_ROOT ?= $(boost-src) ; 63 | 64 | #~ And load up Boost.Build... 65 | 66 | boost-build $(boost-build-src) ; 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /doc/Jamfile.jam: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 Renato Tegon Forti 2 | # 3 | # Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #using boostbook ; 7 | #using quickbook ; 8 | #using doxygen ; 9 | 10 | using quickbook ; 11 | using boostbook ; 12 | using doxygen ; 13 | using xsltproc ; 14 | 15 | import set ; 16 | import doxygen ; 17 | import xsltproc ; 18 | import notfile ; 19 | import path ; 20 | 21 | project boost/libs/application/doc ; 22 | 23 | # 24 | # Common params for doxygen 25 | # 26 | 27 | local doxygen_params = 28 | PREDEFINED=BOOST_APPLICATINO_DOXYGEN 29 | HIDE_UNDOC_CLASSES=YES 30 | HIDE_UNDOC_MEMBERS=YES 31 | ; 32 | 33 | # 34 | # Ref Sessions Generation 35 | # 36 | 37 | doxygen autodoc_core 38 | : 39 | [ glob 40 | ../../../boost/application/aspect_map.hpp 41 | ../../../boost/application/context.hpp 42 | ../../../boost/application/handler.hpp 43 | ../../../boost/application/signal_binder.hpp 44 | ../../../boost/application/launch.hpp 45 | ] 46 | : 47 | $(doxygen_params) 48 | "boost.doxygen.reftitle=Core Reference" 49 | ; 50 | 51 | doxygen autodoc_modes 52 | : 53 | [ glob 54 | ../../../boost/application/common_application.hpp 55 | ../../../boost/application/server_application.hpp 56 | ] 57 | : 58 | $(doxygen_params) 59 | "boost.doxygen.reftitle=Application Modes Reference" 60 | ; 61 | 62 | doxygen autodoc_aspects 63 | : 64 | [ glob ../../../boost/application/aspects/*.hpp ] 65 | : 66 | $(doxygen_params) 67 | "boost.doxygen.reftitle=Aspects Reference" 68 | ; 69 | 70 | # 71 | # Docs Generation 72 | # 73 | 74 | boostbook standalone 75 | : 76 | application.qbk 77 | : 78 | autodoc_core 79 | autodoc_modes 80 | autodoc_aspects 81 | boost.root=../../../.. 82 | html.stylesheet=../../../../doc/src/boostbook.css 83 | ; 84 | 85 | -------------------------------------------------------------------------------- /doc/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/Thumbs.db -------------------------------------------------------------------------------- /doc/acknowledgements.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Acknowledgements] 8 | 9 | A special thanks goes to [*Vicente J. Botet Escriba] that helped a lot on all areas of this lib. 10 | 11 | Thanks to (chronological order): 12 | 13 | [*Antony Polukhin] for improvements on plug-in system module (shared_library), that now is a new library, see notes above.[br] 14 | [*Rodrigo Madera] for your comments, help and RM support.[br] 15 | [*Sergei Nikulov] for provided fixes and patches.[br] 16 | [*Benjamin Dieckmann] for your comments and help on posix side and the singleton implementation inside lib.[br] 17 | [*Stanislav Ivochkin] for your comments and self-pipe aspect design.[br] 18 | [*Julian Gonggrijp] for your comments to improving the ease of use.[br] 19 | [*Jarrad Waterloo] for your comments and directions. 20 | 21 | The first Boost.Application appears in 2011 labed as 'version alpha 1 (0.1)' and some people have helped on various areas that influenced Boost.Application. 22 | 23 | [endsect] 24 | 25 | -------------------------------------------------------------------------------- /doc/app.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/app.ai -------------------------------------------------------------------------------- /doc/app.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/app.gif -------------------------------------------------------------------------------- /doc/application.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [library Boost.Application 8 | [quickbook 1.5] 9 | [authors [Forti, Renato]] 10 | [copyright 2014 Dokfile Software Ltd.] 11 | [id application] 12 | [dirname application] 13 | [license 14 | Distributed under the Boost Software License, Version 1.0. 15 | (See accompanying file LICENSE_1_0.txt or copy at 16 | http://www.boost.org/LICENSE_1_0.txt) 17 | ] 18 | ] 19 | 20 | [include introduction.qbk] 21 | [include designoverview.qbk] 22 | [include apptypes.qbk] 23 | [include roadmap.qbk] 24 | [include context.qbk] 25 | [include aspects.qbk] 26 | [include useaspecthandler.qbk] 27 | [include handlingerrors.qbk] 28 | [include tutorial.qbk] 29 | [include customization.qbk] 30 | [include otherfeatures.qbk] 31 | [include windowsspecifics.qbk] 32 | [include posixspecifics.qbk] 33 | [include faq.qbk] 34 | [include dependencies.qbk] 35 | [include platforms.qbk] 36 | [include examples.qbk] 37 | [include reference.qbk] 38 | [include bibliography.qbk] 39 | [include todo.qbk] 40 | [include revisionhistory.qbk] 41 | [include acknowledgements.qbk] 42 | -------------------------------------------------------------------------------- /doc/apptypes.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Suported Application Types] 8 | 9 | Boost.Application supports basically 2 flavors of applications that can be: 10 | 11 | [section Common Application] 12 | This kind of application is a usual Interactive Terminal application. 13 | [endsect] 14 | 15 | [section Server Application] 16 | This kind of application generates a Service (Windows), or a background process/Daemon (Unix). 17 | [endsect] 18 | 19 | [note Both versions can be extended using the plugin system provided by library (see [@../html/boost_application/other_features.html#plugin_system 'Extending Application']) 20 | ] 21 | 22 | Other types of applications can be added in the future, e.g. Apache Module, IIS Module, FastCGI. 23 | 24 | [endsect] 25 | 26 | -------------------------------------------------------------------------------- /doc/aspect.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/aspect.ai -------------------------------------------------------------------------------- /doc/aspect.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/aspect.gif -------------------------------------------------------------------------------- /doc/aspects.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section:aspects Application Apects ] 8 | A central concept on Boost.Application is the 'aspects' that can be added to application context. 9 | 10 | Boost.Application provide a wide class of ready-to-use 'aspects' and user is free to customize or define anyone that he needs, basically we can classify the ready-to-use aspects in 2 groups: 11 | 12 | [table:sca Simple or Common that can be any class 13 | [[Aspect Name] [Aspect Contract Class] [Aspect Final Class] [Aspect Functionality]] 14 | [[args] [args] [args (same class)] [Provide functionality for handling arguments of the application]] 15 | [[path] [path] [path (same class)] [Provide functionality for handling paths of the application]] 16 | [[path] [process_id] [process_id (same class)] [Provide functionality for obtaining a PID of application process]] 17 | [[run_mode] [run_mode] [run_mode (same class)] [Provide information of application running mode (common or server)]] 18 | [[status] [status] [status (same class)] [Provide information about current satatus of application (sopped, running or paused)]] 19 | [[wait_for_termination_request] [wait_for_termination_request] [wait_for_termination_request_default_behaviour] [Provide functionality for wait for task completion]] 20 | 21 | ] 22 | 23 | [table:hc Handler, that has a callback associated to it 24 | [[Aspect Name] [Aspect Contract Class] [Aspect Final Class] [Aspect Functionality]] 25 | [[pause_handler] [pause_handler] [pause_handler_default_behaviour] [When 'pause' event is detected, fire a user defined callback]] 26 | [[resume_handler] [resume_handler] [resume_handler_default_behaviour] [When 'resume' event is detected, fire a user defined callback]] 27 | [[termination_handler] [termination_handler] [termination_handler_default_behaviour] [When 'stop' signal/event is detected, fire a user defined callback]] 28 | [[limit_single_instance] [limit_single_instance] [limit_single_instance_default_behaviour] [When single instance feature is enabled, fire a user defined callback to handle it]] 29 | 30 | ] 31 | 32 | To know how customize an Aspect, refer to [@../html/boost_application/customization.html#boost_application.customization.customize_handlers 'Customize Aspects'] 33 | 34 | 35 | [note 36 | Note that that the application launch tie 'run_mode' and 'status' aspects to application context in automatic way. 37 | ] 38 | 39 | For sample, the following code show the use of 'path' aspect. 40 | [import ../example/path.cpp] 41 | [path] 42 | 43 | [endsect] 44 | 45 | -------------------------------------------------------------------------------- /doc/bibliography.qbk: -------------------------------------------------------------------------------- 1 | 2 | [section Bibliography] 3 | 4 | This section lists all the bibliographic references cited by this documentation. 5 | 6 | * Andrei Alexandrescu. [@http://www.informit.com/articles/article.aspx?p=25298&seqNum=5 Multithreading and the C++ Type System] (Threads Synchronization) 7 | * Anthony Williams, Vicente J. Botet Escriba [@http://www.boost.org/doc/libs/1_55_0/doc/html/thread/synchronization.html Boost Threads Synchronization] (Threads Synchronization) 8 | * Arch D. Robison, Anton Malakhov, Artur Laksberg. [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3425.html Concurrent Unordered Associative Containers for C++] (Containers Concurrent Access) 9 | * Arch D. Robison, Anton Potapov, Anton Malakhov. [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3732.pdf Value-Oriented Concurrent Unordered Containers] (Containers Concurrent Access) 10 | * Arch D. Robison. [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3712.pdf Policy-Based Design for Safe Destruction in Concurrent Containers] (Containers Concurrent Access) 11 | * Dave Lennert. [@http://cjh.polyplex.org/software/daemon.pdf How To Write a UNIX Daemon] (Unix Daemon) 12 | * Devin Watson. [@http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html Linux Daemon Writing HOWTO] (Linux Daemon) 13 | * W. Richard Stevens, Stephen A. Rago. [@http://www.amazon.com/Programming-Environment-Addison-Wesley-Professional-Computing/dp/0321637739/ref=sr_1_1?s=books&ie=UTF8&qid=1379593264&sr=1-1&keywords=advanced+unix+programming+3rd+edition Advanced Programming in the UNIX Environment] (Unix Daemon) 14 | * Kevin Miller. [@http://www.amazon.com/Professional-NT-Services-Kevin-Miller/dp/1861001304/ref=sr_1_sc_1?ie=UTF8&qid=1398252097&sr=8-1-spell&keywords=profisional+nt+services Professional NT Services] (Windows Services) 15 | * Marshall Brain, Ronald D. Reeves. [@http://www.amazon.com/Programming-Environment-Addison-Wesley-Professional-Computing/dp/0321637739/ref=sr_1_1?s=books&ie=UTF8&qid=1379593264&sr=1-1&keywords=advanced+unix+programming+3rd+edition Win32 System Services: The Heart of Windows 98 and Windows 2000] (Windows Services) 16 | * Johnson M. Hart. [@http://www.amazon.com/Win32-System-Programming-Application-Developers/dp/0201703106/ref=pd_sim_b_15 Win32 System Programming: A Windows 2000 Application Developer's Guide] (Windows Services) 17 | * David Vandevoorde, Nicolai M. Josuttis. [@http://www.amazon.com/Templates-Complete-Guide-David-Vandevoorde/dp/0201734842/ref=sr_1_1?s=books&ie=UTF8&qid=1379592907&sr=1-1&keywords=c+++templates C++ Templates: The Complete Guide] (Templates stuff) 18 | * Davide Di Gennaro. [@http://www.amazon.com/Templates-Complete-Guide-David-Vandevoorde/dp/0201734842/ref=sr_1_1?s=books&ie=UTF8&qid=1379592907&sr=1-1&keywords=c+++templates Advanced C++ Metaprogramming] (Templates stuff) 19 | * Martin Reddy. [@http://www.amazon.com/API-Design-C-Martin-Reddy/dp/0123850037/ref=pd_sim_b_4 API Design for C++] (Plugin Systems) 20 | * Wikipedia. [@http://en.wikipedia.org/wiki/Unix_signal Unix Signal] (Unix Signals) 21 | * Enderunix. [@http://www.enderunix.org/docs/eng/daemon.php Unix Daemon Server Programming] (Unix Daemon) 22 | 23 | [endsect] 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/context.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section:context Application Context] 8 | A central concept on Boost.Application is the 'aspects' that can be added to application context. 9 | 10 | User is free to add any aspect to Application Context, and many operations are available (thread-safe) to manipulate the 'aspect pool' of application, refer to [@boost/application/entity/aspect_map.html 'Application Context (aspect_map class)'] reference to know more detail about provided methods. 11 | 12 | The application context can be a global (singleton) or local, which passes the 'context' as parameter to constructor of functor. 13 | 14 | The user is free to choose the best option to your application design. 15 | 16 | Here's a simple example of how to construct a application using global context: 17 | 18 | [import ../example/simple_application_with_global_context.cpp] 19 | [intro_global_context] 20 | 21 | Here's a simple example of how to construct a application using local context: 22 | 23 | [intro] 24 | 25 | [endsect] 26 | 27 | -------------------------------------------------------------------------------- /doc/customization.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | 8 | 9 | [section:customization Customization] 10 | 11 | 12 | [/ 13 | # -------------------------------------------------------------------------------- 14 | # customize_handlers 15 | # -------------------------------------------------------------------------------- 16 | ] 17 | 18 | [section:customize_handlers Customize Aspects] 19 | 20 | The '[*aspects]' concept allow user to customize, and extend library functionality in easy way. The diagram below shows the way to extend or create new aspect. 21 | 22 | [$aspect.gif] 23 | 24 | The '[*A]' shows the more complex aspects, that needs to meet a well defined interface, which is used internally by the application mode. 25 | 26 | On '[*B]' we have simplest aspect that can be any C++ class. 27 | 28 | Thus, the user can customize the default behavior of any handler. To do this, the user needs inheriting of contract handler class (abstract) that he wants to modify the behavior. 29 | 30 | For sample: The default behavior of wait_for_termination_request is unblock and exit of application. To change this behavior user can do as follows: 31 | 32 | [import ../example/my_own_wait_for_termination_request.cpp] 33 | [mownwfr] 34 | 35 | [endsect] 36 | 37 | [/ 38 | # -------------------------------------------------------------------------------- 39 | # customize_signal 40 | # -------------------------------------------------------------------------------- 41 | ] 42 | 43 | [section:customize_signal Customize Signals/Handlers] 44 | 45 | Like a handler, the user is free to customize the SIGNALS of application. 46 | 47 | [note 48 | The SIGNALS can not be customized when Windows Service (server application mode on windows) is used. 49 | 50 | Windows Service uses a completely different set of signals called 'events', so in this case you should customize 'pause', 'resume' and 'stop' handlers 51 | ] 52 | 53 | This feature allows user configure/add handlers for others SIGNALS. 54 | 55 | In this sample we will create a handler to SIGUSR2 POSIX signal. Note that this signal is not available on Windows. 56 | 57 | To do this user need inheriting of signal_manager class and add new signal bind, like: 58 | 59 | [import ../example/my_own_termination_handler.cpp] 60 | [myownsig] 61 | 62 | [endsect] 63 | 64 | 65 | [endsect] 66 | -------------------------------------------------------------------------------- /doc/dependencies.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Dependencies] 8 | 9 | The Boost.Application is a header only library, but it depends on the following libraries, and they must be available in order to compile programs that use Boost.Application: 10 | 11 | * Boost.System for the boost::system::error_code and boost::system::system_error classes. 12 | * Boost.Thread for creating a service thread and synchronization. Windows Service blocks the main thread so, then service thread function would need to be called from a boost thread. 13 | * Boost.Function, Bind for creation of a callbak system and others. 14 | * Boost.Asio for SIGNALs. 15 | * Boost.TypeIndex or std::type_index used by application context. 16 | * Boost.Filesystem to directory manipulation. 17 | * Boost.Uuid to application single instantiation. 18 | 19 | Furthermore, some of the examples also require the Boost.Program_options libraries in both sides (Window/Unix). 20 | 21 | [endsect] 22 | 23 | -------------------------------------------------------------------------------- /doc/designoverview.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section:design_overview Design overview] 8 | 9 | The design of Boost.Application is very modular and extensible. The components are very independents (loosely coupled). The 'aspects' concept allow user to customize, and extend library functionality in easy way. The key components are designed in independent way, and are tied at runtime (launch). 10 | 11 | The diagram below shows the components of Boost.Application. 12 | 13 | [$app.gif] 14 | 15 | [h5 Primary Components] 16 | 17 | The first component is the '[*User Defined Application Functor Class]'. This component is designed by the user, and the user must define the '[*application operator]' that will hold user application logic. 18 | 19 | The next components is the '[@../html/boost_application/suported_application_types.html Application Mode]', this component will create the needed structure to run the '[*User Defined Application Functor Class]' using desired mode, that can be a '[*server (Service/Daemon)]' or '[*common]' application type. The user can design a new '[*application mode]' if he want. 20 | 21 | The third component is responsible for receiving '[*signals]' from the operating system and run the '[*callback]' defined by the User. The User can customize this [@../html/boost_application/customization.html#boost_application.customization.customize_signal manager] if necessary. 22 | 23 | The next components is the '[@../html/boost_application/context.html Application Context]'. This Component hold the '[*Aspect Pool]' of application. User can customize an '[*Aspect]' provided by library, or/and can create new '[*Aspects]' to your own need. 24 | 25 | The last components is the '[*launch]'. The launch tie all components and execute the '[*User Application]'. 26 | 27 | [h5 Optional Components] 28 | 29 | On 'A' we have the 'service setup' component. This component is Windows specific, and has the code necessary to install and uninstall a Windows Service on Client machine. This component is not part of lib, and are provided on 'example/setup' folder. 30 | 31 | [endsect] 32 | 33 | 34 | -------------------------------------------------------------------------------- /doc/faq.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section F.A.Q.] 8 | 9 | [section Is Boost.Application thread-safe?] 10 | Not at all, applications singleton objects should not be called between threads, you should create several threads from it. 11 | 12 | The "shared_library" and "context" (aspect_map) classes are synchronized 13 | [endsect] 14 | 15 | [section How Unicode (Windows) is hadled?] 16 | Boost.Application supports Unicode on Windows. If the macro UNICODE or _UNICODE is defined, the Unicode version of Windows [@http://msdn.microsoft.com/en-us/library/windows/desktop/dd374081(v=vs.85).aspx API] is used when needed. 17 | [endsect] 18 | 19 | [section Can I customize a application SIGNALS?] 20 | Yes. The unique exception is Server Mode on Windows (Windows Service). 21 | 22 | The rule is that you need inherit of abstract contract class of aspect. Refer to [@../html/boost_application/customization.html#boost_application.customization.customize_signal 'Customize Signals/Handlers'] to know more. 23 | [endsect] 24 | 25 | [section Can I customize a library provided aspects?] 26 | Yes. All library provided aspects can be customized. 27 | 28 | The rule is that you need inherit of '[*signal_manager]' class and customize signals that you want. Refer to [@../html/boost_application/customization.html#boost_application.customization.customize_handlers 'Customize Aspects'] to know more. 29 | [endsect] 30 | 31 | [section Can I build another aspects to application?] 32 | Yes. An aspect is a normal object, that are stored in application context. Any C++ class can be an aspect. The only limitation is that you can have only one aspect of same type on application context. Refer to [@../html/boost_application/customization.html#boost_application.customization.customize_handlers 'Customize Aspects'] to know more. 33 | [endsect] 34 | 35 | [section Can I build another application mode? What is needed?] 36 | Yes. Use a '[*common]' mode as model, and changes the internal behaviour to what you want. You can create new aspects to it too. Refer to the example [@../html/boost_application/examples.html 'Apache httpd Application Mode' on session 'Library extension']. 37 | 38 | [tip 39 | An unofficial tutorial can be found at [@http://www.codeproject.com/Articles/695937/Creating-a-New-Application-Mode Code Project] 40 | ] 41 | 42 | [endsect] 43 | 44 | [section I have found a bug, how do I notify?] 45 | Please, send a e-mail with detailed description to re.tf[at]acm.org 46 | [endsect] 47 | 48 | [endsect] 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /doc/handlingerrors.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Handling errors] 8 | 9 | All class methods of Boost.Application that can generate an error has two version, one throws an exception of type boost::system::system_error, and another receive a boost::system::error_code variable 'ec' that would be set to the result of the operation, and no thrown an exception. 10 | 11 | [section Throws an 'system_error' version.] 12 | 13 | [import ../example/handling_errors_ex_version.cpp] 14 | [exver] 15 | 16 | [endsect] 17 | 18 | [section Set 'error_code' on error version.] 19 | 20 | [import ../example/handling_errors_ec_version.cpp] 21 | [ecver] 22 | 23 | [endsect] 24 | 25 | [endsect] 26 | 27 | -------------------------------------------------------------------------------- /doc/introduction.qbk: -------------------------------------------------------------------------------- 1 | [section:introduction Motivation] 2 | 3 | [caution This is not yet an official Boost C++ library. It wasn't reviewed and can't be downloaded from www.boost.org. This beta is available to boost community to know real interest and get comments for refinement.The intention is to submit library to formal review, if community think that it is interesting!] 4 | 5 | [note 6 | Starting with version 0.4.10 the plug-in module has been moved to a new library, called Boost.Plugin. 7 | 8 | [@https://github.com/apolukhin/Boost.Plugin Refer to Boost.Plugin] 9 | ] 10 | 11 | Sometimes we need run application for long time (e.g. Server Application), we need a mechanism to extend this application on runtime, and we need some facilities to access paths, ensure single instance instantiation on system, manage and catch signals and so on. 12 | 13 | This work is recurrent each time that we need build and deploy an application for particular system, and the way to do this, change a lot on each of these systems. 14 | 15 | For instance on Windows side we have 'services' and on Unix (POSIX) side we have 'daemons' that are used to build long-running executable applications (e.g. server) and these two APIs have no similarity. Thus, in this scenarios, is so much difficult to developer have your application running on Windows or on POSIX as server without a lot of work. The work is harder if we need run same application in both systems. 16 | 17 | Other problem raise when user want provide a way to extend your application using a plug-in mechanism. Like Service/Daemon, the shared modules (DSO) manipulation changes a lot on Windows and POSIX. 18 | 19 | Obtain simple thing like paths, arguments, manipulate signal, can be annoying, since it also don't has a common interface to do this on both systems. 20 | 21 | Boost.Application library aims to make significantly easier for the developer has your application runs in cross-platform (POSIX/Windows) environment. Boost.Application provides a application environment, or start point to any people that want a basic infrastructure to build an system application on Windows or Unix Variants (e.g. Solaris, Linux, MacOS). 22 | 23 | The Boost.Application uses behaviours modeled using 'aspects' concept proposed by 'Vicente J. Botet Escriba', that allow easy extension and customization of library components. The application modes uses these components internally to achieve the user desirable behaviours. 24 | 25 | Boost.Application provide many usefull ready-to-use features, e.g: 26 | 27 | * Run application as Windows Service; 28 | * Run application as UNIX/POSIX Daemon; 29 | * Plugin extension system; 30 | * Process(executable) Single instance Instantiation support; 31 | * Application SIGNAL/Callbacks customization; 32 | 33 | Here's a simple example of how to construct a application with Boost.Application: 34 | 35 | [import ../example/simple_application.cpp] 36 | [intro] 37 | 38 | Refer to [@../html/boost_application/roadmap.html "road map"] to know all required/optional steps to build a complete application using Boost.Application. To high level design overview, refer to [@../html/boost_application/design_overview.html '"design overview"'] 39 | 40 | [caution 41 | This documentatuion is in "Work in Progress" status. 42 | [@https://github.com/retf/Boost.Application DOWNLOAD THE LIB] 43 | ] 44 | 45 | [endsect] 46 | -------------------------------------------------------------------------------- /doc/otherfeatures.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | 8 | 9 | [section:other_features Other Features] 10 | 11 | 12 | [section Single Instance Feature] 13 | 14 | Some applications should only have a single instance running on a given operating system, Boost.Application provides a means to easily achieve this, as: 15 | 16 | User need define a unique identity to application. To do this the user need generate a [@http://www.boost.org/doc/libs/1_54_0/libs/uuid/ Boost.Uuid]. 17 | 18 | Optionally, the user can define a callback that will handle if a new instance of application should continue or exit. 19 | 20 | If this callback this is not set the default behavior is terminate. 21 | 22 | [import ../example/limit_single_instance_callback.cpp] 23 | [lsic] 24 | 25 | [endsect] 26 | 27 | [endsect] 28 | -------------------------------------------------------------------------------- /doc/platforms.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Supported compilers and platforms] 8 | 9 | The following platforms and compilers have been tested: 10 | 11 | * Win32 and Win64 using Visual C++ 11.0. 12 | * MinGW 4.7/4.8 13 | * Linux (2.6 kernels) using g++ 4.7.3. 14 | 15 | [endsect] 16 | 17 | -------------------------------------------------------------------------------- /doc/posixspecifics.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section POSIX specifics] 8 | 9 | Boost.Application have some specifics on each side, here the user that uses POSIX system need be aware. 10 | 11 | [/ 12 | NOW WE USE SELFPIPE ON wait_for_termination_request 13 | /] 14 | [/ 15 | [section Reserved SIGNAL(SIGUSR1) ] 16 | 17 | On POSIX the SIGNAL 'SIGUSR1' is used internaly be wait_for_termination_request (wait_for_termination_request_impl). 18 | 19 | If you need of 'SIGUSR1' on your application, you need customize an new wait_for_termination_request to use other signal (e.g. SIGUSR2), this is ease task, refer to: 20 | [@../html/boost_application/customization.html#boost_application.customization.customize_handlers 'Customize Aspects'] 21 | 22 | [endsect] 23 | /] 24 | 25 | [section Self-pipe ] 26 | 27 | The Self-pipe aspect can be used if user need more control of application. 28 | 29 | In default form a SIGNAL can interrupt your program at any time. E.g.: while any of your code is executing, a signal can arrive and interrupt it. While one signal is being handled, another signal (or the same signal), can arrive a second time and interrupt the first handler and so on. 30 | 31 | The problem is that the default signal handler is not re-entrant, and if you need that your signal handlers to be re-entrant, you can use Self-pipe aspect. 32 | 33 | In Self-pipe a 'pipe' is used as queue (you just write some bytes to one end and read some bytes from the other end), and this queue is used to notify the other side that an 'event', or a SIGNAL has arrived. 34 | 35 | User can use 'select' system call to monitors the reading end of this pipe, to know when SIGNAL arrives. 36 | 37 | [import ../example/selfpipe/selfpipe.cpp] 38 | [selfpipe] 39 | 40 | [note Note that Self-pipe is only available on POSIX platform. This aspect is platform dependent, and the use of it implies in use of some POSIX API, like select().] 41 | 42 | [endsect] 43 | 44 | [endsect] 45 | 46 | -------------------------------------------------------------------------------- /doc/reference.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Reference] 8 | 9 | [xinclude autodoc_core.xml] 10 | [xinclude autodoc_modes.xml] 11 | [xinclude autodoc_aspects.xml] 12 | 13 | [endsect] 14 | 15 | -------------------------------------------------------------------------------- /doc/revisionhistory.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Revision History] 8 | 9 | [h5 0.4.10] 10 | 11 | Starting with version 0.4.10 the plug-in module has been moved to a new library, called Boost.Plugin. 12 | 13 | [@https://github.com/apolukhin/Boost.Plugin Refer to Boost.Plugin] 14 | 15 | [h5 0.4.9] 16 | 17 | As proposed by Rodrigo Madera (Application RM), this: 18 | 19 | struct myapp { 20 | bool stop(boost::application::context& context); 21 | bool pause(boost::application::context& context); 22 | bool resume(boost::application::context& context); }; 23 | 24 | Become this: 25 | 26 | struct myapp { 27 | myapp(boost::application::context& context); 28 | 29 | bool stop(); 30 | bool pause(); 31 | bool resume(); 32 | }; 33 | 34 | [h5 0.4.8] 35 | 36 | New experimental module auto_handler.hpp 37 | This module simplifies the creation of the main 'handlers', like: stop, instace_aready_running, pause (windows only), resume (windows only) 38 | 39 | [h5 0.4.7] 40 | 41 | In line with the last Boost.TypeIndex (typeindex::type_index) 42 | 43 | [@https://github.com/boostorg/type_index TypeIndex] 44 | 45 | [h5 0.4.6] 46 | 47 | Removes Boost.Singularity dependence and add a global context 48 | 49 | [h5 0.4.5] 50 | 51 | In line with the last Boost.TypeIndex (typeind::type_index) 52 | 53 | [h5 0.4.4] 54 | 55 | New sample that show how user can extend the lib(new_application_mode) 56 | 57 | [@https://github.com/retf/Boost.Application Version 0.4.4.b (Current)] 58 | 59 | [h5 0.4.3] 60 | 61 | Changes on identification of application modes. 62 | 63 | [@https://github.com/retf/Boost.Application Version 0.4.3.b] 64 | 65 | [h5 0.4.2] 66 | 67 | aspect_map now is Thread-Safe. 68 | 69 | [@https://github.com/retf/Boost.Application Version 0.4.2.b] 70 | 71 | [h5 0.4.1] 72 | 73 | On POSIX/UNIX now we provide 'selfpipe' for SIGNALS handle like proposed by 'Stanislav Ivochkin' on mailing list discussion. 74 | 75 | [@https://github.com/retf/Boost.Application Version 0.4.1.b] 76 | 77 | [h5 0.4] 78 | 79 | Boost.Application 0.4 (Aspect Based Design) 80 | 81 | [@https://github.com/retf/Boost.Application Version 0.4.b] 82 | 83 | [h5 0.3] 84 | 85 | Boost.Application 0.3 (Old Interface) 86 | 87 | [@http://sourceforge.net/projects/boostapp/ Version 0.3.b] 88 | 89 | [h5 0.2] 90 | 91 | Boost.Application 0.2 (Concept Tests) 92 | 93 | [@http://sourceforge.net/projects/boostapp/ Version 0.2.pa Boost.Application_pre_alpha_2] 94 | 95 | [h5 0.1] 96 | 97 | Boost.Application 0.1 (Initial Prototype) 98 | 99 | [@http://sourceforge.net/projects/boostapp/ Version 0.1.pa Boost.Application_pre_alpha_1] 100 | 101 | [endsect] 102 | 103 | -------------------------------------------------------------------------------- /doc/roadmap.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2014 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section:roadmap Application Roadmap] 8 | 9 | Building an application with Boost.Application is a simple process, the basic roadmap steps are: 10 | 11 | [table:rs Roadmap Steps 12 | [[Step] [Optionally?] [Description]] 13 | [[A] [NO] [Define a 'functor' class for your application with an application operator]] 14 | [[B] [NO] [Create a 'context' for application. An context can be a global_context (singleton) or local context]] 15 | [[C] [YES] [Add desired 'aspects' to application context]] 16 | [[D] [YES] [Define a 'callback' for 'handler aspects' type. e.g.: stop, pause, resume]] 17 | [[E] [YES] [Define new 'apects', and add it to application context]] 18 | [[F] [YES] [Customize some ready to use 'apects']] 19 | [[G] [YES] [Customize 'SIGNALS' of application]] 20 | [[H] [NO] [Launch an application using some ready to use mode. ('common' or 'server' application)]] 21 | [[I] [YES] [In case of 'Windows Service' (Server mode on Windows), use example code to setup service]] 22 | [[J] [YES] [Use 'aspects' available in the context (that user add on step 'C' or 'E')]] 23 | ] 24 | 25 | A basic sample of server application can be: 26 | 27 | [import ../example/simple_server_application_help.cpp] 28 | [simplesrvrhelp] 29 | 30 | [note 31 | The 'application context' can be defined in 2 ways. [br] 32 | [br] 1. 'global_context' based version (that don't receive a 'context' as parameter on constructor). 33 | [br] 2. 'local' based version (that receive a 'context' of application as parameter on constructor, our case here.). 34 | ] 35 | 36 | [endsect] 37 | 38 | -------------------------------------------------------------------------------- /doc/scm.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/scm.gif -------------------------------------------------------------------------------- /doc/scm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/scm.png -------------------------------------------------------------------------------- /doc/scm_pause.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/scm_pause.gif -------------------------------------------------------------------------------- /doc/scm_stop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/scm_stop.gif -------------------------------------------------------------------------------- /doc/terminal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/doc/terminal.gif -------------------------------------------------------------------------------- /doc/todo.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section TODO/Future Releases ] 8 | 9 | This session present ideas from Boost Mailing list to be implemented on Boost.Application. If you have any idea, or want contribute with this lib in anyway, let me know! 10 | 11 | [section TODO] 12 | 13 | * Revise / improve (a lot) the documentation; 14 | 15 | [endsect] 16 | 17 | [section Future Releases] 18 | * Support for other types of applications, e.g. Apache Module, IIS Module, FastCGI. 19 | * Add support for Service/Daemon setup on core lib for unix/linux variants (Solaris, MacOSX, Ubuntu and so on) and Windows. 20 | ->Now Service/Daemon setup are provided as example on examples folder for Ubuntu and Windows. 21 | [endsect] 22 | 23 | [endsect] 24 | 25 | -------------------------------------------------------------------------------- /doc/useaspecthandler.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | Copyright 2013 Renato Tegon Forti 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | /] 6 | 7 | [section Using Application Handlers] 8 | 9 | In the Boost.Application, the '[*aspects handlers]' is the way that you can define a custom action to response some events, that are initiated by user via [@http://msdn.microsoft.com/en-us/library/windows/desktop/ms685150(v=vs.85).aspx SCM] or [@http://en.wikipedia.org/wiki/Unix_signal SIGNALS]. 10 | 11 | [table:ahc Pre-configured Handlers available in the library 12 | [[Aspect Name] [Aspect Contract Class] [Aspect Final Class] [Aspect Functionality]] 13 | [[pause_handler] [pause_handler] [pause_handler_default_behaviour] [When 'pause' event is detected, fire a user defined callback]] 14 | [[resume_handler] [resume_handler] [resume_handler_default_behaviour] [When 'resume' event is detected, fire a user defined callback]] 15 | [[termination_handler] [termination_handler] [termination_handler_default_behaviour] [When 'stop' signal/event is detected, fire a user defined callback]] 16 | [[limit_single_instance] [limit_single_instance] [limit_single_instance_default_behaviour] [When single instance feature is enabled, fire a user defined callback to handle it]] 17 | 18 | ] 19 | 20 | The user can define the handler like this: 21 | 22 | 23 | ``` 24 | bool stop(void) 25 | ``` 26 | 27 | Note that handlers must return a 'bool' to indicate to '[*application mode engine]', what action need be done, e.g.: 28 | 29 | ``` 30 | class myapp 31 | { 32 | public: 33 | // ... 34 | bool stop() 35 | { 36 | char type; 37 | do 38 | { 39 | std::cout << "Do you want to exit? [y/n]" << std::endl; 40 | std::cin >> type; 41 | } 42 | while( !std::cin.fail() && type!='y' && type!='n' ); 43 | 44 | if(type == 'y') 45 | { 46 | // return true to tell to the 'application mode engine' to stop application. 47 | // This implies: 48 | // 1. The 'application mode engine' will set the 'application 'status' aspect to status::stopped; 49 | // 2. The 'application mode engine' will signalize the 'application 'wait_for_termination_request' aspect to release. 50 | return true; 51 | } 52 | 53 | // tell the 'application mode engine' to continue application (ignore requisited action) 54 | return false; 55 | } 56 | // ... 57 | }; 58 | ``` 59 | [endsect] 60 | 61 | -------------------------------------------------------------------------------- /doc/win_buid_utility.cmd: -------------------------------------------------------------------------------- 1 | 2 | COPY E:\project.boost.app.v4.10.git\doc C:\boost_1_54_0\libs\application\doc 3 | COPY E:\project.boost.app.v4.10.git\example C:\boost_1_54_0\libs\application\example 4 | COPY E:\project.boost.app.v4.10.git\example\tutorial C:\boost_1_54_0\libs\application\example\tutorial 5 | COPY E:\project.boost.app.v4.10.git\example\selfpipe C:\boost_1_54_0\libs\application\example\selfpipe 6 | 7 | COPY E:\project.boost.app.v4.10.git\include\boost\application C:\boost_1_54_0\boost\application 8 | COPY E:\project.boost.app.v4.10.git\include\boost\application\aspects C:\boost_1_54_0\boost\application\aspects 9 | COPY E:\project.boost.app.v4.10.git\include\boost\application\detail C:\boost_1_54_0\boost\application\detail 10 | COPY E:\project.boost.app.v4.10.git\include\boost\application\detail\posix C:\boost_1_54_0\boost\application\detail\posix 11 | COPY E:\project.boost.app.v4.10.git\include\boost\application\detail\windows C:\boost_1_54_0\boost\application\detail\windows 12 | 13 | cd C:\boost_1_54_0\libs\application\doc\ 14 | bjam -------------------------------------------------------------------------------- /example/application_mode_select.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2013 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // ----------------------------------------------------------------------------- 7 | // This example shows how to add both application types support to application. 8 | // [use] 9 | // application_mode_select[.exe] -f (run as common/foreground) 10 | // application_mode_select[.exe] (run as server daemon) (default) 11 | // ----------------------------------------------------------------------------- 12 | 13 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace boost; 20 | namespace po = boost::program_options; 21 | 22 | class my_application_functor_class 23 | { 24 | public: 25 | 26 | my_application_functor_class(application::context& context) 27 | : context_(context) 28 | { 29 | } 30 | 31 | int operator()() 32 | { 33 | // your application logic here! 34 | // use ctrl to get state of your application... 35 | 36 | boost::shared_ptr modes 37 | = context_.find(); 38 | 39 | if(modes->mode() == application::common::mode()) 40 | { 41 | std::cout << "Yes am I a common application!" << std::endl; 42 | } 43 | 44 | if(modes->mode() == application::server::mode()) 45 | { 46 | std::cout << "Yes am I a server application!" << std::endl; 47 | } 48 | 49 | std::cout << "your application logic!" << std::endl; 50 | context_.find()->wait(); 51 | 52 | return 0; 53 | } 54 | 55 | bool stop() 56 | { 57 | std::cout << "stop!" << std::endl; 58 | return true; // return true to stop, false to ignore 59 | } 60 | 61 | private: 62 | application::context& context_; 63 | 64 | }; 65 | 66 | int main(int argc, char** argv) 67 | { 68 | // select application mode 69 | 70 | po::variables_map vm; 71 | po::options_description desc; 72 | 73 | desc.add_options() 74 | (",f", "run on foreground") 75 | ; 76 | 77 | po::store(po::parse_command_line(argc, argv, desc), vm); 78 | 79 | application::context app_context; 80 | my_application_functor_class app(app_context); 81 | 82 | // add termination handler 83 | 84 | application::handler<>::callback termination_callback 85 | = boost::bind(&my_application_functor_class::stop, &app); 86 | 87 | app_context.insert( 88 | boost::make_shared< 89 | application::termination_handler_default_behaviour>(termination_callback)); 90 | 91 | int result = 0; 92 | boost::system::error_code ec; 93 | 94 | // we will run like a daemon or like a common application (foreground) 95 | if (vm.count("-f")) 96 | { 97 | result = 98 | application::launch< 99 | application::common>(app, app_context, ec); 100 | } 101 | else 102 | { 103 | result = 104 | application::launch< 105 | application::server>(app, app_context, ec); 106 | } 107 | 108 | // check for error 109 | 110 | if(ec) 111 | { 112 | std::cout << "[E] " << ec.message() 113 | << " <" << ec.value() << "> " << std::cout; 114 | } 115 | 116 | return result; 117 | } 118 | 119 | -------------------------------------------------------------------------------- /example/handling_errors_ec_version.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // handling_errors_ec_version.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | 18 | #include 19 | #include 20 | 21 | using namespace boost; 22 | 23 | class myapp 24 | { 25 | public: 26 | 27 | // param 28 | int operator()(application::context& context) 29 | { 30 | return 0; 31 | } 32 | }; 33 | 34 | // main 35 | 36 | //[ecver 37 | // ... 38 | int main(int argc, char *argv[]) 39 | { 40 | myapp app; 41 | application::context app_context; 42 | 43 | boost::system::error_code ec; 44 | int result = application::launch(app, app_context, ec); 45 | 46 | if(ec) 47 | { 48 | std::cerr << "[E] " << ec.message() 49 | << " <" << ec.value() << "> " << std::cout; 50 | } 51 | 52 | return result; 53 | } 54 | //] 55 | 56 | -------------------------------------------------------------------------------- /example/handling_errors_ex_version.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // handling_errors_ex_version.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | 18 | #include 19 | #include 20 | 21 | using namespace boost; 22 | 23 | class myapp 24 | { 25 | public: 26 | 27 | // param 28 | int operator()(application::context& context) 29 | { 30 | return 0; 31 | } 32 | }; 33 | 34 | // main 35 | 36 | //[exver 37 | // ... 38 | int main(int argc, char *argv[]) 39 | { 40 | try 41 | { 42 | myapp app; 43 | application::context app_context; 44 | 45 | return application::launch(app, app_context); 46 | } 47 | catch(boost::system::system_error& se) 48 | { 49 | // error 50 | std::cerr << se.what() << std::endl; 51 | 52 | return 1; 53 | } 54 | } 55 | //] 56 | 57 | -------------------------------------------------------------------------------- /example/limit_single_instance.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // simple_application.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace boost; 24 | 25 | class myapp 26 | { 27 | public: 28 | 29 | myapp(application::context& context) 30 | : context_(context) 31 | { 32 | } 33 | 34 | // param 35 | int operator()() 36 | { 37 | boost::shared_ptr args = 38 | context_.find(); 39 | 40 | if(args) 41 | { 42 | const std::vector &arg_vector = args->arg_vector(); 43 | 44 | // only print args on screen 45 | for(std::vector::const_iterator it = arg_vector.begin(); 46 | it != arg_vector.end(); ++it) { 47 | std::cout << *it << std::endl; 48 | } 49 | } 50 | 51 | context_.find()->wait(); 52 | 53 | return 0; 54 | } 55 | 56 | private: 57 | 58 | application::context& context_; 59 | }; 60 | 61 | // main 62 | 63 | int main(int argc, char *argv[]) 64 | { 65 | application::context app_context; 66 | myapp app(app_context); 67 | 68 | boost::uuids::string_generator gen; 69 | 70 | app_context.insert( 71 | boost::make_shared( 72 | gen("{2F66E4AD-ECA5-475D-8784-4BAA329EF9F1}"))); 73 | 74 | return application::launch(app, app_context); 75 | } 76 | -------------------------------------------------------------------------------- /example/limit_single_instance_boost_interprocess_named_mutex.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // limit_single_instance_boost_interprocess_named_mutex.cpp : examples that 3 | // show how use Boost.Application to make a simplest interactive 4 | // (terminal) application 5 | // 6 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 7 | // development process. 8 | // ----------------------------------------------------------------------------- 9 | 10 | // Copyright 2011-2013 Renato Tegon Forti 11 | // 12 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 | // 15 | 16 | // ----------------------------------------------------------------------------- 17 | 18 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 19 | 20 | // Single instance mechanism that will support aspect based on 21 | // Boost.Interprocess Named Mutex too. 22 | #define ENABLE_BOOST_INTERPROCESS_NAMED_MUTEX 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace boost; 29 | 30 | // we have a bug here. on windows the destructor of 31 | // limit_single_instance_named_mutex_behaviour never is called, this cause 32 | // to Named Mutex to not be released, need fix 33 | 34 | class myapp 35 | { 36 | public: 37 | 38 | myapp(application::context& context) 39 | : context_(context) 40 | { 41 | } 42 | 43 | // param 44 | int operator()() 45 | { 46 | boost::shared_ptr args = 47 | context_.find(); 48 | 49 | if(args) 50 | { 51 | std::vector &arg_vector = args->arg_vector(); 52 | 53 | // only print args on screen 54 | for(std::vector::iterator it = arg_vector.begin(); 55 | it != arg_vector.end(); ++it) { 56 | std::cout << *it << std::endl; 57 | } 58 | } 59 | 60 | context_.find()->wait(); 61 | 62 | return 0; 63 | } 64 | 65 | private: 66 | application::context& context_; 67 | 68 | }; 69 | 70 | // main 71 | 72 | int main(int argc, char *argv[]) 73 | { 74 | application::context app_context; 75 | myapp app(app_context); 76 | 77 | boost::uuids::string_generator gen; 78 | 79 | app_context.insert( 80 | boost::make_shared( 81 | gen("{0F1164AD-ECA5-175D-8784-4BAA329EF9F2}"))); 82 | 83 | return application::launch(app, app_context); 84 | } 85 | -------------------------------------------------------------------------------- /example/my_own_wait_for_termination_request.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // my_own_wait_for_termination_request.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | #include 20 | #include 21 | 22 | using namespace boost; 23 | 24 | //[mownwfr 25 | class myapp 26 | { 27 | public: 28 | 29 | myapp(application::context& context) 30 | : context_(context) 31 | { 32 | } 33 | 34 | // param 35 | int operator()() 36 | { 37 | std::cout << "Test" << std::endl; 38 | 39 | /*<< Use your custon handler >>*/ 40 | context_.find()->wait(); 41 | 42 | return 0; 43 | } 44 | 45 | private: 46 | 47 | application::context& context_; 48 | }; 49 | 50 | // my made by hand behaviour 51 | class wait_for_termination_request_my_behaviour 52 | /*<< Inheriting of 'wait_for_termination_request' handler contract abstract class >>*/ 53 | : public application::wait_for_termination_request 54 | { 55 | public: 56 | 57 | /*<< Define your desired operation for 'wait' method >>*/ 58 | void wait(){ 59 | char type; 60 | do 61 | { 62 | std::cout << "Exit? [y/n]" << std::endl; 63 | std::cin >> type; 64 | } 65 | while( !std::cin.fail() && type!='y' ); 66 | } 67 | 68 | void proceed(){ 69 | // do nothing 70 | } 71 | }; 72 | 73 | // main 74 | 75 | int main(int argc, char *argv[]) 76 | { 77 | application::context app_context; 78 | myapp app(app_context); 79 | 80 | app_context.insert( 81 | boost::make_shared(argc, argv)); 82 | 83 | // if user do this, the default behavoiur will be ignored, 84 | // and the user behaviour will be executed by application::server 85 | /*<< Add your custon handler to context aspect pool of application >>*/ 86 | app_context.insert< application::wait_for_termination_request>( 87 | shared_ptr( 88 | new wait_for_termination_request_my_behaviour)); 89 | 90 | return application::launch(app, app_context); 91 | } 92 | //] -------------------------------------------------------------------------------- /example/myexception.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // myexception.cpp : examples that show how use your own exception on 3 | // Boost.Application 4 | // ----------------------------------------------------------------------------- 5 | 6 | // Copyright 2011-2013 Renato Tegon Forti 7 | // 8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | 12 | // ----------------------------------------------------------------------------- 13 | 14 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 15 | 16 | #include 17 | #include 18 | 19 | // you should probably add it to a header 20 | // -> 21 | 22 | // generic exception to be used insted Boost.System 23 | class myexception_base : public std::exception 24 | { 25 | public: 26 | // build a new exception using LastError on Windows and errno on Unix 27 | explicit myexception_base(const std::string& msg, unsigned int code) 28 | : message_(msg) , code_(code) 29 | { } 30 | 31 | virtual const char * what () const throw () { 32 | return message_.c_str(); 33 | } 34 | 35 | unsigned int code() const { 36 | return code_; 37 | } 38 | 39 | private: 40 | std::string message_; int code_; 41 | }; 42 | 43 | struct myexception : public myexception_base 44 | { 45 | myexception(const std::string& what, unsigned int error_code) 46 | : myexception_base(what, error_code) {} 47 | 48 | std::string mymessage() 49 | { 50 | std::stringstream msg; 51 | 52 | msg 53 | << what () 54 | << "(" 55 | << code() 56 | << ")" 57 | << std::endl; 58 | 59 | return msg.str(); 60 | } 61 | }; 62 | 63 | #define BOOST_APPLICATION_TROWN_MY_OWN_EXCEPTION throw myexception 64 | #include 65 | // <- 66 | 67 | using namespace boost; 68 | 69 | class myapp 70 | { 71 | public: 72 | 73 | myapp(application::context& context) 74 | : context_(context) 75 | { 76 | } 77 | 78 | int operator()() 79 | { 80 | if(!context_.find()) 81 | { 82 | throw myexception("custon error", 4121); 83 | } 84 | 85 | return 0; 86 | } 87 | 88 | private: 89 | application::context& context_; 90 | 91 | }; 92 | 93 | // main 94 | 95 | int main(int argc, char *argv[]) 96 | { 97 | try 98 | { 99 | application::context app_context; 100 | myapp app(app_context); 101 | 102 | // app_context.insert( 103 | // boost::make_shared(argc, argv)); 104 | 105 | return application::launch(app, app_context); 106 | } 107 | catch(myexception &e) 108 | { 109 | std::cerr << e.mymessage(); 110 | return 1; 111 | } 112 | 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /example/new_application_mode/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright Renato Tegon Forti 2011 - 2013. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # (See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt) 6 | # 7 | 8 | project 9 | : source-location . 10 | : requirements 11 | ../../../../Singularity 12 | linux:/usr/include/apache2/ 13 | linux:/usr/include/apr-1.0/ 14 | windows:"C:\Program Files (x86)\Apache Software Foundation\Apache2.2" 15 | ; 16 | 17 | lib apache_httpd 18 | : apache_httpd.cpp 19 | ; 20 | 21 | -------------------------------------------------------------------------------- /example/new_application_mode/apache_httpd.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 10 | 11 | #include 12 | #include 13 | #include "apache_httpd_mode.hpp" 14 | 15 | using namespace boost; 16 | 17 | class my_apache2_httpd_content_generator_mod 18 | { 19 | public: 20 | 21 | my_apache2_httpd_content_generator_mod(application::context& context) 22 | : context_(context) { } 23 | 24 | int operator()() 25 | { 26 | return 0; 27 | } 28 | 29 | std::string get() 30 | { 31 | context_.insert( 32 | boost::make_shared("text/html;charset=ascii")); 33 | 34 | std::stringstream htm; 35 | 36 | htm.str(""); 37 | htm << "" 38 | << " " 39 | << " Boost.Application Test" 40 | << " " 41 | << "" 42 | << " " 43 | << "

Hello Boost.Application Version " 44 | << application::library_version_string() << "!" 45 | << "

" 46 | << "
" 47 | << " Apache HTTPd Mod." 48 | << "
" 49 | << " " 50 | << "" 51 | ; 52 | 53 | boost::shared_ptr apachelog = context_.find(); 54 | if(apachelog) 55 | { 56 | // log something on apache log file 57 | apachelog->information("Page requested!"); 58 | } 59 | 60 | return htm.str(); 61 | } 62 | 63 | private: 64 | 65 | application::context& context_; 66 | 67 | }; 68 | 69 | // an application will be launched to handle each request that arrives. 70 | extern "C" int myhandle(request_rec *r) 71 | { 72 | application::context app_context; 73 | 74 | my_apache2_httpd_content_generator_mod app(app_context); 75 | 76 | app_context.insert( 77 | boost::make_shared("boostapp")); 78 | 79 | application::handler::callback my_http_get_verb 80 | = boost::bind( 81 | &my_apache2_httpd_content_generator_mod::get, &app); 82 | 83 | app_context.insert( 84 | boost::make_shared< 85 | http_get_verb_handler>(my_http_get_verb)); 86 | 87 | return application::launch(app, *r, app_context); 88 | } 89 | 90 | // register request function and mod on apache server 91 | BOOST_APPLICATION_APACHE_REGISTER_TEST_MY_MODE(myhandle, my_boost_app_mod) 92 | 93 | /* 94 | On httpd.conf, add: 95 | 96 | LoadModule my_boost_app_mod path_of_my_mod\application_mode_apache_httpd_mod.dll 97 | 98 | SetHandler boostapp 99 | 100 | 101 | And start apache httpd and on your favorite navegator, access: 102 | http://localhost:8080/boostapp 103 | 104 | You will see: Hello! 105 | 106 | 107 | 108 | Boost.Application Test 109 | 110 | 111 |

Hello!

112 | 113 | 114 | 115 | on it! 116 | 117 | */ 118 | -------------------------------------------------------------------------------- /example/path.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // path.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | #include 20 | #include 21 | 22 | 23 | using namespace boost; 24 | 25 | //[path 26 | class myapp 27 | { 28 | public: 29 | 30 | myapp(application::context& context) 31 | : context_(context) 32 | { 33 | } 34 | 35 | // param 36 | int operator()() 37 | { 38 | std::cout << "Test" << std::endl; 39 | 40 | /*<< Use 'path' aspect on your logic. Note that path is added by default >>*/ 41 | 42 | boost::shared_ptr path 43 | = context_.find(); 44 | 45 | std::cout << "executable_path : " << path->executable_path() << std::endl; 46 | std::cout << "current_path : " << path->current_path() << std::endl; 47 | std::cout << "executable_name : " << path->executable_name() << std::endl; 48 | std::cout << "executable_full_name : " << path->executable_full_name() << std::endl; 49 | std::cout << "executable_path_name : " << path->executable_path_name() << std::endl; 50 | std::cout << "home_path : " << path->home_path() << std::endl; 51 | std::cout << "app_data_path : " << path->app_data_path() << std::endl; 52 | std::cout << "config_path : " << path->config_path() << std::endl; 53 | std::cout << "temp_path : " << path->temp_path() << std::endl; 54 | 55 | // e.g.: "executable_path : E:\project.boost.app.v4\libs\application\vc11ide\Debug" 56 | // e.g.: "current_path : E:\project.boost.app.v4\libs\application\vc11ide" 57 | // e.g.: "executable_name : path" 58 | // e.g.: "executable_full_name : path.exe" 59 | // e.g.: "executable_path_name : E:\project.boost.app.v4\libs\application\vc11ide\Debug\path.exe" 60 | // e.g.: "home_path : C:\Users\somebody" 61 | // e.g.: "app_data_path : C:\Users\somebody\AppData\Roaming" 62 | // e.g.: "config_path : C:\Users\somebody\AppData\Roaming" 63 | // e.g.: "temp_path : C:\Users\somebody\Local\Temp" 64 | 65 | return 0; 66 | 67 | } 68 | 69 | private: 70 | application::context& context_; 71 | 72 | }; 73 | 74 | // main 75 | 76 | int main(int argc, char *argv[]) 77 | { 78 | application::context app_context; 79 | //myapp app(app_context); 80 | 81 | // std::cout << boost::has_trivial_copy::value << std::endl; 82 | 83 | application::auto_handler app(app_context); 84 | 85 | return application::launch(app, app_context); 86 | } 87 | 88 | //] 89 | -------------------------------------------------------------------------------- /example/pid.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // path.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | #include 20 | #include 21 | 22 | using namespace boost; 23 | 24 | //[pid 25 | class myapp 26 | { 27 | public: 28 | 29 | myapp(application::context& context) 30 | : context_(context) 31 | { 32 | } 33 | 34 | // param 35 | int operator()() 36 | { 37 | std::cout << "Test" << std::endl; 38 | 39 | boost::shared_ptr pid 40 | = context_.find(); 41 | 42 | std::cout << "pid : " << pid->pid() << std::endl; 43 | 44 | 45 | return 0; 46 | } 47 | 48 | private: 49 | application::context& context_; 50 | 51 | }; 52 | 53 | // main 54 | 55 | int main(int argc, char *argv[]) 56 | { 57 | application::context app_context; 58 | myapp app(app_context); 59 | 60 | return application::launch(app, app_context); 61 | } 62 | 63 | //] 64 | -------------------------------------------------------------------------------- /example/selfpipe/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright Renato Tegon Forti 2011 - 2013. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # (See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt) 6 | # 7 | 8 | project 9 | : source-location . 10 | : requirements 11 | ; 12 | 13 | # complex samples 14 | 15 | exe selfpipe 16 | : selfpipe.cpp 17 | : no linux:yes 18 | ; 19 | -------------------------------------------------------------------------------- /example/setup/initializers.hpp: -------------------------------------------------------------------------------- 1 | // application_initializers.hpp ----------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 05-04-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_APPLICATION_INITIALIZERS_HPP 17 | #define BOOST_APPLICATION_APPLICATION_INITIALIZERS_HPP 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | namespace boost { namespace application { 24 | 25 | // this is used by examples, check: 26 | // example/setup for more detail 27 | template 28 | class setup_type 29 | : public base_type 30 | { 31 | public: 32 | explicit setup_type(const String &s) 33 | : base_type(s) {} 34 | }; 35 | 36 | // setup session 37 | inline setup_type 38 | setup_arg(const character_types::char_type *s) 39 | { 40 | return setup_type(s); 41 | } 42 | 43 | inline setup_type 44 | setup_arg(const character_types::string_type &s) 45 | { 46 | return setup_type(s); 47 | } 48 | 49 | inline setup_type 50 | setup_arg(const boost::filesystem::path &p) 51 | { 52 | #if defined(BOOST_APPLICATION_STD_WSTRING) 53 | return setup_type(p.wstring()); 54 | #else 55 | return setup_type(p.string()); 56 | #endif 57 | } 58 | 59 | }} // boost::application 60 | 61 | #endif // BOOST_APPLICATION_SHARED_LIBRARY_INITIALIZERS_HPP 62 | 63 | -------------------------------------------------------------------------------- /example/setup/posix/debian/howto.txt: -------------------------------------------------------------------------------- 1 | Use 'ubuntu' istructions! -------------------------------------------------------------------------------- /example/setup/posix/ubuntu/howto.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/example/setup/posix/ubuntu/howto.txt -------------------------------------------------------------------------------- /example/setup/posix/work_in_progress.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/example/setup/posix/work_in_progress.txt -------------------------------------------------------------------------------- /example/simple_application.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // simple_application.cpp : examples that show how use 4 | // Boost.Application to make a simplest interactive (terminal) application 5 | // 6 | 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2014 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | //[intro 20 | #include 21 | #include 22 | 23 | using namespace boost; 24 | 25 | /*<>*/ 26 | class myapp 27 | { 28 | public: 29 | 30 | /*<>*/ 31 | myapp(application::context& context) 32 | : context_(context) 33 | { 34 | } 35 | 36 | /*<>*/ 37 | int operator()() 38 | { 39 | 40 | /*<>*/ 41 | application::csbl::shared_ptr myargs 42 | = context_.find(); 43 | 44 | if (myargs) 45 | { 46 | const std::vector &arg_vector = myargs->arg_vector(); 47 | 48 | // only print args on screen 49 | for(std::vector::const_iterator it = arg_vector.begin(); 50 | it != arg_vector.end(); ++it) { 51 | std::cout << *it << std::endl; 52 | } 53 | } 54 | 55 | /*<>*/ 56 | // code your application 57 | 58 | return 0; 59 | } 60 | 61 | private: 62 | 63 | /*<>*/ 64 | application::context& context_; 65 | 66 | }; 67 | 68 | // main 69 | 70 | int main(int argc, char *argv[]) 71 | { 72 | 73 | /*<>*/ 74 | application::context app_context; 75 | 76 | /*<>*/ 77 | myapp app(app_context); 78 | 79 | /*<>*/ 80 | app_context.insert( 81 | application::csbl::make_shared(argc, argv)); 82 | 83 | /*<>*/ 84 | return application::launch(app, app_context); 85 | } 86 | //] 87 | 88 | 89 | -------------------------------------------------------------------------------- /example/simple_application_with_global_context.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // simple_application_with_global_context.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // using global_context 5 | // 6 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 7 | // development process. 8 | // ----------------------------------------------------------------------------- 9 | 10 | // Copyright 2011-2013 Renato Tegon Forti 11 | // 12 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 | // 15 | 16 | // ----------------------------------------------------------------------------- 17 | 18 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 19 | 20 | //[intro_global_context 21 | 22 | #include 23 | #include 24 | 25 | using namespace boost; 26 | 27 | // singleton access 28 | 29 | /*<>*/ 30 | inline application::global_context_ptr this_application() { 31 | return application::global_context::get(); 32 | } 33 | 34 | // my functor application 35 | 36 | class myapp 37 | { 38 | public: 39 | 40 | /*<>*/ 41 | int operator()() 42 | { 43 | BOOST_APPLICATION_FEATURE_SELECT 44 | 45 | std::cout << "Test" << std::endl; 46 | shared_ptr myargs 47 | = this_application()->find(); 48 | 49 | if (myargs) 50 | { 51 | const std::vector &arg_vector = myargs->arg_vector(); 52 | 53 | // only print args on screen 54 | for(std::vector::const_iterator it = arg_vector.begin(); 55 | it != arg_vector.end(); ++it) { 56 | std::cout << *it << std::endl; 57 | } 58 | } 59 | 60 | 61 | /*<>*/ 62 | // code your application 63 | 64 | return 0; 65 | } 66 | 67 | }; 68 | 69 | // main 70 | 71 | int main(int argc, char *argv[]) 72 | { 73 | /*<>*/ 74 | application::global_context_ptr ctx = application::global_context::create(); 75 | 76 | /*<>*/ 77 | myapp app; 78 | 79 | /*<>*/ 80 | this_application()->insert( 81 | boost::make_shared(argc, argv)); 82 | 83 | /*<>*/ 84 | int ret = application::launch(app, this_application()); 85 | 86 | /*<>*/ 87 | application::global_context::destroy(); 88 | 89 | return ret; 90 | } 91 | //] 92 | 93 | -------------------------------------------------------------------------------- /example/simple_server_application_help.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // simple_server_application_help.cpp : help only 3 | // ----------------------------------------------------------------------------- 4 | 5 | // Copyright 2011-2013 Renato Tegon Forti 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | // ----------------------------------------------------------------------------- 12 | 13 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 14 | 15 | #include 16 | #include 17 | 18 | using namespace boost; 19 | 20 | //[simplesrvrhelp 21 | /*<< Define a 'functor' myapp class for our application >>*/ 22 | class myapp // [[a]] 23 | { 24 | public: 25 | 26 | /*<>*/ 27 | myapp(application::context& context) 28 | : context_(context) 29 | { 30 | } 31 | 32 | /*<< Define a application operator using 'param' signature >>*/ 33 | int operator()() // [[a]] 34 | { 35 | // Do some thing 36 | 37 | // [[k]] 38 | context_.find()->wait(); 39 | 40 | return 0; 41 | } 42 | 43 | // [[d]] 44 | /*<< Optionally, define a 'stop callback' handler, using 'param' signature >>*/ 45 | bool stop() 46 | { 47 | // Do some thing 48 | return true; // return true to stop, false to ignore 49 | } 50 | 51 | private: 52 | 53 | /*<>*/ 54 | application::context& context_; 55 | }; 56 | 57 | int main(int argc, char *argv[]) 58 | { 59 | 60 | /*<< Create a local 'context' for application that will hold our aspects >>*/ 61 | application::context app_context; // [[b]] 62 | 63 | /*<< Instatntiate our application using auto_handler, the 'stop' method will be automatically handled >>*/ 64 | application::auto_handler app(app_context); // [[a]] 65 | 66 | // my server aspects 67 | 68 | // [[c]] 69 | /*<< Add 'args aspect' to application context >>*/ 70 | app_context.insert( 71 | boost::make_shared(argc, argv)); 72 | 73 | // [[h]] 74 | /*<< Launch an application using server application mode >>*/ 75 | return application::launch(app, app_context); 76 | } 77 | //] 78 | 79 | -------------------------------------------------------------------------------- /example/termination_handler.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // limit_single_instance_callback.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace boost::application; 26 | 27 | class myapp 28 | { 29 | public: 30 | 31 | myapp(context& context) 32 | : context_(context) 33 | { 34 | } 35 | 36 | ~myapp() 37 | { 38 | std::cout << "~myapp()" << std::endl; 39 | } 40 | 41 | void work_thread() 42 | { 43 | while(1) 44 | { 45 | boost::this_thread::sleep(boost::posix_time::seconds(2)); 46 | std::cout << "running" << std::endl; 47 | } 48 | } 49 | 50 | // param 51 | int operator()() 52 | { 53 | std::cout << "operator()" << std::endl; 54 | 55 | // using [state] 56 | 57 | /* 58 | std::shared_ptr state = 59 | context.get_aspect(); 60 | 61 | while(state->state() != status::stopped) 62 | { 63 | boost::this_thread::sleep(boost::posix_time::seconds(2)); 64 | std::cout << "running" << std::endl; 65 | } 66 | */ 67 | 68 | // or using [wait_for_termination_request] 69 | 70 | // launch a work thread 71 | boost::thread thread(boost::bind(&myapp::work_thread, this)); 72 | 73 | context_.find()->wait(); 74 | 75 | return 0; 76 | } 77 | 78 | bool stop() 79 | { 80 | char type; 81 | do 82 | { 83 | std::cout << "Do you want to exit? [y/n]" << std::endl; 84 | std::cin >> type; 85 | } 86 | while( !std::cin.fail() && type!='y' && type!='n' ); 87 | 88 | if(type == 'y') 89 | // tell to app to continue. 90 | return true; 91 | 92 | // tell to app to exit. 93 | return false; 94 | } 95 | 96 | private: 97 | 98 | context& context_; 99 | 100 | }; 101 | 102 | // main 103 | 104 | int main(int argc, char *argv[]) 105 | { 106 | context app_context; 107 | myapp app(app_context); 108 | 109 | handler<>::callback stop 110 | = boost::bind(&myapp::stop, &app); 111 | 112 | app_context.insert( 113 | boost::make_shared(stop)); 114 | 115 | return launch(app, app_context); 116 | } 117 | -------------------------------------------------------------------------------- /example/termination_handler_with_global_context.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // limit_single_instance_callback.cpp : examples that show how use 3 | // Boost.Application to make a simplest interactive (terminal) application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace boost; 26 | 27 | 28 | // singleton access 29 | 30 | inline application::global_context_ptr this_application() { 31 | return application::global_context::get(); 32 | } 33 | 34 | 35 | class myapp 36 | { 37 | public: 38 | 39 | ~myapp() 40 | { 41 | std::cout << "~myapp()" << std::endl; 42 | } 43 | 44 | void work_thread() 45 | { 46 | while(1) 47 | { 48 | boost::this_thread::sleep(boost::posix_time::seconds(2)); 49 | std::cout << "running" << std::endl; 50 | } 51 | } 52 | 53 | // param 54 | int operator()() 55 | { 56 | std::cout << "operator()" << std::endl; 57 | 58 | // using [state] 59 | 60 | /* 61 | std::shared_ptr state = 62 | context.get_aspect(); 63 | 64 | while(state->state() != status::stopped) 65 | { 66 | boost::this_thread::sleep(boost::posix_time::seconds(2)); 67 | std::cout << "running" << std::endl; 68 | } 69 | */ 70 | 71 | // or using [wait_for_termination_request] 72 | 73 | // launch a work thread 74 | boost::thread thread(boost::bind(&myapp::work_thread, this)); 75 | 76 | this_application()->find()->wait(); 77 | 78 | return 0; 79 | } 80 | 81 | bool stop() 82 | { 83 | char type; 84 | do 85 | { 86 | std::cout << "Do you want to exit? [y/n]" << std::endl; 87 | std::cin >> type; 88 | } 89 | while( !std::cin.fail() && type!='y' && type!='n' ); 90 | 91 | if(type == 'y') 92 | // tell to app to continue. 93 | return true; 94 | 95 | // tell to app to exit. 96 | return false; 97 | } 98 | 99 | }; 100 | 101 | // main 102 | 103 | int main(int argc, char *argv[]) 104 | { 105 | myapp app; 106 | 107 | application::global_context_ptr ctx = application::global_context::create(); 108 | 109 | application::handler<>::callback callback 110 | = boost::bind(&myapp::stop, &app); 111 | 112 | this_application()->insert( 113 | boost::make_shared(callback)); 114 | 115 | int ret = application::launch(app, ctx); 116 | 117 | application::global_context::destroy(); 118 | 119 | return ret; 120 | } 121 | -------------------------------------------------------------------------------- /example/test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // ----------------------------------------------------------------------------- 7 | // simple compiler test 8 | // ----------------------------------------------------------------------------- 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | using namespace boost::application; 16 | 17 | int main(int argc, char* argv[]) 18 | { 19 | boost::system::error_code ec; 20 | 21 | while(1) 22 | { 23 | boost::this_thread::sleep(boost::posix_time::seconds(1)); 24 | std::cout << "runing..."; 25 | } 26 | 27 | return 1; 28 | } 29 | -------------------------------------------------------------------------------- /example/tutorial/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright Renato Tegon Forti 2011 - 2013. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # (See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt) 6 | # 7 | 8 | project 9 | : source-location . 10 | : requirements 11 | ; 12 | 13 | # tutorial samples 14 | 15 | exe main_stage1 16 | : main_stage1.cpp 17 | ; 18 | 19 | exe main_stage2 20 | : main_stage2.cpp 21 | ; 22 | 23 | exe main_stage3 24 | : main_stage3.cpp 25 | ; 26 | 27 | exe main_stage4 28 | : main_stage4.cpp 29 | ; -------------------------------------------------------------------------------- /example/tutorial/main_stage1.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, refer to 'last stage' to see a code that 10 | // can be compiled. 11 | // 12 | 13 | #include "myfunctor_stage1.hpp" 14 | 15 | //[tutorialcpps1 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | /*<< Your application context that hold a 'aspect' pool >>*/ 20 | application::context app_context; 21 | 22 | /*<< Your application functor instance >>*/ 23 | myapp app(app_context); 24 | 25 | /*<< Starts the application as a common application type. >>*/ 26 | return application::launch(app, app_context); 27 | } 28 | 29 | //] 30 | 31 | -------------------------------------------------------------------------------- /example/tutorial/main_stage2.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, refer to 'last stage' to see a code that 10 | // can be compiled. 11 | // 12 | 13 | #include "myfunctor_stage2.hpp" 14 | 15 | //[tutorialcpps2 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | application::context app_context; 20 | 21 | /*<< Tie stop to termination_handler using default behaviour >>*/ 22 | application::auto_handler app(app_context); 23 | 24 | /*<< Starts the application as a common application type. >>*/ 25 | return application::launch(app, app_context); 26 | } 27 | 28 | //] 29 | 30 | -------------------------------------------------------------------------------- /example/tutorial/main_stage3.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, refer to 'last stage' to see a code that 10 | // can be compiled. 11 | // 12 | 13 | #include "myfunctor_stage3.hpp" 14 | 15 | //[tutorialcpps3 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | application::context app_context; 20 | 21 | /*<< Tie stop to termination_handler using default behaviour >>*/ 22 | application::auto_handler app(app_context); 23 | 24 | /*<< Note that now we are using 'application::server' as template param >>*/ 25 | return application::launch(app, app_context); 26 | } 27 | 28 | //] 29 | 30 | -------------------------------------------------------------------------------- /example/tutorial/main_stage4.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, this is the 'last stage'. 10 | // 11 | 12 | #include "myfunctor_stage4.hpp" 13 | 14 | //[tutorialcpps4 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | /*<< Application Context >>*/ 19 | application::context app_context; 20 | 21 | /*<< Tie stop, pause, resume handlers using default behaviour >>*/ 22 | application::auto_handler app(app_context); 23 | 24 | /*<< Path manipulation aspect, to be used to get executable module path to use in log >>*/ 25 | app_context.insert( 26 | boost::make_shared()); 27 | 28 | /*<< Arg manipulation aspect >>*/ 29 | app_context.insert( 30 | boost::make_shared(argc, argv)); 31 | 32 | /*<< Note that now we are using 'application::server' as template param >>*/ 33 | return application::launch(app, app_context); 34 | } 35 | 36 | //] 37 | 38 | -------------------------------------------------------------------------------- /example/tutorial/myfunctor_stage1.hpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, refer to 'last stage' to see a code that 10 | // can be compiled. 11 | // 12 | 13 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 14 | 15 | #include 16 | #include 17 | 18 | using namespace boost; 19 | 20 | //[tutorials1 21 | 22 | /*<< Your application functor class >>*/ 23 | class myapp 24 | { 25 | public: 26 | 27 | myapp(application::context& context) 28 | : context_(context) 29 | { 30 | } 31 | 32 | /*<< Application operator, this is like a 'main' function >>*/ 33 | int operator()() 34 | { 35 | // your application logic here! 36 | return 0; 37 | } 38 | 39 | private: 40 | application::context& context_; 41 | 42 | }; 43 | 44 | //] 45 | 46 | -------------------------------------------------------------------------------- /example/tutorial/myfunctor_stage2.hpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, refer to 'last stage' to see a code that 10 | // can be compiled. 11 | // 12 | 13 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 14 | 15 | 16 | #include 17 | #include 18 | 19 | using namespace boost; 20 | 21 | //[tutorials2 22 | 23 | class myapp 24 | { 25 | public: 26 | 27 | myapp(application::context& context) 28 | : context_(context) 29 | { 30 | } 31 | 32 | int operator()() 33 | { 34 | /*<< Retrieves 'status' aspect from your context >>*/ 35 | boost::shared_ptr st = 36 | context_.find(); 37 | 38 | /*<< Check 'aspect' status 'state' >>*/ 39 | while(st->state() != application::status::stopped) 40 | { 41 | /*<< Your application loop body >>*/ 42 | boost::this_thread::sleep(boost::posix_time::seconds(1)); 43 | // your application logic here! 44 | } 45 | 46 | return 0; 47 | } 48 | 49 | // check in next stage 50 | bool stop() 51 | { 52 | return true; 53 | } 54 | 55 | private: 56 | application::context& context_; 57 | 58 | }; 59 | 60 | //] 61 | 62 | -------------------------------------------------------------------------------- /example/tutorial/myfunctor_stage3.hpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, refer to 'last stage' to see a code that 10 | // can be compiled. 11 | // 12 | 13 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 14 | 15 | #include 16 | #include 17 | 18 | using namespace boost; 19 | 20 | //[tutorials3 21 | 22 | class myapp 23 | { 24 | public: 25 | 26 | myapp(application::context& context) 27 | : context_(context) 28 | { 29 | } 30 | 31 | int operator()() 32 | { 33 | context_.find()->wait(); 34 | return 0; 35 | } 36 | 37 | /*<< Define your 'stop' handler that will be called when the 'stop' event will be fired. >>*/ 38 | bool stop() 39 | { 40 | std::cout << "Stoping my application..." << std::endl; 41 | 42 | /*<< return true to stop, false to ignore >>*/ 43 | return true; 44 | } 45 | 46 | private: 47 | application::context& context_; 48 | 49 | }; 50 | 51 | //] 52 | 53 | -------------------------------------------------------------------------------- /example/tutorial/myfunctor_stage4.hpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | 3 | // Copyright 2011-2013 Renato Tegon Forti 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | 9 | // This file is part of tutorial, refer to 'last stage' to see a code that 10 | // can be compiled. 11 | // 12 | 13 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 14 | 15 | #include 16 | #include 17 | 18 | using namespace boost; 19 | 20 | //[tutorials4 21 | 22 | class myapp 23 | { 24 | public: 25 | 26 | myapp(application::context& context) 27 | : context_(context) 28 | { 29 | } 30 | 31 | int operator()() 32 | { 33 | std::string logfile 34 | = context_.find()->executable_path().string() + "/log.txt"; 35 | 36 | my_log_file_.open(logfile.c_str()); 37 | my_log_file_ << "Start Log..." << std::endl; 38 | 39 | /*<< Here we use wait_for_termination_request instead application loop >>*/ 40 | context_.find()->wait(); 41 | 42 | return 0; 43 | } 44 | 45 | /*<< The 'stop' handler, available on windows and posix >>*/ 46 | bool stop() 47 | { 48 | my_log_file_ << "Stoping my application..." << std::endl; 49 | my_log_file_.close(); 50 | 51 | /*<< Return true to resume, false to tell to application mode engine to ignore the event >>*/ 52 | return true; 53 | } 54 | 55 | /*<< The 'pause' handler, available on windows only, ignored on posix >>*/ 56 | bool pause() 57 | { 58 | my_log_file_ << "Pause my application..." << std::endl; 59 | 60 | /*<< Return true to resume, false to tell to application mode engine to ignore the event >>*/ 61 | return true; 62 | } 63 | 64 | /*<< The 'resume' handler, available on windows only, ignored on posix >>*/ 65 | bool resume() 66 | { 67 | my_log_file_ << "Resume my application..." << std::endl; 68 | 69 | /*<< Return true to resume, false to tell to application mode engine to ignore the event >>*/ 70 | return true; 71 | } 72 | 73 | private: 74 | application::context& context_; 75 | 76 | /*<< Our simple log >>*/ 77 | std::ofstream my_log_file_; 78 | 79 | }; 80 | 81 | //] 82 | 83 | -------------------------------------------------------------------------------- /example/wait_for_termination_request.cpp: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------------- 2 | // wait_for_termination_request.cpp : examples that show how use 3 | // Boost.Application to make a application 4 | // 5 | // Note 1: The Boost.Application (Aspects v4) and this sample are in 6 | // development process. 7 | // ----------------------------------------------------------------------------- 8 | 9 | // Copyright 2011-2013 Renato Tegon Forti 10 | // 11 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 | // 14 | 15 | // ----------------------------------------------------------------------------- 16 | 17 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 18 | 19 | #include 20 | #include 21 | 22 | using namespace boost; 23 | 24 | class myapp 25 | { 26 | public: 27 | 28 | myapp(application::context& context) 29 | : context_(context) 30 | { 31 | } 32 | 33 | // param 34 | int operator()() 35 | { 36 | std::cout << "Test" << std::endl; 37 | boost::shared_ptr myargs 38 | = context_.find(); 39 | 40 | if (myargs) 41 | { 42 | const std::vector &arg_vector = myargs->arg_vector(); 43 | 44 | // only print args on screen 45 | for(std::vector::const_iterator it = arg_vector.begin(); 46 | it != arg_vector.end(); ++it) { 47 | std::cout << *it << std::endl; 48 | } 49 | } 50 | 51 | context_.find()->wait(); 52 | 53 | return 0; 54 | } 55 | 56 | private: 57 | application::context& context_; 58 | }; 59 | 60 | // main 61 | 62 | int main(int argc, char *argv[]) 63 | { 64 | application::context app_context; 65 | myapp app(app_context); 66 | 67 | app_context.insert( 68 | boost::make_shared(argc, argv)); 69 | 70 | return application::launch(app, app_context); 71 | } 72 | -------------------------------------------------------------------------------- /example/work_queue/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright Renato Tegon Forti 2011 - 2013. 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # (See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt) 6 | # 7 | 8 | project 9 | : source-location . 10 | : requirements 11 | /boost/timer//boost_timer 12 | ; 13 | 14 | # complex samples 15 | 16 | exe work_queue 17 | : work_queue.cpp 18 | ; 19 | 20 | -------------------------------------------------------------------------------- /example/work_queue/work_queue.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2013 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #ifndef BOOST_APPLICATION_WORK_QUEUE_HPP 9 | #define BOOST_APPLICATION_WORK_QUEUE_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | // work_queue class 16 | // NWorkers : nuber of worker threads 17 | // provide 0 to use available cores of machine 18 | template 19 | class work_queue 20 | { 21 | public: 22 | 23 | work_queue() 24 | { 25 | work_ctrl_ = new boost::asio::io_service::work(io_service_); 26 | 27 | int workers = boost::thread::hardware_concurrency(); 28 | if(NWorkers > 0) 29 | workers = NWorkers; 30 | 31 | for (std::size_t i = 0; i < workers; ++i) 32 | { 33 | threads_.create_thread(boost::bind(&boost::asio::io_service::run, &io_service_)); 34 | } 35 | } 36 | 37 | virtual ~work_queue() 38 | { 39 | delete work_ctrl_; 40 | } 41 | 42 | template 43 | void add_task(TTask task) 44 | { 45 | // c++11 46 | // io_service_.dispatch(std::move(task)); 47 | io_service_.dispatch(task); 48 | } 49 | 50 | private: 51 | 52 | boost::asio::io_service io_service_; 53 | boost::thread_group threads_; 54 | 55 | boost::asio::io_service::work *work_ctrl_; 56 | }; 57 | 58 | #endif // BOOST_APPLICATION_WORK_QUEUE_HPP 59 | 60 | 61 | -------------------------------------------------------------------------------- /include/boost/application.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Renato Tegon Forti 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_APPLICATION_HPP 8 | #define BOOST_APPLICATION_HPP 9 | 10 | /// \file boost/application.hpp 11 | /// \brief Includes all the headers of the Boost.Application library. 12 | 13 | // config 14 | #include 15 | #include 16 | // application 17 | #include 18 | #include 19 | #include 20 | #include 21 | // #include 22 | // application/aspects 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #ifdef BOOST_HAS_PRAGMA_ONCE 31 | # pragma once 32 | #endif 33 | 34 | #endif // BOOST_APPLICATION_HPP 35 | -------------------------------------------------------------------------------- /include/boost/application/application_mode_register.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Renato Tegon Forti. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_APPLICATION_MODES_REGISTER_HPP 8 | #define BOOST_APPLICATION_MODES_REGISTER_HPP 9 | 10 | #include 11 | #ifdef BOOST_HAS_PRAGMA_ONCE 12 | # pragma once 13 | #endif 14 | 15 | /// \file boost/application/application_mode_register.hpp 16 | /// \brief Contains a template function that generate a unique identifier 17 | /// for each application mode 18 | 19 | namespace boost { namespace application { 20 | 21 | /*! 22 | * Creates a unique identifier generator for each application mode, e.g.: 23 | * common, server and so on. 24 | * 25 | * \b Examples: 26 | * \code 27 | * struct my_new_mode { 28 | * static int mode() { 29 | * static int id = new_run_mode(); 30 | * return id; 31 | * } 32 | * }; 33 | * \endcode 34 | * 35 | * \return T that holds an new generated unique identifier to be used on 36 | * application mode. 37 | */ 38 | template 39 | T new_run_mode() { 40 | static boost::atomic id(-1); 41 | return ++id; 42 | } 43 | 44 | }} // boost::application 45 | 46 | #endif // BOOST_APPLICATION_MODES_REGISTER_HPP 47 | -------------------------------------------------------------------------------- /include/boost/application/aspects/args.hpp: -------------------------------------------------------------------------------- 1 | // args.hpp -----------------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 14-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_ARGS_ASPECT_HPP 17 | #define BOOST_APPLICATION_ARGS_ASPECT_HPP 18 | 19 | #include 20 | #include 21 | 22 | namespace boost { namespace application { 23 | 24 | /*! 25 | * \brief This aspect class handle application args in more friedly way. 26 | * 27 | * An aspect that will hold args, and provide a easy way to access they 28 | * or user can extrat args from it to use with Program_options, 29 | * getopts or argp and so on. 30 | * 31 | */ 32 | template 33 | class args_ 34 | { 35 | public: 36 | 37 | // string types to be used internaly to handle unicode on windows 38 | typedef CharType char_type; 39 | typedef std::basic_string string_type; 40 | 41 | /*! 42 | * Constructs an args_. 43 | * 44 | * \param argc An argc from main. 45 | * \param argc An argv from main. 46 | */ 47 | args_(int argc, char_type *argv[]) 48 | { 49 | for(int i=0; i arg_vector() 82 | { 83 | std::vector< string_type > args; 84 | for (int i = 0; i < argc(); ++i) 85 | args.push_back(argv()[i]); 86 | 87 | return args; 88 | } 89 | 90 | private: 91 | 92 | std::vector arguments_; 93 | 94 | }; 95 | 96 | ///////////////////////////////////////////////////////////////////////////// 97 | // args 98 | // 99 | 100 | // args versions for Multi-Byte string and Unicode string 101 | typedef args_ args; 102 | // wchar_t / char 103 | 104 | }} // boost::application 105 | 106 | #endif // BOOST_APPLICATION_ARGS_ASPECT_HPP 107 | 108 | -------------------------------------------------------------------------------- /include/boost/application/aspects/path.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Renato Tegon Forti 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_APPLICATION_PATH_ASPECT_HPP 8 | #define BOOST_APPLICATION_PATH_ASPECT_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #if defined( BOOST_WINDOWS_API ) 16 | #include 17 | #elif defined( BOOST_POSIX_API ) 18 | #include 19 | #else 20 | #error "Sorry, no boost application are available for this platform." 21 | #endif 22 | 23 | namespace boost { namespace application { 24 | 25 | 26 | class path 27 | { 28 | public: 29 | path() : impl_(new detail::default_path_impl) {} 30 | 31 | filesystem::path current_path(void) 32 | { 33 | return impl_->current_path(); 34 | } 35 | 36 | filesystem::path location(boost::system::error_code &ec) 37 | { 38 | return impl_->location(ec); 39 | } 40 | 41 | filesystem::path location() 42 | { 43 | return impl_->location(); 44 | } 45 | 46 | filesystem::path executable_path_name(boost::system::error_code &ec) 47 | { 48 | return impl_->location(ec); 49 | } 50 | 51 | filesystem::path executable_path_name() 52 | { 53 | return impl_->location(); 54 | } 55 | 56 | filesystem::path executable_path(boost::system::error_code &ec) 57 | { 58 | return location(ec).parent_path(); 59 | } 60 | 61 | filesystem::path executable_path() 62 | { 63 | return impl_->location().parent_path(); 64 | } 65 | 66 | filesystem::path executable_full_name(boost::system::error_code &ec) 67 | { 68 | return impl_->location(ec).filename(); 69 | } 70 | 71 | filesystem::path executable_full_name(void) 72 | { 73 | return impl_->location().filename(); 74 | } 75 | 76 | filesystem::path executable_name(boost::system::error_code &ec) 77 | { 78 | return impl_->location(ec).stem(); 79 | } 80 | 81 | filesystem::path executable_name(void) 82 | { 83 | return impl_->location().stem(); 84 | } 85 | 86 | filesystem::path home_path(void) 87 | { 88 | return impl_->home_path(); 89 | } 90 | 91 | filesystem::path config_path(void) 92 | { 93 | return impl_->config_path(); 94 | } 95 | 96 | filesystem::path app_data_path(void) 97 | { 98 | return impl_->app_data_path(); 99 | } 100 | 101 | filesystem::path temp_path(void) 102 | { 103 | return impl_->temp_path(); 104 | } 105 | 106 | private: 107 | csbl::shared_ptr impl_; 108 | }; 109 | 110 | }} // boost::application 111 | 112 | #endif // BOOST_APPLICATION_PATH_ASPECT_HPP 113 | 114 | -------------------------------------------------------------------------------- /include/boost/application/aspects/pause_handler.hpp: -------------------------------------------------------------------------------- 1 | // pause_handler.hpp ---------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 18-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_ASPECT_PAUSE_HANDLER_HPP 17 | #define BOOST_APPLICATION_ASPECT_PAUSE_HANDLER_HPP 18 | 19 | #include 20 | #include 21 | 22 | namespace boost { namespace application { 23 | 24 | class pause_handler : public handler<> 25 | { 26 | public: 27 | pause_handler(const callback& cb) 28 | : handler<>(cb) {} 29 | }; 30 | 31 | class pause_handler_default_behaviour : public pause_handler 32 | { 33 | public: 34 | pause_handler_default_behaviour(const callback& cb) 35 | : pause_handler(cb) {} 36 | }; 37 | 38 | }} // boost::application 39 | 40 | #endif // BOOST_APPLICATION_ASPECT_PAUSE_HANDLER_HPP 41 | 42 | -------------------------------------------------------------------------------- /include/boost/application/aspects/process_id.hpp: -------------------------------------------------------------------------------- 1 | // pid.hpp ------------------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 14-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_PID_ASPECT_HPP 17 | #define BOOST_APPLICATION_PID_ASPECT_HPP 18 | 19 | #include 20 | #include 21 | 22 | #if defined( BOOST_WINDOWS_API ) 23 | #include 24 | #elif defined( BOOST_POSIX_API ) 25 | #include 26 | #else 27 | #error "Sorry, no boost application are available for this platform." 28 | #endif 29 | 30 | namespace boost { namespace application { 31 | 32 | /*! 33 | * \brief A class aspect to be used to obtain a PID of proccess. 34 | * 35 | */ 36 | class process_id 37 | : public detail::process_id_impl { 38 | typedef detail::process_id_impl base_t; 39 | 40 | public: 41 | 42 | typedef process_id_impl::native_pid_t native_pid_t; 43 | 44 | process_id() 45 | {} 46 | 47 | process_id(native_pid_t p) 48 | : base_t(p) 49 | {} 50 | 51 | virtual ~process_id() 52 | {} 53 | 54 | /*! 55 | * Obtain a PID of proccess. 56 | * 57 | */ 58 | native_pid_t pid() BOOST_NOEXCEPT { 59 | return base_t::pid(); 60 | } 61 | }; 62 | 63 | }} // boost::application 64 | 65 | #endif // BOOST_APPLICATION_PID_ASPECT_HPP 66 | 67 | -------------------------------------------------------------------------------- /include/boost/application/aspects/resume_handler.hpp: -------------------------------------------------------------------------------- 1 | // resume_handler.hpp --------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 18-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_ASPECT_RESUME_HANDLER_HPP 17 | #define BOOST_APPLICATION_ASPECT_RESUME_HANDLER_HPP 18 | 19 | #include 20 | #include 21 | 22 | namespace boost { namespace application { 23 | 24 | class resume_handler : public handler<> 25 | { 26 | public: 27 | resume_handler(const callback& cb) 28 | : handler<>(cb) {} 29 | }; 30 | 31 | class resume_handler_default_behaviour : public resume_handler 32 | { 33 | public: 34 | resume_handler_default_behaviour(const callback& cb) 35 | : resume_handler(cb) {} 36 | }; 37 | 38 | }} // boost::application 39 | 40 | #endif // BOOST_APPLICATION_ASPECT_RESUME_HANDLER_HPP 41 | 42 | -------------------------------------------------------------------------------- /include/boost/application/aspects/run_mode.hpp: -------------------------------------------------------------------------------- 1 | // run_mode.hpp -------------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 14-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_RUN_MODE_ASPECT_HPP 17 | #define BOOST_APPLICATION_RUN_MODE_ASPECT_HPP 18 | 19 | // appication 20 | #include 21 | 22 | namespace boost { namespace application { 23 | 24 | /*! 25 | * \brief This aspect class is used internaly by applications types (modes) 26 | * 27 | * Indicates how the application was created. 28 | * 29 | */ 30 | class run_mode 31 | { 32 | public: 33 | 34 | /*! 35 | * Constructs an run_mode aspect. 36 | * 37 | * \param run_mode The mode of application. 38 | */ 39 | run_mode(int run_mode) 40 | : application_run_mode_(run_mode) {} 41 | 42 | /*! 43 | * Retreaves current mode of application. 44 | * 45 | * \return the mode of application. 46 | * 47 | */ 48 | int mode() { 49 | return application_run_mode_; 50 | } 51 | 52 | /*! 53 | * Sets the current mode of application. 54 | * 55 | * \param mode The mode of application. 56 | * 57 | */ 58 | void mode(int mode) { 59 | application_run_mode_ = mode; 60 | } 61 | 62 | bool operator==(int mode) const { 63 | return mode == application_run_mode_; 64 | } 65 | 66 | private: 67 | 68 | int application_run_mode_; 69 | 70 | }; 71 | 72 | }} // boost::application 73 | 74 | #endif // BOOST_APPLICATION_RUN_MODE_ASPECT_HPP 75 | 76 | -------------------------------------------------------------------------------- /include/boost/application/aspects/selfpipe.hpp: -------------------------------------------------------------------------------- 1 | // selfpipe.hpp --------------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | // Copyright 2013 Stanislav Ivochkin 6 | // Part of this file was contributed by Stanislav Ivochkin 7 | 8 | // Distributed under the Boost Software License, Version 1.0. 9 | // See http://www.boost.org/LICENSE_1_0.txt 10 | 11 | // ----------------------------------------------------------------------------- 12 | 13 | // Revision History 14 | // 08-11-2013 dd-mm-yyyy - Initial Release 15 | 16 | // ----------------------------------------------------------------------------- 17 | 18 | // test aspet (indev) 19 | 20 | #ifndef BOOST_APPLICATION_SELFPIPE_ASPECT_HPP 21 | #define BOOST_APPLICATION_SELFPIPE_ASPECT_HPP 22 | 23 | #include 24 | #include 25 | 26 | // platform usage 27 | #if defined( BOOST_POSIX_API ) 28 | #include 29 | #include 30 | #endif 31 | 32 | namespace boost { namespace application { 33 | 34 | namespace posix { 35 | 36 | /*! 37 | * \brief POSIX platform specific aspect that implement self-pipe trick. 38 | * 39 | */ 40 | class selfpipe : noncopyable 41 | { 42 | 43 | public: 44 | 45 | selfpipe() 46 | { 47 | boost::system::error_code ec; 48 | 49 | setup(ec); 50 | 51 | if(ec) BOOST_APPLICATION_THROW_LAST_SYSTEM_ERROR_USING_MY_EC( 52 | "selfpipe() failed", ec); 53 | } 54 | 55 | selfpipe(boost::system::error_code &ec) 56 | { 57 | setup(ec); 58 | } 59 | 60 | virtual ~selfpipe() 61 | { 62 | teardown(); 63 | } 64 | 65 | protected: 66 | 67 | void setup(boost::system::error_code &ec) 68 | { 69 | if (pipe(fd_) == -1) 70 | { 71 | ec = last_error_code(); return; 72 | } 73 | 74 | fcntl(fd_[readfd], F_SETFL, 75 | fcntl(fd_[readfd], F_GETFL) | O_NONBLOCK); 76 | 77 | fcntl(fd_[writefd], F_SETFL, 78 | fcntl(fd_[writefd], F_GETFL) | O_NONBLOCK); 79 | } 80 | 81 | void teardown() 82 | { 83 | close(fd_[readfd]); 84 | close(fd_[writefd]); 85 | } 86 | 87 | public: 88 | 89 | int read_fd() const 90 | { 91 | return fd_[readfd]; 92 | } 93 | 94 | int write_fd() const 95 | { 96 | return fd_[writefd]; 97 | } 98 | 99 | void poke() 100 | { 101 | write(fd_[writefd], "", 1); 102 | } 103 | 104 | private: 105 | 106 | enum { readfd = 0, writefd = 1 }; 107 | 108 | int fd_[2]; 109 | 110 | }; // selfpipe 111 | 112 | } // posix 113 | 114 | // platform usage 115 | #if defined( BOOST_WINDOWS_API ) 116 | // not available 117 | // using windows::self_pipe; 118 | # error "Sorry, the Windows platform don't support 'selfpipe' aspect." 119 | #elif defined( BOOST_POSIX_API ) 120 | using posix::selfpipe; 121 | #else 122 | # error "Sorry, selfpipe are available for this platform." 123 | #endif 124 | 125 | }} // boost::application::posix 126 | 127 | #endif // BOOST_APPLICATION_SELFPIPE_ASPECT_HPP 128 | 129 | -------------------------------------------------------------------------------- /include/boost/application/aspects/status.hpp: -------------------------------------------------------------------------------- 1 | // status.hpp ---------------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 14-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_STATUS_ASPECT_HPP 17 | #define BOOST_APPLICATION_STATUS_ASPECT_HPP 18 | 19 | // appication 20 | #include 21 | 22 | namespace boost { namespace application { 23 | 24 | /*! 25 | * \brief This aspect class is used internaly by applications types (modes) 26 | * 27 | * Indicates the current state of application, 28 | * 3 ways are possible: 29 | * 30 | * - application_stopped 31 | * - application_running 32 | * - application_paused (used only on server appliation on windows side) 33 | * 34 | */ 35 | class status 36 | { 37 | friend class server; 38 | friend class common; 39 | 40 | public: 41 | // application current state 42 | enum application_state { 43 | stopped = 0, 44 | running, 45 | paused // Windows Service 46 | }; 47 | 48 | /*! 49 | * Constructs an application_state aspect. 50 | * 51 | * \param state The state of application. 52 | */ 53 | status(application_state state) 54 | : application_state_(state) {} 55 | 56 | /*! 57 | * Retreaves current state of application. 58 | * 59 | * \return the state of application. 60 | * 61 | */ 62 | application_state state() { 63 | return application_state_; 64 | } 65 | 66 | /*! 67 | * Sets the current state of application. 68 | * 69 | * \param state The state of application. 70 | * 71 | */ 72 | void state(application_state state) { 73 | application_state_ = state; 74 | } 75 | 76 | bool operator==(application_state state) const { 77 | return state == application_state_; 78 | } 79 | 80 | bool operator!=(application_state state) const { 81 | return state != application_state_; 82 | } 83 | 84 | private: 85 | 86 | application_state application_state_; 87 | 88 | }; 89 | 90 | }} // boost::application 91 | 92 | #endif // BOOST_APPLICATION_STATUS_ASPECT_HPP 93 | 94 | -------------------------------------------------------------------------------- /include/boost/application/aspects/termination_handler.hpp: -------------------------------------------------------------------------------- 1 | // termination_handler.hpp --------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 18-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_ASPECT_TERMINATION_HANDLER_HPP 17 | #define BOOST_APPLICATION_ASPECT_TERMINATION_HANDLER_HPP 18 | 19 | #include 20 | #include 21 | 22 | namespace boost { namespace application { 23 | 24 | class termination_handler : public handler<> 25 | { 26 | public: 27 | termination_handler(const callback& cb) 28 | : handler<>(cb) {} 29 | }; 30 | 31 | class termination_handler_default_behaviour : public termination_handler 32 | { 33 | public: 34 | termination_handler_default_behaviour(const callback& cb) 35 | : termination_handler(cb) {} 36 | }; 37 | 38 | }} // boost::application 39 | 40 | #endif // BOOST_APPLICATION_ASPECT_TERMINATION_HANDLER_HPP 41 | 42 | -------------------------------------------------------------------------------- /include/boost/application/aspects/wait_for_termination_request.hpp: -------------------------------------------------------------------------------- 1 | // wait_for_termination_request.hpp -----------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 14-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_ASPECT_HPP 17 | #define BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_ASPECT_HPP 18 | 19 | #include 20 | #include 21 | #if defined( BOOST_WINDOWS_API ) 22 | #include 23 | #elif defined( BOOST_POSIX_API ) 24 | #include 25 | #else 26 | #error "Sorry, no boost application are available for this platform." 27 | #endif 28 | 29 | namespace boost { namespace application { 30 | 31 | /*! 32 | * \brief A contract class to be used by the user on your own 33 | * class implementation of wait_for_termination_request aspect. 34 | * 35 | */ 36 | class wait_for_termination_request : noncopyable 37 | { 38 | public: 39 | wait_for_termination_request() {} 40 | virtual ~wait_for_termination_request() {} 41 | 42 | /*! 43 | * Wait for termination request that need be 44 | * implemented on derived class. 45 | * 46 | */ 47 | virtual void wait() = 0; 48 | 49 | /*! 50 | * Continue, that need be implemented on derived class. 51 | * 52 | */ 53 | virtual void proceed() = 0; 54 | }; 55 | 56 | /*! 57 | * \brief This aspect class handle termination request of application. 58 | * User can override this behavior and define your own. 59 | * 60 | */ 61 | class wait_for_termination_request_default_behaviour 62 | : public wait_for_termination_request 63 | { 64 | public: 65 | wait_for_termination_request_default_behaviour() 66 | : impl_(new wait_for_termination_request_impl()){} 67 | 68 | /*! 69 | * Wait for termination request. 70 | * 71 | */ 72 | void wait() { 73 | impl_->wait(); 74 | } 75 | 76 | /*! 77 | * Continue, cause wait to be relesed 78 | * 79 | */ 80 | void proceed() { 81 | impl_->proceed(); 82 | } 83 | 84 | private: 85 | 86 | csbl::shared_ptr impl_; 87 | 88 | }; 89 | 90 | }} // boost::application 91 | 92 | #endif // BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_ASPECT_HPP 93 | 94 | -------------------------------------------------------------------------------- /include/boost/application/base_type.hpp: -------------------------------------------------------------------------------- 1 | // base_type.hpp -------------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 04-03-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_BASE_TYPE_HPP 17 | #define BOOST_APPLICATION_BASE_TYPE_HPP 18 | 19 | // app 20 | #include 21 | 22 | namespace boost { namespace application { 23 | 24 | // use it if you want indicate to 'launch' that 'CustomType' is not necessary 25 | // int launch(Application& app, CustomType& ct, ... 26 | struct not_necessary {}; 27 | // as launch(app, not_necessary()); 28 | // 29 | 30 | /*! 31 | * \brief This is a fundamental type for Boost.Application. 32 | * 33 | * It is used to pack string, args, paths values, 34 | * with it we can handle unicode (windows) and others 35 | * neededs types required by application lib. 36 | * 37 | */ 38 | template 39 | class base_type 40 | { 41 | public: 42 | explicit base_type(const Type &s) 43 | : s_(s) 44 | {} 45 | 46 | const Type& get() const { 47 | return s_; 48 | } 49 | 50 | private: 51 | Type s_; 52 | }; 53 | 54 | /*! 55 | * \brief Pack for characters types used by Boost.Application. 56 | * 57 | * It is used to pack string, args, paths values, 58 | * with it we can handle unicode (windows) and others 59 | * neededs types required by application lib. 60 | * 61 | */ 62 | struct character_types 63 | { 64 | // basic string types to be used by application lib 65 | #if defined(BOOST_APPLICATION_STD_WSTRING) 66 | typedef wchar_t char_type; 67 | #else 68 | typedef char char_type; 69 | #endif 70 | typedef std::basic_string string_type; 71 | }; 72 | 73 | }} // boost::application 74 | 75 | #endif // BOOST_APPLICATION_BASE_TYPE_HPP 76 | 77 | -------------------------------------------------------------------------------- /include/boost/application/detail/application_impl.hpp: -------------------------------------------------------------------------------- 1 | // application_impl.hpp ------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 26-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_DETAIL_APPLICATION_IMPL_HPP 17 | #define BOOST_APPLICATION_DETAIL_APPLICATION_IMPL_HPP 18 | 19 | // application 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | namespace boost { namespace application { 26 | 27 | // share context on modes 28 | class application_impl : noncopyable 29 | { 30 | public: 31 | 32 | application_impl(context &cxt) 33 | : context_(cxt) 34 | { 35 | } 36 | 37 | context &get_context() 38 | { 39 | return context_; 40 | } 41 | 42 | protected: 43 | context &context_; 44 | 45 | }; 46 | 47 | }} // boost::application 48 | 49 | #endif // BOOST_APPLICATION_DETAIL_APPLICATION_IMPL_HPP 50 | -------------------------------------------------------------------------------- /include/boost/application/detail/csbl.hpp: -------------------------------------------------------------------------------- 1 | // csbl.hpp ------------------------------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 25-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_DETAIL_CSBL_HPP 17 | #define BOOST_APPLICATION_DETAIL_CSBL_HPP 18 | 19 | #include 20 | 21 | // This enable we to use csbl:: and internally the library select correct 22 | // names, e.g. : csbl::unique_ptr will be boost::shared_ptr or std::shared_ptr 23 | 24 | namespace boost { namespace application { namespace csbl { 25 | // as common std-boost library 26 | 27 | BOOST_APPLICATION_FEATURE_SELECT 28 | 29 | template 30 | inline type_index get_type_id() { 31 | 32 | #if defined( BOOST_APPLICATION_FEATURE_NS_SELECT_STD ) 33 | return typeid(T); 34 | #elif defined( BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST ) 35 | return BOOST_APPLICATION_TYPE_INDEX_NS_SELECT::type_id(); 36 | #else // auto detect 37 | # ifndef BOOST_NO_CXX11_HDR_TYPEINDEX 38 | return typeid(T); 39 | # else 40 | return BOOST_APPLICATION_TYPE_INDEX_NS_SELECT::type_id(); 41 | # endif 42 | #endif 43 | 44 | } 45 | 46 | }}} // boost::application::csbl 47 | 48 | #endif // BOOST_APPLICATION_DETAIL_CSBL_HPP 49 | -------------------------------------------------------------------------------- /include/boost/application/detail/ensure_single_instance.hpp: -------------------------------------------------------------------------------- 1 | // ensure_single_instance.hpp ----------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 14-10-2013 dd-mm-yyyy - Initial Release 13 | // 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_DETAIL_ENSURE_SINGLE_INSTANCE_HPP 17 | #define BOOST_APPLICATION_DETAIL_ENSURE_SINGLE_INSTANCE_HPP 18 | 19 | // application 20 | #include 21 | #include 22 | #include 23 | 24 | namespace boost { namespace application { namespace detail { 25 | 26 | // check single_instance aspect and runs the requested behavior, 27 | // returns true to indicate that application needs exit. 28 | 29 | inline bool check(context &cxt, 30 | boost::system::error_code& ec) 31 | { 32 | csbl::shared_ptr ol = 33 | cxt.find(); 34 | 35 | if(ol) 36 | { 37 | bool is_another_instance_running = ol->lock(ec); 38 | 39 | if(ec) return false; // user need check by error 40 | 41 | if(!is_another_instance_running) 42 | return false; // continue, no other instance running 43 | 44 | // check if we have any callback to call 45 | 46 | handler<>::callback* cb = 0; 47 | 48 | if(ol->get(cb)) 49 | { 50 | if((*cb)()) 51 | { 52 | // user tell us to continue 53 | return false; 54 | } 55 | 56 | return true; 57 | } 58 | 59 | // default behaviour 60 | return true; 61 | } 62 | 63 | // continue / no restriction 64 | return false; 65 | } 66 | 67 | template struct ensure_single_instance { 68 | bool operator()(T &cxt, boost::system::error_code& ec) 69 | { 70 | return check(cxt, ec); 71 | } 72 | }; 73 | 74 | template <> struct ensure_single_instance< 75 | global_context_ptr > { 76 | bool operator()(global_context_ptr cxt, 77 | boost::system::error_code& ec) 78 | { 79 | return check(*cxt.get(), ec); 80 | } 81 | }; 82 | 83 | }}} // boost::application 84 | 85 | #endif // BOOST_APPLICATION_DETAIL_ENSURE_SINGLE_INSTANCE_HPP 86 | 87 | -------------------------------------------------------------------------------- /include/boost/application/detail/posix/common_application_impl.hpp: -------------------------------------------------------------------------------- 1 | // common_application_impl.hpp ---------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 23-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_COMMON_APPLICATION_IMPL_HPP 17 | #define BOOST_APPLICATION_COMMON_APPLICATION_IMPL_HPP 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace boost { namespace application { 29 | 30 | template 31 | class common_application_impl_ : public application_impl 32 | { 33 | public: 34 | 35 | typedef csbl::function< int (void) > mainop; 36 | 37 | // string types to be used internaly to handle unicode on windows 38 | typedef CharType char_type; 39 | typedef std::basic_string string_type; 40 | 41 | common_application_impl_(const mainop &main, 42 | signal_binder &sb, 43 | application::context &context, 44 | boost::system::error_code& ec) 45 | : application_impl(context) 46 | , main_(main) 47 | { 48 | sb.start(); 49 | } 50 | 51 | virtual ~common_application_impl_() 52 | { 53 | } 54 | 55 | int run() 56 | { 57 | return main_(); 58 | } 59 | 60 | private: 61 | mainop main_; 62 | 63 | }; 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | // server_application_impl 67 | // 68 | 69 | // args versions for Multi-Byte string and Unicode string 70 | typedef common_application_impl_ common_application_impl; 71 | // wchar_t / char 72 | 73 | }} // boost::application 74 | 75 | #endif // BOOST_APPLICATION_COMMON_APPLICATION_IMPL_HPP 76 | -------------------------------------------------------------------------------- /include/boost/application/detail/posix/process_id_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Renato Tegon Forti, Antony Polukhin. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_APPLICATION_DETAIL_PROCESS_ID_HPP 8 | #define BOOST_APPLICATION_DETAIL_PROCESS_ID_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #ifdef BOOST_HAS_PRAGMA_ONCE 17 | # pragma once 18 | #endif 19 | 20 | namespace boost { namespace application { namespace detail { 21 | 22 | class process_id_impl { 23 | 24 | public: 25 | typedef pid_t native_pid_t; 26 | 27 | process_id_impl() 28 | : pid_ (0) 29 | {} 30 | 31 | process_id_impl(native_pid_t pid) 32 | : pid_ (pid) 33 | {} 34 | 35 | native_pid_t pid() BOOST_NOEXCEPT { 36 | if(pid_) 37 | return pid_; 38 | 39 | pid_ = getpid(); 40 | return pid_; 41 | } 42 | 43 | private: 44 | native_pid_t pid_; 45 | }; 46 | 47 | }}} // namespace boost::application::detail 48 | 49 | #endif // BOOST_APPLICATION_DETAIL_WINDOWS_PATH_FROM_ME_HPP 50 | 51 | -------------------------------------------------------------------------------- /include/boost/application/detail/posix/wait_for_termination_request_impl.hpp: -------------------------------------------------------------------------------- 1 | // wait_for_termination_request_impl.hpp ------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2013 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 15-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_IMPL_HPP 17 | #define BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_IMPL_HPP 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | namespace boost { namespace application { 25 | 26 | #if defined( USE_POSIX_WAIT_FOR_TERMINATION_REQUEST_YELD_BASED ) 27 | class wait_for_termination_request_impl : noncopyable 28 | { 29 | public: 30 | 31 | wait_for_termination_request_impl() 32 | : run_(true) 33 | { 34 | } 35 | 36 | // will wait for termination request 37 | void wait() 38 | { 39 | while (run_) { boost::this_thread::yield(); } 40 | } 41 | 42 | void proceed() 43 | { 44 | run_ = false; 45 | } 46 | 47 | private: 48 | 49 | bool run_; 50 | 51 | }; 52 | #elif defined( USE_POSIX_WAIT_FOR_TERMINATION_REQUEST_SIGUSR1_BASED ) 53 | class wait_for_termination_request_impl : noncopyable 54 | // http://www.cs.kent.edu/~farrell/sp/lectures/signals.html 55 | { 56 | public: 57 | 58 | // will wait for termination request 59 | void wait() 60 | { 61 | sigset_t sset; 62 | 63 | sigemptyset(&sset); 64 | 65 | //sigaddset(&sset, SIGINT); 66 | //sigaddset(&sset, SIGQUIT); 67 | //sigaddset(&sset, SIGTERM); 68 | 69 | sigaddset(&sset, SIGUSR1); 70 | 71 | sigprocmask(SIG_BLOCK, &sset, NULL); 72 | 73 | int sig; 74 | sigwait(&sset, &sig); 75 | } 76 | 77 | void proceed() 78 | { 79 | raise(SIGUSR1); 80 | } 81 | }; 82 | #else // DRFAULT WAY 83 | class wait_for_termination_request_impl : noncopyable 84 | { 85 | public: 86 | 87 | // will wait for termination request 88 | void wait() 89 | { 90 | fd_set readfds; 91 | FD_ZERO(&readfds); 92 | FD_SET(selfpipe_.read_fd(), &readfds); 93 | 94 | // block and wait 95 | while(select(selfpipe_.read_fd() + 1, &readfds, 0, 0, 0) == -1 && errno == EINTR) 96 | { 97 | // nothing here, restart when signal is catch 98 | } 99 | } 100 | 101 | void proceed() 102 | { 103 | selfpipe_.poke(); 104 | } 105 | 106 | private: 107 | 108 | application::selfpipe selfpipe_; 109 | 110 | }; 111 | #endif 112 | 113 | }} // boost::application 114 | 115 | #endif // BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_IMPL_HPP 116 | 117 | -------------------------------------------------------------------------------- /include/boost/application/detail/windows/common_application_impl.hpp: -------------------------------------------------------------------------------- 1 | // common_application_impl.hpp ---------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2014 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 23-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_COMMON_APPLICATION_IMPL_HPP 17 | #define BOOST_APPLICATION_COMMON_APPLICATION_IMPL_HPP 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace boost { namespace application { 29 | 30 | template 31 | class common_application_impl_ : public application_impl 32 | { 33 | public: 34 | 35 | typedef csbl::function< int (void) > mainop; 36 | 37 | // string types to be used internaly to handle unicode on windows 38 | typedef CharType char_type; 39 | typedef std::basic_string string_type; 40 | 41 | common_application_impl_(const mainop &main_op, 42 | signal_binder &sb, 43 | application::context &context, 44 | boost::system::error_code& ec) 45 | : application_impl(context) 46 | , main_(main_op) 47 | { 48 | sb.start(); 49 | } 50 | 51 | virtual ~common_application_impl_() 52 | { 53 | } 54 | 55 | int run() 56 | { 57 | return main_(); 58 | } 59 | 60 | private: 61 | mainop main_; 62 | 63 | }; 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | // server_application_impl 67 | // 68 | 69 | // args versions for Multi-Byte string and Unicode string 70 | typedef common_application_impl_ common_application_impl; 71 | // wchar_t / char 72 | 73 | }} // boost::application 74 | 75 | #endif // BOOST_APPLICATION_COMMON_APPLICATION_IMPL_HPP 76 | 77 | -------------------------------------------------------------------------------- /include/boost/application/detail/windows/limit_single_instance_impl.hpp: -------------------------------------------------------------------------------- 1 | // limit_single_instance_impl.hpp -------------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2012 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 06-01-2012 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_IMPL_WINDOWS_LIMIT_SINGLE_INSTANCE_IMPL_HPP 17 | #define BOOST_APPLICATION_IMPL_WINDOWS_LIMIT_SINGLE_INSTANCE_IMPL_HPP 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace boost { namespace application { 28 | 29 | // This code is from Q243953 in case you lose the article and wonder 30 | // where this code came from. 31 | template 32 | class limit_single_instance_impl_ : noncopyable 33 | { 34 | 35 | public: 36 | 37 | typedef CharType char_type; 38 | typedef std::basic_string string_type; 39 | 40 | limit_single_instance_impl_() 41 | : mutex_(0) {} 42 | 43 | ~limit_single_instance_impl_() { 44 | release(); 45 | } 46 | 47 | bool lock(const uuids::uuid& instance_id, boost::system::error_code &ec) 48 | { 49 | // Make sure that you use a name that is unique for this application otherwise 50 | // two apps may think they are the same if they are using same name for 51 | // 3rd parm to CreateMutex 52 | 53 | // allways we will use upper case 54 | string_type normalized_uuid_text = 55 | boost::to_upper_copy(boost::lexical_cast(instance_id)); 56 | 57 | mutex_ = CreateMutex(0, FALSE, normalized_uuid_text.c_str()); 58 | 59 | if(mutex_ == 0) 60 | { 61 | ec = boost::application::last_error_code(); return false; 62 | } 63 | else 64 | last_error_ = GetLastError(); //save for use later... 65 | 66 | return is_another_instance_running(); 67 | } 68 | 69 | void release(bool force = false) 70 | { 71 | // force: do nothing here force 72 | 73 | if (mutex_ == 0) 74 | { 75 | CloseHandle(mutex_); 76 | mutex_ = 0; 77 | } 78 | } 79 | 80 | bool is_another_instance_running() 81 | { 82 | return (ERROR_ALREADY_EXISTS == last_error_); 83 | } 84 | 85 | private: 86 | 87 | DWORD last_error_; 88 | HANDLE mutex_; 89 | 90 | }; 91 | 92 | typedef limit_single_instance_impl_ limit_single_instance_impl; 93 | 94 | } } // boost::application::win 95 | 96 | #endif // BOOST_APPLICATION_IMPL_WINDOWS_LIMIT_SINGLE_INSTANCE_IMPL_HPP 97 | -------------------------------------------------------------------------------- /include/boost/application/detail/windows/process_id_impl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Renato Tegon Forti, Antony Polukhin. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_APPLICATION_DETAIL_PROCESS_ID_HPP 8 | #define BOOST_APPLICATION_DETAIL_PROCESS_ID_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | #ifdef BOOST_HAS_PRAGMA_ONCE 18 | # pragma once 19 | #endif 20 | 21 | namespace boost { namespace application { namespace detail { 22 | 23 | class process_id_impl { 24 | 25 | public: 26 | typedef boost::detail::winapi::DWORD_ native_pid_t; 27 | 28 | process_id_impl() 29 | : pid_ (0) 30 | {} 31 | 32 | process_id_impl(native_pid_t pid) 33 | : pid_ (pid) 34 | {} 35 | 36 | native_pid_t pid() BOOST_NOEXCEPT { 37 | if(pid_) 38 | return pid_; 39 | 40 | pid_ = boost::detail::winapi::GetCurrentProcessId(); 41 | return pid_; 42 | } 43 | 44 | private: 45 | native_pid_t pid_; 46 | }; 47 | 48 | }}} // namespace boost::application::detail 49 | 50 | #endif // BOOST_APPLICATION_DETAIL_WINDOWS_PATH_FROM_ME_HPP 51 | 52 | -------------------------------------------------------------------------------- /include/boost/application/detail/windows/wait_for_termination_request_impl.hpp: -------------------------------------------------------------------------------- 1 | // wait_for_termination_request_impl.hpp ------------------------------------// 2 | // ----------------------------------------------------------------------------- 3 | 4 | // Copyright 2011-2013 Renato Tegon Forti 5 | 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See http://www.boost.org/LICENSE_1_0.txt 8 | 9 | // ----------------------------------------------------------------------------- 10 | 11 | // Revision History 12 | // 15-10-2013 dd-mm-yyyy - Initial Release 13 | 14 | // ----------------------------------------------------------------------------- 15 | 16 | #ifndef BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_IMPL_HPP 17 | #define BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_IMPL_HPP 18 | 19 | namespace boost { namespace application { 20 | 21 | class wait_for_termination_request_impl : noncopyable 22 | { 23 | public: 24 | 25 | wait_for_termination_request_impl() 26 | : terminate_event_(NULL) 27 | { 28 | // create the termination event 29 | terminate_event_ = CreateEvent (0, TRUE, FALSE, 0); 30 | } 31 | 32 | virtual ~wait_for_termination_request_impl() 33 | { 34 | if (terminate_event_) 35 | CloseHandle(terminate_event_); 36 | } 37 | 38 | void wait() 39 | { 40 | // Wait for stop signal, and then terminate 41 | WaitForSingleObject(terminate_event_, INFINITE); 42 | } 43 | 44 | void proceed() 45 | { 46 | if (terminate_event_) 47 | // set the event that is holding main 48 | // so that app can continue 49 | SetEvent(terminate_event_); 50 | } 51 | 52 | private: 53 | 54 | // windowns terminate event ctrl 55 | HANDLE terminate_event_; 56 | 57 | }; 58 | 59 | }} // boost::application 60 | 61 | #endif // BOOST_APPLICATION_WAIT_FOR_TERMINATION_REQUEST_IMPL_HPP 62 | 63 | -------------------------------------------------------------------------------- /include/boost/application/system_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Renato Tegon Forti 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_APPLICATION_SYSTEM_ERROR_HPP 8 | #define BOOST_APPLICATION_SYSTEM_ERROR_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #if defined(BOOST_POSIX_API) 16 | # include 17 | #elif defined(BOOST_WINDOWS_API) 18 | # include 19 | #endif 20 | 21 | #ifdef BOOST_HAS_PRAGMA_ONCE 22 | # pragma once 23 | #endif 24 | 25 | namespace boost { namespace application { 26 | 27 | // BOOST_APPLICATION_LAST_ERROR 28 | 29 | /*! 30 | * Retrieves the last error code of system. 31 | * 32 | * \return the last error code of system. 33 | * 34 | * [Windows] 35 | * GetLastError 36 | * 37 | * [POSIX] 38 | * errno 39 | * 40 | */ 41 | inline int last_error(void) BOOST_NOEXCEPT 42 | { 43 | #if defined(BOOST_POSIX_API) 44 | return errno; 45 | #elif defined(BOOST_WINDOWS_API) 46 | return GetLastError(); 47 | #endif 48 | } 49 | 50 | // BOOST_APPLICATION_SET_LAST_SYSTEM_ERROR 51 | 52 | /*! 53 | * Generate a system::error_code form last_error function. 54 | * 55 | * \return the system::error_code based on last_error 56 | * function (System Error). 57 | * 58 | */ 59 | inline system::error_code last_error_code() BOOST_NOEXCEPT 60 | { 61 | return boost::system::error_code(last_error(), 62 | boost::system::system_category()); 63 | } 64 | 65 | }}// boost::application 66 | 67 | #endif // BOOST_APPLICATION_SYSTEM_ERROR_HPP 68 | 69 | -------------------------------------------------------------------------------- /include/boost/application/version.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Renato Tegon Forti. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt 5 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_APPLICATION_APPLICATION_VERSION_HPP 8 | #define BOOST_APPLICATION_APPLICATION_VERSION_HPP 9 | 10 | #ifdef BOOST_HAS_PRAGMA_ONCE 11 | # pragma once 12 | #endif 13 | 14 | /// \file boost/application/version.hpp 15 | /// \brief Hold a set of functions to inspect the version of library. 16 | /// The BOOST_APPLICATION_VERSION_MAJOR value will be incremented whenever a 17 | /// change is made which might cause compilation errors for existing client code. 18 | 19 | #define BOOST_APPLICATION_VERSION_MAJOR 0 20 | #define BOOST_APPLICATION_VERSION_MINOR 4 21 | #define BOOST_APPLICATION_VERSION_BUILD 12 22 | 23 | // major.minor.build 24 | 25 | #ifndef BOOST_APPLICATION_VERSION 26 | #define BOOST_APPLICATION_VERSION \ 27 | BOOST_STRINGIZE(BOOST_APPLICATION_VERSION_MAJOR) "." \ 28 | BOOST_STRINGIZE(BOOST_APPLICATION_VERSION_MINOR) "." \ 29 | BOOST_STRINGIZE(BOOST_APPLICATION_VERSION_BUILD) 30 | #endif // BOOST_APPLICATION_VERSION 31 | 32 | namespace boost { namespace application { 33 | 34 | inline const char* library_version_string() { 35 | return BOOST_APPLICATION_VERSION; 36 | } 37 | 38 | inline unsigned int library_major_version() { 39 | return BOOST_APPLICATION_VERSION_MAJOR; 40 | } 41 | 42 | inline unsigned int library_minor_version() { 43 | return BOOST_APPLICATION_VERSION_MINOR; 44 | } 45 | 46 | inline unsigned int library_build_version() { 47 | return BOOST_APPLICATION_VERSION_BUILD; 48 | } 49 | 50 | }}// boost::application 51 | 52 | #endif // BOOST_APPLICATION_APPLICATION_VERSION_HPP 53 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Automatic redirection failed, please go to 7 | ../../doc/html/index.html 8 |

© Copyright 2013 Renato Tegon Forti 9 | Distributed under the Boost Software 10 | License, Version 1.0. (See accompanying file 11 | LICENSE_1_0.txt or copy at 12 | http://www.boost.org/LICENSE_1_0.txt) 13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /test/args_aspect_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2014 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE ArgAspect 13 | #include 14 | 15 | using namespace boost; 16 | 17 | BOOST_AUTO_TEST_CASE(arg_aspect) 18 | { 19 | auto& argc = boost::unit_test::framework::master_test_suite().argc; 20 | auto& argv = boost::unit_test::framework::master_test_suite().argv; 21 | 22 | application::args myargs(argc, argv); 23 | 24 | BOOST_CHECK(myargs.argc()); 25 | 26 | const std::vector< std::string > &argvec = myargs.arg_vector(); 27 | 28 | BOOST_CHECK(argvec.size()); 29 | } 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/auto_handler_global_context_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2014 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE AutoHandlerGlobalContext 13 | #include 14 | 15 | using namespace boost; 16 | 17 | inline application::global_context_ptr this_application() { 18 | return application::global_context::get(); 19 | } 20 | 21 | class myapp 22 | { 23 | public: 24 | 25 | myapp(application::context& context) 26 | : context_(context) { 27 | } 28 | 29 | int operator()() { 30 | return 0; 31 | } 32 | 33 | bool stop() { 34 | return true; // return true to stop, false to ignore 35 | } 36 | 37 | bool pause() { 38 | return true; // return true to pause, false to ignore 39 | } 40 | 41 | bool resume() { 42 | return true; // return true to resume, false to ignore 43 | } 44 | 45 | private: 46 | 47 | application::context& context_; 48 | 49 | }; 50 | 51 | BOOST_AUTO_TEST_CASE(auto_handler_global_context) 52 | { 53 | system::error_code ec; 54 | 55 | application::global_context_ptr app_context = application::global_context::create(ec); 56 | BOOST_CHECK(!ec.value()); 57 | 58 | application::auto_handler app(app_context); 59 | 60 | BOOST_CHECK(application::launch(app, app_context, ec) == 0); 61 | BOOST_CHECK(!ec.value()); 62 | 63 | application::global_context::destroy(ec); 64 | BOOST_CHECK(!ec.value()); 65 | 66 | } 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /test/auto_handler_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2014 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE AutoHandler 13 | #include 14 | 15 | using namespace boost; 16 | 17 | class myapp 18 | { 19 | public: 20 | 21 | myapp(application::context& context) 22 | : context_(context) { 23 | } 24 | 25 | int operator()() { 26 | return 0; 27 | } 28 | 29 | bool stop() { 30 | return true; // return true to stop, false to ignore 31 | } 32 | 33 | bool pause() { 34 | return true; // return true to pause, false to ignore 35 | } 36 | 37 | bool resume() { 38 | return true; // return true to resume, false to ignore 39 | } 40 | 41 | private: 42 | 43 | application::context& context_; 44 | 45 | }; 46 | 47 | 48 | BOOST_AUTO_TEST_CASE(auto_handler) 49 | { 50 | application::context app_context; 51 | application::auto_handler app(app_context); 52 | 53 | boost::system::error_code ec; 54 | 55 | BOOST_CHECK(application::launch(app, app_context, ec) == 0); 56 | BOOST_CHECK(!ec.value()); 57 | 58 | } 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /test/global_context_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Benjamin Dieckmann 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #define BOOST_TEST_MODULE global_context_test 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace boost; 17 | 18 | BOOST_AUTO_TEST_CASE(create_global_context) 19 | { 20 | application::global_context_ptr ctx = 21 | application::global_context::create(); 22 | BOOST_CHECK(ctx.get()!=0); 23 | 24 | application::global_context::destroy(); 25 | } 26 | 27 | BOOST_AUTO_TEST_CASE(get_global_context) 28 | { 29 | application::global_context_ptr ctx = 30 | application::global_context::create(); 31 | BOOST_CHECK(application::global_context::get()); 32 | 33 | application::global_context::destroy(); 34 | } 35 | 36 | BOOST_AUTO_TEST_CASE(destroy_global_context) 37 | { 38 | application::global_context_ptr ctx = 39 | application::global_context::create(); 40 | 41 | application::global_context::destroy(); 42 | } 43 | 44 | BOOST_AUTO_TEST_CASE(throw_create_global_context_twice) 45 | { 46 | application::global_context_ptr ctx = application::global_context::create(); 47 | 48 | BOOST_CHECK_THROW(application::global_context::create(), boost::system::system_error); 49 | 50 | application::global_context::destroy(); 51 | } 52 | 53 | BOOST_AUTO_TEST_CASE(throw_destroy_global_context_twice) 54 | { 55 | application::global_context_ptr ctx = 56 | application::global_context::create(); 57 | 58 | application::global_context::destroy(); 59 | BOOST_CHECK_THROW(application::global_context::destroy(), boost::system::system_error); 60 | } 61 | 62 | BOOST_AUTO_TEST_CASE(throw_after_destroy_global_context) 63 | { 64 | application::global_context_ptr ctx = 65 | application::global_context::create(); 66 | 67 | application::global_context::destroy(); 68 | BOOST_CHECK_THROW(application::global_context::get(), boost::system::system_error); 69 | } 70 | 71 | BOOST_AUTO_TEST_CASE(throw_before_create_global_context) 72 | { 73 | BOOST_CHECK_THROW(application::global_context::get(), boost::system::system_error); 74 | } 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /test/handler_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2014 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE Handler 13 | #include 14 | 15 | using namespace boost; 16 | 17 | struct handler_test 18 | { 19 | bool handler() 20 | { 21 | return true; 22 | } 23 | }; 24 | 25 | BOOST_AUTO_TEST_CASE(handler) 26 | { 27 | handler_test app_handler_test; 28 | application::context app_context; 29 | 30 | { 31 | application::handler<> h; 32 | 33 | BOOST_CHECK(!h.is_valid()); 34 | BOOST_CHECK(!h.is_valid()); 35 | } 36 | 37 | { 38 | application::handler<>::callback cb = boost::bind( 39 | &handler_test::handler, &app_handler_test); 40 | 41 | application::handler<> h(cb); 42 | BOOST_CHECK(h.is_valid()); 43 | 44 | application::handler<>::callback* hvb = 0; 45 | BOOST_CHECK(h.get(hvb)); 46 | BOOST_CHECK((*hvb)()); 47 | } 48 | 49 | { 50 | application::handler<>::callback cb = boost::bind( 51 | &handler_test::handler, &app_handler_test); 52 | 53 | application::handler<> h; 54 | h.set(cb); 55 | 56 | BOOST_CHECK(h.is_valid()); 57 | 58 | application::handler<>::callback* hcb = 0; 59 | BOOST_CHECK(h.get(hcb)); 60 | BOOST_CHECK((*hcb)()); 61 | } 62 | } 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /test/myapp.cpp: -------------------------------------------------------------------------------- 1 | #include "myapp.h" 2 | 3 | myapp::myapp(void) 4 | { 5 | } 6 | 7 | myapp::~myapp(void) 8 | { 9 | } 10 | 11 | int myapp::operator()(void) 12 | { 13 | shared_ptr myargs 14 | = this_application()->find(); 15 | 16 | if (myargs) 17 | { 18 | std::vector arg_vector = myargs->arg_vector(); 19 | } 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /test/myapp.h: -------------------------------------------------------------------------------- 1 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 2 | 3 | #include 4 | #include 5 | 6 | using namespace boost; 7 | 8 | inline application::global_context_ptr this_application() { 9 | return application::global_context::get(); 10 | } 11 | 12 | class myapp 13 | { 14 | public: 15 | myapp(void); 16 | ~myapp(void); 17 | 18 | int operator()(void); 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /test/myexception_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2014 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #define BOOST_TEST_MODULE myexception_test 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace boost; 18 | 19 | #include 20 | #include 21 | 22 | // you should probably add it to a header 23 | // -> 24 | 25 | // generic exception to be used insted Boost.System 26 | class myexception_base : public std::exception 27 | { 28 | public: 29 | // build a new exception using LastError on Windows and errno on Unix 30 | explicit myexception_base(const std::string& msg, unsigned int code) 31 | : message_(msg) , code_(code) 32 | { } 33 | 34 | virtual const char * what () const throw () { 35 | return message_.c_str(); 36 | } 37 | 38 | unsigned int code() const { 39 | return code_; 40 | } 41 | 42 | private: 43 | std::string message_; int code_; 44 | }; 45 | 46 | struct myexception : public myexception_base 47 | { 48 | myexception(const std::string& what, unsigned int error_code) 49 | : myexception_base(what, error_code) {} 50 | 51 | std::string mymessage() 52 | { 53 | std::stringstream msg; 54 | 55 | msg 56 | << what () 57 | << "(" 58 | << code() 59 | << ")" 60 | << std::endl; 61 | 62 | return msg.str(); 63 | } 64 | }; 65 | 66 | #define BOOST_APPLICATION_TROWN_MY_OWN_EXCEPTION throw myexception 67 | #include 68 | // <- 69 | 70 | using namespace boost; 71 | 72 | class myapp 73 | { 74 | public: 75 | 76 | myapp(application::context& context) 77 | : context_(context) 78 | { 79 | } 80 | 81 | int operator()() 82 | { 83 | if(!context_.find()) 84 | { 85 | throw myexception("custon error", 4121); 86 | } 87 | 88 | return 0; 89 | } 90 | 91 | private: 92 | application::context& context_; 93 | 94 | }; 95 | 96 | 97 | 98 | 99 | BOOST_AUTO_TEST_CASE(myexception_throw) 100 | { 101 | { 102 | application::context app_context; 103 | myapp app(app_context); 104 | 105 | BOOST_CHECK_THROW(application::launch(app, app_context), myexception); 106 | } 107 | } 108 | 109 | /* 110 | int test_main(int argc, char** argv) 111 | { 112 | 113 | try 114 | { 115 | application::context app_context; 116 | myapp app(app_context); 117 | 118 | BOOST_CHECK_THROW(application::launch(app, app_context), myexception); 119 | 120 | 121 | return application::launch(app, app_context); 122 | } 123 | catch(myexception &e) 124 | { 125 | std::cerr << e.mymessage(); 126 | 127 | BOOST_CHECK(e.code() == 4121); 128 | 129 | return 0; 130 | } 131 | 132 | BOOST_CHECK(0); 133 | 134 | return 0; 135 | } 136 | 137 | 138 | 139 | */ -------------------------------------------------------------------------------- /test/path_aspect_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE PathAspect 13 | #include 14 | 15 | using namespace boost; 16 | 17 | BOOST_AUTO_TEST_CASE(path_aspect) 18 | { 19 | auto& argc = boost::unit_test::framework::master_test_suite().argc; 20 | auto& argv = boost::unit_test::framework::master_test_suite().argv; 21 | 22 | filesystem::path module_path_name; 23 | 24 | #if defined( BOOST_WINDOWS_API ) 25 | wchar_t module_name[MAX_PATH]; 26 | 27 | if (GetModuleFileNameW(0, module_name, sizeof(module_name)) > 0) 28 | { 29 | module_path_name = module_name; 30 | } 31 | #elif defined( BOOST_POSIX_API ) 32 | std::string command = argv[0]; 33 | char resolved_path[PATH_MAX]; 34 | 35 | // realpath -returns the canonicalized absolute pathname 36 | if (realpath (command.c_str(), resolved_path)) 37 | { 38 | module_path_name = std::string (resolved_path); 39 | } 40 | #endif 41 | 42 | application::path path; 43 | 44 | { 45 | BOOST_CHECK(filesystem::current_path() == path.current_path()); 46 | } 47 | 48 | { 49 | filesystem::path module_path(module_path_name); 50 | BOOST_CHECK(module_path.stem() == path.executable_name()); 51 | } 52 | 53 | { 54 | filesystem::path module_path(module_path_name); 55 | BOOST_CHECK(module_path.filename() == path.executable_full_name()); 56 | } 57 | 58 | { 59 | filesystem::path module_path(module_path_name); 60 | BOOST_CHECK(module_path.parent_path() == path.executable_path()); 61 | } 62 | 63 | { 64 | BOOST_CHECK(module_path_name == path.executable_path_name()); 65 | } 66 | 67 | std::string isempty; 68 | BOOST_CHECK(!isempty.size()); 69 | 70 | isempty = path.app_data_path().string(); 71 | BOOST_CHECK(isempty.size()); 72 | 73 | isempty = path.home_path().string(); 74 | BOOST_CHECK(isempty.size()); 75 | 76 | isempty = path.config_path().string(); 77 | BOOST_CHECK(isempty.size()); 78 | 79 | isempty = path.app_data_path().string(); 80 | BOOST_CHECK(isempty.size()); 81 | 82 | isempty = path.temp_path().string(); 83 | BOOST_CHECK(isempty.size()); 84 | 85 | 86 | } 87 | 88 | -------------------------------------------------------------------------------- /test/signal_binder_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE SignalBinder 13 | #include 14 | 15 | using namespace boost; 16 | 17 | struct handler_test 18 | { 19 | int count_; 20 | bool called_; 21 | handler_test() : count_(0), called_(false) { } 22 | 23 | bool signal_handler1() 24 | { 25 | called_ = true; 26 | return false; 27 | } 28 | 29 | bool running() 30 | { 31 | count_++; 32 | return !called_; 33 | } 34 | }; 35 | 36 | class my_signal_binder : public application::signal_binder 37 | { 38 | public: 39 | my_signal_binder(application::context &app_context) 40 | : application::signal_binder(app_context){} 41 | 42 | void start() 43 | { 44 | signal_binder::start(); 45 | } 46 | }; 47 | 48 | BOOST_AUTO_TEST_CASE(signal_binder) 49 | { 50 | application::context app_context; 51 | my_signal_binder app_signal_binder(app_context); 52 | handler_test app_handler_test; 53 | 54 | app_signal_binder.start(); 55 | 56 | application::handler<>::callback cb = boost::bind( 57 | &handler_test::signal_handler1, &app_handler_test); 58 | 59 | boost::system::error_code ec; 60 | app_signal_binder.bind(SIGABRT, cb, ec); 61 | 62 | raise(SIGABRT); 63 | 64 | BOOST_CHECK(!ec); 65 | 66 | app_signal_binder.bind(SIGINT, cb, ec); 67 | 68 | BOOST_CHECK(!ec); 69 | 70 | app_signal_binder.bind(SIGINT, cb, cb, ec); 71 | 72 | BOOST_CHECK(!ec); 73 | BOOST_CHECK(app_signal_binder.is_bound(SIGINT)); 74 | 75 | app_signal_binder.unbind(SIGINT, ec); 76 | 77 | BOOST_CHECK(!app_signal_binder.is_bound(SIGINT)); 78 | 79 | while(app_handler_test.running()) 80 | std::cerr << "waiting..." << std::endl; 81 | 82 | BOOST_CHECK(app_handler_test.count_ > 0); 83 | 84 | } 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /test/simple_common_application_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE SimpleCommonApplication 13 | #include 14 | 15 | using namespace boost; 16 | 17 | class myapp 18 | { 19 | public: 20 | 21 | myapp(application::context& context) 22 | : context_(context) { } 23 | 24 | int operator()() 25 | { 26 | return 0; 27 | } 28 | 29 | private: 30 | application::context& context_; 31 | }; 32 | 33 | BOOST_AUTO_TEST_CASE(simple_common_application) 34 | { 35 | application::context app_context; 36 | myapp app(app_context); 37 | 38 | BOOST_CHECK(application::launch(app, app_context) == 0); 39 | } 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/simple_server_application_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011-2012 Renato Tegon Forti 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt 4 | // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // For more information, see http://www.boost.org 7 | 8 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 9 | 10 | #include 11 | #include 12 | #define BOOST_TEST_MODULE SimpleServerApplication 13 | #include 14 | 15 | using namespace boost; 16 | 17 | class myapp 18 | { 19 | public: 20 | myapp(application::context& context) 21 | : context_(context) { } 22 | 23 | int operator()() 24 | { 25 | return 0; 26 | } 27 | 28 | private: 29 | application::context& context_; 30 | }; 31 | 32 | BOOST_AUTO_TEST_CASE(simple_server_application) 33 | { 34 | application::context app_context; 35 | myapp app(app_context); 36 | 37 | boost::system::error_code ec; 38 | int ret = application::launch(app, app_context, ec); 39 | 40 | #if defined(BOOST_WINDOWS_API) 41 | #if !defined(__MINGW32__) 42 | // 1063 (0x427) 43 | // The service process could not connect to the service controller. 44 | BOOST_CHECK(ec.value() == 1063); 45 | // on windows we need run on SCM 46 | #endif 47 | #else 48 | BOOST_CHECK(ret == 0); 49 | #endif 50 | 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /test/tunit_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST 4 | //[intro 5 | #include 6 | #include 7 | #define BOOST_TEST_MODULE Tunit 8 | #include 9 | 10 | // other unit 11 | #include "myapp.h" 12 | 13 | BOOST_AUTO_TEST_CASE(tunit) 14 | { 15 | auto& argc = boost::unit_test::framework::master_test_suite().argc; 16 | auto& argv = boost::unit_test::framework::master_test_suite().argv; 17 | 18 | myapp app; 19 | application::global_context_ptr ctx = application::global_context::create(); 20 | 21 | this_application()->insert( 22 | boost::make_shared(argc, argv)); 23 | 24 | BOOST_CHECK(application::launch(app, ctx) == 0); 25 | 26 | application::global_context::destroy(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vc11ide/application_mode_apache_httpd_mod.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /vc11ide/application_mode_select.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/boost_application.opensdf: -------------------------------------------------------------------------------- 1 | RenatoPC-DEV-01 -------------------------------------------------------------------------------- /vc11ide/boost_application.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/vc11ide/boost_application.suo -------------------------------------------------------------------------------- /vc11ide/boost_application.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/vc11ide/boost_application.v11.suo -------------------------------------------------------------------------------- /vc11ide/boost_application.v14.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/retf/Boost.Application/4d0cf24587694a67a58bb20614d035e059f103c8/vc11ide/boost_application.v14.suo -------------------------------------------------------------------------------- /vc11ide/limit_single_instance.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/limit_single_instance_boost_interprocess_named_mutex.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/limit_single_instance_callback.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/limit_single_instance_callback_with_global_context.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/my_own_termination_handler.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/my_own_wait_for_termination_request.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/myexception.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/path.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/pid.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/service_setup_ex.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/simple_application.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/simple_application_with_global_context.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/simple_server_application.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/simple_server_application_with_auto_handler.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/simple_server_application_with_auto_handler_and_global_context.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/termination_handler.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/termination_handler_with_global_context.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/test_signal_binder_test.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/time_based_plugin_job.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/tutorial_stage1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/tutorial_stage2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/tutorial_stage3.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/tutorial_stage4.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/wait_for_termination_request.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /vc11ide/work_queue.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | --------------------------------------------------------------------------------