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.
 
 
 
 
 
 

103 lines
3.3 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_API_H
  9. #define CPPCMS_SESSION_API_H
  10. #include <cppcms/defs.h>
  11. #include <booster/noncopyable.h>
  12. #include <booster/shared_ptr.h>
  13. #include <string>
  14. namespace cppcms {
  15. class session_interface;
  16. ///
  17. /// \brief This class represents the most generic implementation of session storage device
  18. ///
  19. /// This classes are created using session_api_factory and are designed to be reimplemented by users
  20. /// to provide an additional backends.
  21. ///
  22. /// This class is most generic that does not provide any goodies with exception of setting or getting session cookie,
  23. /// the user should generally take a look on sessions::session_storage or sessions::encryptor for easier implementation of session storage
  24. ///
  25. /// Note: these objects must be thread safe.
  26. ///
  27. class session_api : public booster::noncopyable
  28. {
  29. public:
  30. ///
  31. /// Save session's data:
  32. ///
  33. /// \param iface - the session_interface object that allows set session cookie
  34. /// \param data - the data that should be stored in the session
  35. /// \param timeout - the absolute expiration POSIX time
  36. /// \param new_data - flag that marks that new session object should be created regardless of current cookie value
  37. /// \param on_server - flag that marks that the data must be stored on the server and not in cookies only
  38. ///
  39. virtual void save(session_interface &iface,std::string const &data,time_t timeout, bool new_data, bool on_server) = 0;
  40. ///
  41. /// Load session's data
  42. ///
  43. /// \param iface - the session_interface object that allows read and set session cookie
  44. /// \param data - the string that should be filled with session data
  45. /// \param timeout - the expiration time of this session object
  46. /// \return true of session was loaded, false otherwise
  47. virtual bool load(session_interface &iface,std::string &data,time_t &timeout) = 0;
  48. ///
  49. /// Remove the session object
  50. ///
  51. /// \param iface - the session_interface object that allows read and set session cookie
  52. ///
  53. virtual void clear(session_interface &iface) = 0;
  54. ///
  55. /// Return true if the session store or save operations are blocking or very cpu intensive
  56. ///
  57. virtual bool is_blocking() = 0;
  58. ///
  59. /// Destructor
  60. ///
  61. virtual ~session_api() {}
  62. };
  63. ///
  64. /// \brief the factory object that generates custom implemented session_api objects
  65. ///
  66. class session_api_factory {
  67. public:
  68. ///
  69. /// Return true if this session API requires Garbage collection: i.e. execution of special function time to time
  70. /// to clear expired sessions from the memory
  71. ///
  72. virtual bool requires_gc() = 0;
  73. ///
  74. /// The actual garbage collection job (may do nothing).
  75. ///
  76. virtual void gc() = 0;
  77. ///
  78. /// Return a pointer to the session_api object. Note it may be shared between multiple requests or may be created each time per request
  79. ///
  80. virtual booster::shared_ptr<session_api> get() = 0;
  81. ///
  82. /// Destructor and cleanup function
  83. ///
  84. virtual ~session_api_factory() {}
  85. };
  86. } // cppcms
  87. #endif