File indexing completed on 2025-01-18 09:55:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
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
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
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
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