Stroika Library 3.0d23x
 
Loading...
Searching...
No Matches
Interceptor.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#include "Stroika/Frameworks/StroikaPreComp.h"
5
8
9#include "Interceptor.h"
10
11using namespace Stroika::Foundation;
13
14using Memory::MakeSharedPtr;
15
16using namespace Stroika::Frameworks;
17using namespace Stroika::Frameworks::WebServer;
18
19/*
20 ********************************************************************************
21 ***************************** Interceptor::MyRep_ ******************************
22 ********************************************************************************
23 */
24class Interceptor::MyRep_ : public Interceptor::_IRep {
25 function<void (Message&)> fHandleMessage_;
26 function<void (Message&, const exception_ptr& e)> fHandleFault_;
27
28public:
29 MyRep_ (const function<void (Message&)>& handleMessage, const function<void (Message&, const exception_ptr&)>& handleFault)
30 : fHandleMessage_{handleMessage}
31 , fHandleFault_{handleFault}
32 {
33 }
34 virtual void HandleFault (Message& m, const exception_ptr& e) const noexcept override
35 {
36 fHandleFault_ (m, e);
37 }
38 virtual void HandleMessage (Message& m) const override
39 {
40 fHandleMessage_ (m);
41 }
42};
43
44/*
45 ********************************************************************************
46 ***************************** WebServer::Interceptor ***************************
47 ********************************************************************************
48 */
49Interceptor::Interceptor (const function<void (Message&)>& handleMessage, const function<void (Message&, const exception_ptr&)>& handleFault)
50 : Interceptor{MakeSharedPtr<MyRep_> (handleMessage, handleFault)}
51{
52}
53
54/*
55 ********************************************************************************
56 *********************** WebServer::Interceptor::_IRep **************************
57 ********************************************************************************
58 */
59void Interceptor::_IRep::HandleFault ([[maybe_unused]] Message& m, [[maybe_unused]] const exception_ptr& e) const noexcept
60{
61}
62
63void Interceptor::_IRep::CompleteNormally ([[maybe_unused]] Message& m) const
64{
65}
66
68{
69 return "{}"_f(reinterpret_cast<const void*> (this)); // ptr representation
70}
auto MakeSharedPtr(ARGS_TYPE &&... args) -> shared_ptr< T >
same as make_shared, but if type T has block allocation, then use block allocation for the 'shared pa...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
virtual void CompleteNormally(Message &m) const
virtual void HandleMessage(Message &m) const =0
virtual Characters::String ToString() const
virtual void HandleFault(Message &m, const exception_ptr &e) const noexcept