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.
 
 
 
 
 
 

64 lines
1.5 KiB

  1. #ifndef CPPCMS_SESSION_STORAGE_H
  2. #define CPPCMS_SESSION_STORAGE_H
  3. #include "defs.h"
  4. #include "refcounted.h"
  5. #include "noncopyable.h"
  6. #include "intrusive_ptr.h"
  7. #include <string>
  8. namespace cppcms {
  9. namespace sessions {
  10. ///
  11. /// \a session_server_storage is an abstract class that allows user to implements
  12. /// custom session storage device like, database storage device
  13. ///
  14. /// Note: if the member functions save/load/remove are thread safe -- can be called
  15. /// from different threads, than you may create a single session and return \a intrusive_ptr
  16. /// to a single intstance, otherwise you have to create multiple instances of object
  17. ///
  18. class session_storage :
  19. public util::noncopyable,
  20. public refcounted
  21. {
  22. public:
  23. ///
  24. /// Save session with end of life time at \a timeout using session id \a sid and content \a in
  25. ///
  26. virtual void save(std::string const &sid,time_t timeout,std::string const &in) = 0;
  27. ///
  28. /// Load session with \a sid, put its end of life time to \a timeout and return its
  29. /// value to \a out
  30. ///
  31. virtual bool load(std::string const &sid,time_t &timeout,std::string &out) = 0;
  32. ///
  33. /// Remove a session with id \a sid from the storage
  34. ///
  35. virtual void remove(std::string const &sid) = 0;
  36. virtual ~session_storage()
  37. {
  38. }
  39. };
  40. class session_storage_factory {
  41. public:
  42. virtual intrusive_ptr<session_storage> get() = 0;
  43. virtual bool requires_gc() = 0;
  44. virtual void gc_job() {}
  45. virtual ~session_storage_factory() {}
  46. };
  47. } // sessions
  48. } // cppcms
  49. #endif