4#include "Stroika/Frameworks/StroikaPreComp.h"
9#include "InterceptorChain.h"
14using Memory::MakeSharedPtr;
16using namespace Stroika::Frameworks;
20struct InterceptorChain::Rep_ : InterceptorChain::_IRep {
22 : fInterceptors_{interceptors}
27 return fInterceptors_;
31 return MakeSharedPtr<Rep_> (interceptors);
33 virtual void HandleMessage (
Message& m)
const override
35 size_t sz = fInterceptors_.size ();
39 fInterceptors_[i].HandleMessage (m);
42 exception_ptr e = current_exception ();
44 fInterceptors_[i].HandleFault (m, e);
50 fInterceptors_[i - 1].CompleteNormally (m);
66InterceptorChain::InterceptorChain (
const shared_ptr<_IRep>& rep)
67 : interceptors{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) ->
Sequence<
Interceptor> {
68 const InterceptorChain* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &InterceptorChain::interceptors);
69 return thisObj->fRep_.cget ().load ()->GetInterceptors ();
71 [qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]]
auto* property,
const Sequence<Interceptor>& interceptors) {
72 InterceptorChain* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &InterceptorChain::interceptors);
73 auto rwLock = thisObj->fRep_.rwget ();
74 rwLock.store (rwLock->get ()->SetInterceptors (interceptors));
82 auto rwLock = fRep_.rwget ();
83 [[maybe_unused]]
bool found{
false};
85 for (
size_t i = 0; i < newInterceptors.
size (); ++i) {
86 if (newInterceptors[i] == before) {
87 newInterceptors.
Insert (i, interceptor2Add);
93 rwLock.store (rwLock->get ()->SetInterceptors (newInterceptors));
98 auto rwLock = fRep_.rwget ();
100 [[maybe_unused]]
bool found{
false};
102 for (
size_t i = 0; i < newInterceptors.
size (); ++i) {
103 if (newInterceptors[i] == after) {
104 newInterceptors.
Insert (i + 1, interceptor2Add);
110 rwLock.store (rwLock->get ()->SetInterceptors (newInterceptors));
117 for (
auto i : fRep_.load ()->GetInterceptors ()) {
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...
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,...
A generalization of a vector: a container whose elements are keyed by the natural numbers.
nonvirtual void Insert(size_t i, ArgByValueType< value_type > item)
nonvirtual size_t size() const
Returns the number of items contained.
nonvirtual void AddBefore(const Interceptor &interceptor2Add, const Interceptor &before)
nonvirtual void AddAfter(const Interceptor &interceptor2Add, const Interceptor &after)