Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Message.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Frameworks/StroikaPreComp.h"
5
8
9#include "Message.h"
10
11using namespace Stroika::Foundation;
14using namespace Stroika::Foundation::Memory;
15
16using namespace Stroika::Frameworks;
17using namespace Stroika::Frameworks::WebServer;
18
20
21/*
22 ********************************************************************************
23 ************************* WebServer::Message ***********************************
24 ********************************************************************************
25 */
26static_assert (not copyable<Message>); // enforce docs Satisfies Concepts:
27static_assert (movable<Message>);
28
29Message::Message (Request&& srcRequest, Response&& srcResponse, const optional<IO::Network::SocketAddress>& peerAddress)
30 : peerAddress{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) -> optional<IO::Network::SocketAddress> {
31 const Message* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &Message::peerAddress);
32 AssertExternallySynchronizedMutex::ReadContext readLock{thisObj->fThisAssertExternallySynchronized_};
33 return thisObj->fPeerAddress_;
34 }}
35 , request{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) -> const Request& {
36 const Message* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &Message::request);
37 AssertExternallySynchronizedMutex::ReadContext readLock{thisObj->fThisAssertExternallySynchronized_};
38 return thisObj->fRequest_;
39 }}
40 , rwRequest{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) -> Request& {
41 Message* thisObj = const_cast<Message*> (qStroika_Foundation_Common_Property_OuterObjPtr (property, &Message::rwRequest));
42 AssertExternallySynchronizedMutex::WriteContext declareContext{thisObj->fThisAssertExternallySynchronized_};
43 return thisObj->fRequest_;
44 }}
45 , response{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) -> const Response& {
46 const Message* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &Message::response);
47 AssertExternallySynchronizedMutex::ReadContext readLock{thisObj->fThisAssertExternallySynchronized_};
48 return thisObj->fResponse_;
49 }}
50 , rwResponse{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) -> Response& {
51 Message* thisObj = const_cast<Message*> (qStroika_Foundation_Common_Property_OuterObjPtr (property, &Message::rwResponse));
52 AssertExternallySynchronizedMutex::WriteContext declareContext{thisObj->fThisAssertExternallySynchronized_};
53 return thisObj->fResponse_;
54 }}
55 , fPeerAddress_{peerAddress}
56 , fRequest_{move (srcRequest)}
57 , fResponse_{move (srcResponse)}
58{
59#if qStroika_Foundation_Debug_AssertExternallySynchronizedMutex_Enabled
60 fRequest_.SetAssertExternallySynchronizedMutexContext (fThisAssertExternallySynchronized_.GetSharedContext ());
61 fResponse_.SetAssertExternallySynchronizedMutexContext (fThisAssertExternallySynchronized_.GetSharedContext ());
62#endif
63}
64
65#if qStroika_Foundation_Debug_AssertExternallySynchronizedMutex_Enabled
66void Message::SetAssertExternallySynchronizedMutexContext (const shared_ptr<AssertExternallySynchronizedMutex::SharedContext>& sharedContext)
67{
68 fThisAssertExternallySynchronized_.SetAssertExternallySynchronizedMutexContext (sharedContext);
69 Assert (fThisAssertExternallySynchronized_.GetSharedContext () == sharedContext);
70 fRequest_.SetAssertExternallySynchronizedMutexContext (sharedContext);
71 fResponse_.SetAssertExternallySynchronizedMutexContext (sharedContext);
72}
73#endif
74
76{
77 AssertExternallySynchronizedMutex::ReadContext readLock{fThisAssertExternallySynchronized_};
79 sb << "{"sv;
80 sb << "PeerAddress: "sv << fPeerAddress_;
81 sb << ", Request: "sv << fRequest_;
82 sb << ", Response: "sv << fResponse_;
83 sb << "}"sv;
84 return sb;
85}
Similar to String, but intended to more efficiently construct a String. Mutable type (String is large...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
NOT a real mutex - just a debugging infrastructure support tool so in debug builds can be assured thr...
shared_lock< const AssertExternallySynchronizedMutex > ReadContext
Instantiate AssertExternallySynchronizedMutex::ReadContext to designate an area of code where protect...
unique_lock< AssertExternallySynchronizedMutex > WriteContext
Instantiate AssertExternallySynchronizedMutex::WriteContext to designate an area of code where protec...
Common::ReadOnlyProperty< Response & > rwResponse
Definition Message.h:93
Common::ReadOnlyProperty< const Request & > request
Definition Message.h:72
Common::ReadOnlyProperty< optional< IO::Network::SocketAddress > > peerAddress
Definition Message.h:66
Common::ReadOnlyProperty< const Response & > response
Definition Message.h:86
Common::ReadOnlyProperty< Request & > rwRequest
Definition Message.h:80
nonvirtual String ToString() const
Definition Message.cpp:75
this represents a HTTP request object for the WebServer module