CppCMS
cppcms/session_storage.h
00001 
00002 //                                                                             
00003 //  Copyright (C) 2008-2012  Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>     
00004 //                                                                             
00005 //  See accompanying file COPYING.TXT file for licensing details.
00006 //
00008 #ifndef CPPCMS_SESSION_STORAGE_H
00009 #define CPPCMS_SESSION_STORAGE_H
00010 
00011 #include <cppcms/defs.h>
00012 #include <booster/noncopyable.h>
00013 #include <booster/shared_ptr.h>
00014 #include <string>
00015 
00016 namespace cppcms {
00017 namespace json {
00018         class value;
00019 }
00020 namespace sessions {
00021 
00030         
00031         class session_storage : public booster::noncopyable
00032         {
00033         public:
00037         
00038                 virtual void save(std::string const &sid,time_t timeout,std::string const &in) = 0;
00039 
00044                 virtual bool load(std::string const &sid,time_t &timeout,std::string &out) = 0;
00045                 
00049                 
00050                 virtual void remove(std::string const &sid) = 0;
00051 
00055                 virtual bool is_blocking() = 0; 
00056         
00057 
00061                 virtual ~session_storage()
00062                 {
00063                 }
00064         };
00065 
00069         class session_storage_factory {
00070         public:
00075                 virtual booster::shared_ptr<session_storage> get() = 0;
00076 
00080                 virtual bool requires_gc() = 0;
00085                 virtual void gc_job() {}
00089                 virtual ~session_storage_factory() {}
00090         };
00091 
00092         extern "C" {
00093                 typedef session_storage_factory *(*cppcms_session_storage_generator_type)(cppcms::json::value const &options);
00094         }
00095 
00096 
00097 } // sessions
00098 } // cppcms
00099 
00100 
00101 #endif