ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
1.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // See accompanying file COPYING.TXT file for licensing details.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef CPPCMS_IMPL_WINSERVICE_H
  9. #define CPPCMS_IMPL_WINSERVICE_H
  10. #include <booster/function.h>
  11. #include <cppcms/defs.h>
  12. #include <cppcms/json.h>
  13. #include <string>
  14. namespace cppcms {
  15. namespace impl {
  16. class CPPCMS_API winservice {
  17. winservice();
  18. ~winservice();
  19. public:
  20. typedef booster::function<void()> callback_type;
  21. static winservice &instance();
  22. // Returns false if it was only install/uninstall process
  23. // rather then execution
  24. void prepare(callback_type const &callback)
  25. {
  26. prepare_=callback;
  27. }
  28. void prepare()
  29. {
  30. if(prepare_) prepare_();
  31. }
  32. void stop(callback_type const &callback)
  33. {
  34. stop_ = callback;
  35. }
  36. void stop()
  37. {
  38. if(stop_) stop_();
  39. }
  40. void exec(callback_type const &callback)
  41. {
  42. exec_ = callback;
  43. }
  44. void exec()
  45. {
  46. if(exec_) exec_();
  47. }
  48. void run(json::value &conf,int argc,char **argv);
  49. static bool is_console(json::value &conf)
  50. {
  51. return conf.get("winservice.mode","console") == "console";
  52. }
  53. private:
  54. callback_type prepare_,stop_,exec_;
  55. std::vector<std::string> args_;
  56. void uninstall();
  57. void install();
  58. void service();
  59. void console();
  60. json::value settings_;
  61. };
  62. }
  63. }
  64. #endif