Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:12

0001 /*
0002  * This File is part of Davix, The IO library for HTTP based protocols
0003  * Copyright (C) CERN 2013
0004  * Author: Adrien Devresse <adrien.devresse@cern.ch>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  *
0020 */
0021 
0022 #ifndef DAVIXCONTEXT_HPP
0023 #define DAVIXCONTEXT_HPP
0024 
0025 #include <string>
0026 #include <status/davixstatusrequest.hpp>
0027 #include <hooks/davix_hooks.hpp>
0028 #include <utils/davix_uri.hpp>
0029 
0030 #ifndef __DAVIX_INSIDE__
0031 #error "Only davix.h or davix.hpp should be included."
0032 #endif
0033 
0034 
0035 ///
0036 /// @file davixcontext.hpp
0037 /// @author Devresse Adrien
0038 ///
0039 ///  Handle of Davix
0040 
0041 namespace Davix{
0042 
0043 struct ContextInternal;
0044 struct ContextExplorer;
0045 class HookList;
0046 class HttpRequest;
0047 class DavPosix;
0048 
0049 
0050 
0051 /// @brief Main handle for Davix
0052 ///
0053 /// Each new davix context contains its own session-reuse pool and set of parameters
0054 /// a Context can execute multiple queries in parallels and is thread safe
0055 class DAVIX_EXPORT Context
0056 {
0057 public:
0058     ///
0059     /// \brief Default constructor
0060     ///
0061     Context();
0062     ///
0063     /// \brief copy constructor
0064     /// \param c
0065     ///
0066     Context(const Context & c);
0067     ///
0068     /// \brief assignment operator
0069     /// \param c
0070     /// \return
0071     ///
0072     Context & operator=(const Context & c);
0073     ///
0074     /// \brief destructor
0075     ///
0076     virtual ~Context();
0077 
0078     /// clone this instance to a new context
0079     Context* clone();
0080 
0081 #ifdef __DAVIX_HAS_STD_FUNCTION
0082 
0083     /// set a new hook (callback) to intercept event in davix
0084     /// see davix_hooks.hpp for more details about hooks
0085     /// WARNING: setting a new HOOK override exiting ones
0086     template<typename HookType>
0087     inline void setHook(const HookType & id){
0088         hookDefine<HookType>(getHookList(), id);
0089     }
0090 
0091     /// get the value register for one type of hook
0092     template<typename HookType>
0093     inline const HookType & getHook(){
0094         return hookGet<HookType>(getHookList());
0095     }
0096 
0097 #endif
0098 
0099 
0100     /// @brief load a plugin or a profile identified by name
0101     /// @param name : name of the plugin or  profile to load
0102     ///
0103     /// Example: loadModule("grid") configure davix
0104     /// for a grid environment usage
0105     void loadModule(const std::string & name);
0106 
0107     ///  enable or disable the session caching
0108     void setSessionCaching(bool caching);
0109 
0110     /// get session caching status
0111     bool getSessionCaching() const;
0112 
0113     /// clear both redirect and session cache
0114     void clearCache();
0115 
0116 private:
0117     // internal context
0118     ContextInternal* _intern;
0119 
0120     friend class DavPosix;
0121     friend struct ContextExplorer;
0122     HookList & getHookList();
0123 public:
0124 
0125     /// @deprecated
0126     HttpRequest* createRequest(const Uri & uri, DavixError** err);
0127     /// @deprecated
0128     HttpRequest* createRequest(const std::string & url, DavixError** err);
0129     /// @deprecated
0130     DavPosix* createDavPosix();
0131 
0132 private:
0133 
0134 };
0135 
0136 
0137 /// runtime version string of the current davix library
0138 /// @return version of davix
0139 DAVIX_EXPORT const std::string & version();
0140 
0141 /// runtime version string of the current HTTP backend library
0142 /// @return version of backend library
0143 DAVIX_EXPORT const std::string backendRuntimeVersion();
0144 
0145 /// backend version _at the time of compilation_ which could
0146 /// be different than runtime one
0147 /// @return header version of backend library
0148 DAVIX_EXPORT const std::string backendHeadersVersion();
0149 
0150 }
0151 
0152 #endif // DAVIXCONTEXT_HPP