Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
WebServer/Interceptor.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
5
7
8 /*
9 ********************************************************************************
10 ***************************** WebServer::Interceptor ***************************
11 ********************************************************************************
12 */
13 inline Interceptor::Interceptor (const shared_ptr<_IRep>& rep)
14 : fRep_{rep}
15 {
16 RequireNotNull (rep);
17 }
18 inline void Interceptor::HandleFault (Message& m, const exception_ptr& e) const noexcept
19 {
20 Debug::AssertExternallySynchronizedMutex::ReadContext readLock{fThisAssertExternallySynchronized_};
21 fRep_->HandleFault (m, e);
22 }
23 inline void Interceptor::HandleMessage (Message& m) const
24 {
25 Debug::AssertExternallySynchronizedMutex::ReadContext readLock{fThisAssertExternallySynchronized_};
26 fRep_->HandleMessage (m);
27 }
28 inline void Interceptor::CompleteNormally (Message& m) const
29 {
30 Debug::AssertExternallySynchronizedMutex::ReadContext readLock{fThisAssertExternallySynchronized_};
31 fRep_->CompleteNormally (m);
32 }
33 inline bool Interceptor::operator== (const Interceptor& rhs) const
34 {
35 Debug::AssertExternallySynchronizedMutex::ReadContext readLock{fThisAssertExternallySynchronized_};
36 Debug::AssertExternallySynchronizedMutex::ReadContext readLock2{rhs.fThisAssertExternallySynchronized_};
37 return fRep_ == rhs.fRep_;
38 }
39 inline Characters::String Interceptor::ToString () const
40 {
41 Debug::AssertExternallySynchronizedMutex::ReadContext readLock{fThisAssertExternallySynchronized_};
42 return fRep_ == nullptr ? "nullptr"sv : fRep_->ToString ();
43 }
44 template <typename T>
45 inline auto Interceptor::_GetRep () const -> const T&
46 {
47 Debug::AssertExternallySynchronizedMutex::ReadContext readLock{fThisAssertExternallySynchronized_}; // not a fully sufficient check cuz returned value not checked during lifetime of this lock but pretty safe - and bug would be outside
48 EnsureMember (fRep_.get (), T);
49 return *dynamic_cast<const T*> (fRep_.get ());
50 }
51
52}
#define RequireNotNull(p)
Definition Assertions.h:347
#define EnsureMember(p, c)
Definition Assertions.h:319
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
shared_lock< const AssertExternallySynchronizedMutex > ReadContext
Instantiate AssertExternallySynchronizedMutex::ReadContext to designate an area of code where protect...