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.
 
 
 
 
 
 

115 lines
3.2 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_SESSION_POOL_H
  9. #define CPPCMS_SESSION_POOL_H
  10. #include <cppcms/defs.h>
  11. #include <booster/shared_ptr.h>
  12. #include <booster/hold_ptr.h>
  13. #include <cppcms/session_api.h>
  14. #include <booster/auto_ptr_inc.h>
  15. namespace cppcms {
  16. class service;
  17. namespace impl {
  18. struct cached_settings;
  19. }
  20. namespace sessions {
  21. class encryptor_factory;
  22. class session_storage_factory;
  23. }
  24. namespace json { class value; }
  25. ///
  26. /// \brief This class provides an access to session management backends an allow customization.
  27. ///
  28. /// When user implements its own session_api, sessions::encryptor or sessions::session_storage
  29. /// interfaces it may set their factories to these classes
  30. ///
  31. class CPPCMS_API session_pool: public booster::noncopyable {
  32. public:
  33. ///
  34. /// Constructor that is used together with CppCMS service
  35. ///
  36. session_pool(service &srv);
  37. ///
  38. /// Constructor that is used to create independent pool to access the session storage by external tools
  39. ///
  40. /// \ver{v1_2}
  41. session_pool(json::value const &v);
  42. ///
  43. /// Destructor
  44. ///
  45. ~session_pool();
  46. ///
  47. /// Initialize the pool - must be called before get() can be used
  48. ///
  49. /// Note: it allows to install custom session_api, encryptor or storage functionality
  50. ///
  51. /// \ver{v1_2}
  52. void init();
  53. ///
  54. /// Get an actual object that is used to store/retreive session data
  55. ///
  56. /// \ver{v1_2}
  57. booster::shared_ptr<session_api> get();
  58. ///
  59. /// Assign your own implementation of session_api passing pointer to session_api_factory.
  60. ///
  61. void backend(std::auto_ptr<session_api_factory> b);
  62. ///
  63. /// Assign your own implementation of sessions::encryptor that would be used for client side session
  64. /// management by passing pointer to sessions::encryptor_factory
  65. ///
  66. void encryptor(std::auto_ptr<sessions::encryptor_factory> e);
  67. ///
  68. /// Assign your own implementation of sessions::session_storage that would be used for server side session
  69. /// management by passing pointer to sessions::session_storage_factory
  70. ///
  71. void storage(std::auto_ptr<sessions::session_storage_factory> s);
  72. private:
  73. impl::cached_settings const &cached_settings();
  74. void after_fork();
  75. struct cookies_factory;
  76. struct dual_factory;
  77. struct sid_factory;
  78. class gc_job;
  79. template<typename Encryptor>
  80. struct enc_factory;
  81. template<typename Encryptor>
  82. struct enc_factory_param;
  83. struct _data;
  84. friend struct cookies_factory;
  85. friend struct dual_factory;
  86. friend struct sid_factory;
  87. friend class session_interface;
  88. friend class gc_job;
  89. booster::hold_ptr<_data> d;
  90. std::auto_ptr<session_api_factory> backend_;
  91. std::auto_ptr<sessions::encryptor_factory> encryptor_;
  92. std::auto_ptr<sessions::session_storage_factory> storage_;
  93. service *service_;
  94. };
  95. }
  96. #endif