📄 warsvrdefinition.h
字号:
/** The server definition is a template that tells WarSvrEngine a host:port to listen to, and how to create the appropriate WarServerProtocol object when a connection is made. Derived classes may also store extra configuration information, like default virtual-server properties, security-settings ol. This is also the container for site-spesific data, like mime-types, auth-modules etc.*/#ifndef WAR_SVR_DEFINITION_H#define WAR_SVR_DEFINITION_H/* SYSTEM INCLUDES */#ifndef WAR_SET_INCLUDED# define WAR_SET_INCLUDED# include <set>#endif/* PROJECT INCLUDES */#ifndef WAR_PTR_WRAPPER_H# include "WarPtrWrapper.h"#endif#ifndef WAR_NET_ADDRESS_H# include "WarNetAddress.h"#endif#ifndef WAR_SMART_POINTER_H# include "WarSmartPointer.h"#endif#ifndef WAR_SVR_PROPERTIES_H# include "WarSvrProperties.h"#endif#ifndef WAR_SOCKET_IO_H# include "WarSocketIo.h"#endif#ifndef WAR_USER_AUTH_H# include "WarUserAuth.h"#endif#ifndef WAR_USER_ENGINE_H# include "WarUserEngine.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */class WarSvrProtocol;class WarSocketIo;class WarIfMimeTypes;typedef WarPtrWrapper<WarIfMimeTypes> war_if_mime_types_ptr_t;#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarSvrDefinition : public WarSmartPointer{public: typedef std::string mime_type_t; typedef std::basic_string<war_sysch_t> filename_t; typedef std::list<filename_t> filename_list_t; typedef std::map<filename_t, std::string> mime_map_t; // extension --> Mime type // LIFECYCLE /** * Default constructor. */ WarSvrDefinition() throw(WarException); // OPERATORS inline bool operator == (const WarSvrDefinition& from) { return mLocalHost == from.mLocalHost; } inline bool operator < (const WarSvrDefinition& from) { return mLocalHost < from.mLocalHost; } // OPERATIONS /** Create a new instance of the server * */ WarSvrProtocol *CreateNewInstance( war_socket_io_ptr_t& companionPtr) throw(WarException); /** Resolves a mime-type. * @param extName File extension to resolve. The * extension does not include the leading '.' character, * but only the name (like "html"). * @param dstMimeType Return bufgfer where the result is * stored. This is the mime-type like "text/html". * @return The function returns true if the mime-type * is resolved. */ bool ResolvMimeType(const filename_t& extName, mime_type_t& dstMimeType) const; // ACCESS WarNetAddress& GetHost() { return mLocalHost; } WarUserEngine& GetAuth() const { return (WarUserEngine&)mAuthEngine; } // INQUIRY std::string Explain() const; const std::string GetSiteName() const; const std::string GetNativeSiteName() const; void GetDefaultPage(filename_list_t& dstList) const; // Properties to be inherited by children WarSvrProperties mProperties; protected: // Call by CreateNewInstance overrides!! void OnCreateNew(WarSvrProtocol *newChild); // Override !! virtual WarSvrProtocol *GetNewSvr( war_socket_io_ptr_t& companionPtr) throw(WarException) = 0;private: friend class WarIfSite; friend class WarIfServer; WarNetAddress mLocalHost; WarUserEngine mAuthEngine; // User authentication std::string mSiteName; // Jgaa's fan club ... std::string mNativeSiteName; // Default site filename_list_t mDefaultPage; war_if_mime_types_ptr_t mMimePtr;};template <class serverT>class WarSvrDefinitionImpl : public WarSvrDefinition{public: typedef serverT server_t; WarSvrDefinitionImpl() throw(WarException) { } protected: virtual WarSvrProtocol *GetNewSvr( war_socket_io_ptr_t& companionPtr) throw(WarException) { return new server_t(companionPtr, *this); } };/* INLINE METHODS *//* EXTERNAL REFERENCES */typedef WarPtrWrapper<WarSvrDefinition> war_svrdef_ptr_t;typedef std::set<war_svrdef_ptr_t> war_svrdef_list_t;#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_SVR_DEFINITION_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -