Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:35:01

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one
0003  * or more contributor license agreements. See the NOTICE file
0004  * distributed with this work for additional information
0005  * regarding copyright ownership. The ASF licenses this file
0006  * to you under the Apache License, Version 2.0 (the
0007  * "License"); you may not use this file except in compliance
0008  * with the License. You may obtain a copy of the License at
0009  *
0010  *   http://www.apache.org/licenses/LICENSE-2.0
0011  *
0012  * Unless required by applicable law or agreed to in writing,
0013  * software distributed under the License is distributed on an
0014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0015  * KIND, either express or implied. See the License for the
0016  * specific language governing permissions and limitations
0017  * under the License.
0018  */
0019 
0020 #ifndef PEEKPROCESSOR_H
0021 #define PEEKPROCESSOR_H
0022 
0023 #include <string>
0024 #include <thrift/TProcessor.h>
0025 #include <thrift/transport/TTransport.h>
0026 #include <thrift/transport/TTransportUtils.h>
0027 #include <thrift/transport/TBufferTransports.h>
0028 #include <memory>
0029 
0030 namespace apache {
0031 namespace thrift {
0032 namespace processor {
0033 
0034 /*
0035  * Class for peeking at the raw data that is being processed by another processor
0036  * and gives the derived class a chance to change behavior accordingly
0037  *
0038  */
0039 class PeekProcessor : public apache::thrift::TProcessor {
0040 
0041 public:
0042   PeekProcessor();
0043   ~PeekProcessor() override;
0044 
0045   // Input here: actualProcessor  - the underlying processor
0046   //             protocolFactory  - the protocol factory used to wrap the memory buffer
0047   //             transportFactory - this TPipedTransportFactory is used to wrap the source transport
0048   //                                via a call to getPipedTransport
0049   void initialize(
0050       std::shared_ptr<apache::thrift::TProcessor> actualProcessor,
0051       std::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory,
0052       std::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory);
0053 
0054   std::shared_ptr<apache::thrift::transport::TTransport> getPipedTransport(
0055       std::shared_ptr<apache::thrift::transport::TTransport> in);
0056 
0057   void setTargetTransport(std::shared_ptr<apache::thrift::transport::TTransport> targetTransport);
0058 
0059   bool process(std::shared_ptr<apache::thrift::protocol::TProtocol> in,
0060                        std::shared_ptr<apache::thrift::protocol::TProtocol> out,
0061                        void* connectionContext) override;
0062 
0063   // The following three functions can be overloaded by child classes to
0064   // achieve desired peeking behavior
0065   virtual void peekName(const std::string& fname);
0066   virtual void peekBuffer(uint8_t* buffer, uint32_t size);
0067   virtual void peek(std::shared_ptr<apache::thrift::protocol::TProtocol> in,
0068                     apache::thrift::protocol::TType ftype,
0069                     int16_t fid);
0070   virtual void peekEnd();
0071 
0072 private:
0073   std::shared_ptr<apache::thrift::TProcessor> actualProcessor_;
0074   std::shared_ptr<apache::thrift::protocol::TProtocol> pipedProtocol_;
0075   std::shared_ptr<apache::thrift::transport::TPipedTransportFactory> transportFactory_;
0076   std::shared_ptr<apache::thrift::transport::TMemoryBuffer> memoryBuffer_;
0077   std::shared_ptr<apache::thrift::transport::TTransport> targetTransport_;
0078 };
0079 }
0080 }
0081 } // apache::thrift::processor
0082 
0083 #endif