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 
0023 #ifndef DAVIX_HOOKS_IMPL_HPP
0024 #define DAVIX_HOOKS_IMPL_HPP
0025 
0026 #include <hooks/davix_hooks_fwd.hpp>
0027 
0028 // intern file, Never use directly
0029 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0030 
0031 namespace Davix{
0032 
0033 struct ContextInternal;
0034 
0035 #ifdef __DAVIX_HAS_STD_FUNCTION
0036 
0037 class HookList{
0038 public:
0039 
0040     RequestPreRunHook _pre_run_req;
0041 
0042     RequestPreSendHook _pre_send_req;
0043 
0044     RequestPreReceHook _pre_rece_req;
0045 
0046 private:
0047     HookList();
0048     friend struct ContextInternal;
0049 };
0050 
0051 
0052 // define
0053 template<typename HookType>
0054 inline void hookDefine(HookList & c,  const HookType & hook){
0055     (void) c;
0056     (void) hook;
0057     throw DavixException(std::string("davix::hook"), StatusCode::InvalidHook, "Invalid Hook type");
0058 }
0059 
0060 template<>
0061 inline void hookDefine(HookList &c, const RequestPreRunHook & hook){
0062     c._pre_run_req = hook;
0063 }
0064 
0065 template<>
0066 inline void hookDefine(HookList &c, const RequestPreSendHook & hook){
0067     c._pre_send_req = hook;
0068 }
0069 
0070 template<>
0071 inline void hookDefine(HookList &c, const RequestPreReceHook & hook){
0072     c._pre_rece_req = hook;
0073 }
0074 
0075 
0076 // get
0077 template<typename HookType>
0078 inline const HookType & hookGet(HookList & c){
0079     (void) c;
0080     throw DavixException(std::string("davix::hook"), StatusCode::InvalidHook, "Invalid Hook type");
0081 }
0082 
0083 template<>
0084 inline const RequestPreRunHook & hookGet(HookList & c){
0085     return c._pre_run_req;
0086 }
0087 
0088 template<>
0089 inline const RequestPreSendHook & hookGet(HookList & c){
0090     return c._pre_send_req;
0091 }
0092 
0093 template<>
0094 inline const RequestPreReceHook & hookGet(HookList & c){
0095     return c._pre_rece_req;
0096 }
0097 
0098 
0099 #endif
0100 
0101 }
0102 
0103 #endif
0104 
0105 #endif // DAVIX_HOOKS_IMPL_HPP