CppCMS
|
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_POOL_H 00009 #define CPPCMS_SESSION_POOL_H 00010 00011 #include <cppcms/defs.h> 00012 #include <booster/shared_ptr.h> 00013 #include <booster/hold_ptr.h> 00014 #include <cppcms/session_api.h> 00015 00016 #include <memory> 00017 00018 namespace cppcms { 00019 class service; 00020 00021 namespace sessions { 00022 class encryptor_factory; 00023 class session_storage_factory; 00024 }; 00025 00032 class CPPCMS_API session_pool: public booster::noncopyable { 00033 public: 00035 session_pool(service &srv); 00036 ~session_pool(); 00037 00038 void init(); 00039 00040 booster::shared_ptr<session_api> get(); 00042 00046 void backend(std::auto_ptr<session_api_factory> b); 00051 void encryptor(std::auto_ptr<sessions::encryptor_factory> e); 00056 void storage(std::auto_ptr<sessions::session_storage_factory> s); 00057 private: 00058 00059 void after_fork(); 00060 00061 struct cookies_factory; 00062 struct dual_factory; 00063 struct sid_factory; 00064 class gc_job; 00065 template<typename Encryptor> 00066 struct enc_factory; 00067 template<typename Encryptor> 00068 struct enc_factory_param; 00069 00070 struct _data; 00071 00072 friend struct cookies_factory; 00073 friend struct dual_factory; 00074 friend struct sid_factory; 00075 friend class gc_job; 00076 00077 booster::hold_ptr<_data> d; 00078 00079 std::auto_ptr<session_api_factory> backend_; 00080 std::auto_ptr<sessions::encryptor_factory> encryptor_; 00081 std::auto_ptr<sessions::session_storage_factory> storage_; 00082 00083 service *service_; 00084 }; 00085 } 00086 00087 00088 #endif