lliohttpserver.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLIOHTTPSERVER_H
00034 #define LL_LLIOHTTPSERVER_H
00035 
00036 #include "llapr.h"
00037 #include "llchainio.h"
00038 #include "llhttpnode.h"
00039 
00040 class LLPumpIO;
00041 
00042 class LLIOHTTPServer
00043 {
00044 public:
00045         typedef void (*timing_callback_t)(const char* hashed_name, F32 time, void* data);
00046 
00047         static LLHTTPNode& create(apr_pool_t* pool, LLPumpIO& pump, U16 port);
00062         static void createPipe(LLPumpIO::chain_t& chain, 
00063             const LLHTTPNode& root, const LLSD& ctx);
00070         static void setTimingCallback(timing_callback_t callback, void* data);
00077 };
00078 
00079 /* @name Helper Templates
00080  *
00081  * These templates make it easy to create nodes that use thier own protocol
00082  * handlers rather than the default.  Typically, you subclass LLIOPipe to
00083  * implement the protocol, and then add a node using the templates:
00084  *
00085  * rootNode->addNode("thing", new LLHTTPNodeForPipe<LLThingPipe>);
00086  *
00087  * The templates are:
00088  *
00089  *      LLChainIOFactoryForPipe
00090  *              - a simple factory that builds instances of a pipe
00091  *
00092  *      LLHTTPNodeForFacotry
00093  *              - a HTTP node that uses a factory as the protocol handler
00094  *
00095  *      LLHTTPNodeForPipe
00096  *              - a HTTP node that uses a simple factory based on a pipe
00097  */
00099 
00100 template<class Pipe>
00101 class LLChainIOFactoryForPipe : public LLChainIOFactory
00102 {
00103 public:
00104         virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const
00105         {   
00106                 chain.push_back(LLIOPipe::ptr_t(new Pipe));
00107                 return true;
00108         }
00109 };
00110 
00111 template<class Factory>
00112 class LLHTTPNodeForFactory : public LLHTTPNode
00113 {
00114 public:
00115         const LLChainIOFactory* getProtocolHandler() const
00116                 { return &mProtocolHandler; }
00117 
00118 private:
00119         Factory mProtocolHandler;
00120 };
00121 
00123 
00124 
00125 template<class Pipe>
00126 class LLHTTPNodeForPipe : public LLHTTPNodeForFactory<
00127                                                                         LLChainIOFactoryForPipe<Pipe> >
00128 {
00129 };
00130 
00131 
00132 #endif // LL_LLIOHTTPSERVER_H
00133 

Generated on Thu Jul 1 06:08:46 2010 for Second Life Viewer by  doxygen 1.4.7