]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/cpp/src/thrift/processor/PeekProcessor.h
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 #ifndef PEEKPROCESSOR_H
21 #define PEEKPROCESSOR_H
24 #include <thrift/TProcessor.h>
25 #include <thrift/transport/TTransport.h>
26 #include <thrift/transport/TTransportUtils.h>
27 #include <thrift/transport/TBufferTransports.h>
35 * Class for peeking at the raw data that is being processed by another processor
36 * and gives the derived class a chance to change behavior accordingly
39 class PeekProcessor
: public apache::thrift::TProcessor
{
43 ~PeekProcessor() override
;
45 // Input here: actualProcessor - the underlying processor
46 // protocolFactory - the protocol factory used to wrap the memory buffer
47 // transportFactory - this TPipedTransportFactory is used to wrap the source transport
48 // via a call to getPipedTransport
50 std::shared_ptr
<apache::thrift::TProcessor
> actualProcessor
,
51 std::shared_ptr
<apache::thrift::protocol::TProtocolFactory
> protocolFactory
,
52 std::shared_ptr
<apache::thrift::transport::TPipedTransportFactory
> transportFactory
);
54 std::shared_ptr
<apache::thrift::transport::TTransport
> getPipedTransport(
55 std::shared_ptr
<apache::thrift::transport::TTransport
> in
);
57 void setTargetTransport(std::shared_ptr
<apache::thrift::transport::TTransport
> targetTransport
);
59 bool process(std::shared_ptr
<apache::thrift::protocol::TProtocol
> in
,
60 std::shared_ptr
<apache::thrift::protocol::TProtocol
> out
,
61 void* connectionContext
) override
;
63 // The following three functions can be overloaded by child classes to
64 // achieve desired peeking behavior
65 virtual void peekName(const std::string
& fname
);
66 virtual void peekBuffer(uint8_t* buffer
, uint32_t size
);
67 virtual void peek(std::shared_ptr
<apache::thrift::protocol::TProtocol
> in
,
68 apache::thrift::protocol::TType ftype
,
70 virtual void peekEnd();
73 std::shared_ptr
<apache::thrift::TProcessor
> actualProcessor_
;
74 std::shared_ptr
<apache::thrift::protocol::TProtocol
> pipedProtocol_
;
75 std::shared_ptr
<apache::thrift::transport::TPipedTransportFactory
> transportFactory_
;
76 std::shared_ptr
<apache::thrift::transport::TMemoryBuffer
> memoryBuffer_
;
77 std::shared_ptr
<apache::thrift::transport::TTransport
> targetTransport_
;
81 } // apache::thrift::processor