4#include "Stroika/Frameworks/StroikaPreComp.h"
8#include "InterceptorChain.h"
13using namespace Stroika::Frameworks;
17struct InterceptorChain::Rep_ : InterceptorChain::_IRep {
19 : fInterceptors_{interceptors}
24 return fInterceptors_;
28 return make_shared<Rep_> (interceptors);
30 virtual void HandleMessage (
Message& m)
const override
32 size_t sz = fInterceptors_.size ();
36 fInterceptors_[i].HandleMessage (m);
39 exception_ptr e = current_exception ();
41 fInterceptors_[i].HandleFault (m, e);
47 fInterceptors_[i - 1].CompleteNormally (m);
63InterceptorChain::InterceptorChain (
const shared_ptr<_IRep>& rep)
64 : interceptors{[qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]] const auto* property) ->
Sequence<
Interceptor> {
65 const InterceptorChain* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &InterceptorChain::interceptors);
66 return thisObj->fRep_.cget ().load ()->GetInterceptors ();
68 [qStroika_Foundation_Common_Property_ExtraCaptureStuff] ([[maybe_unused]]
auto* property,
const Sequence<Interceptor>& interceptors) {
69 InterceptorChain* thisObj = qStroika_Foundation_Common_Property_OuterObjPtr (property, &InterceptorChain::interceptors);
70 auto rwLock = thisObj->fRep_.rwget ();
71 rwLock.store (rwLock->get ()->SetInterceptors (interceptors));
79 auto rwLock = fRep_.rwget ();
80 [[maybe_unused]]
bool found{
false};
82 for (
size_t i = 0; i < newInterceptors.
size (); ++i) {
83 if (newInterceptors[i] == before) {
84 newInterceptors.
Insert (i, interceptor2Add);
90 rwLock.store (rwLock->get ()->SetInterceptors (newInterceptors));
95 auto rwLock = fRep_.rwget ();
97 [[maybe_unused]]
bool found{
false};
99 for (
size_t i = 0; i < newInterceptors.
size (); ++i) {
100 if (newInterceptors[i] == after) {
101 newInterceptors.
Insert (i + 1, interceptor2Add);
107 rwLock.store (rwLock->get ()->SetInterceptors (newInterceptors));
114 for (
auto i : fRep_.load ()->GetInterceptors ()) {
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)