LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/sandesh/library/cpp - request_pipeline.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 2 2 100.0 %
Date: 2026-08-03 02:19:58 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : //
       6             : // request_pipeline.h
       7             : //
       8             : 
       9             : #ifndef __REQUEST_PIPELINE_H__
      10             : #define __REQUEST_PIPELINE_H__
      11             : 
      12             : #include <boost/ptr_container/ptr_vector.hpp>
      13             : #include <boost/function.hpp>
      14             : #include <boost/shared_ptr.hpp>
      15             : #include <vector>
      16             : 
      17             : class SandeshRequest;
      18             : class Sandesh;
      19             : 
      20             : class RequestPipeline {
      21             : public:
      22             :     class PipeImpl;
      23             :     class StageImpl;
      24             : 
      25             :     ~RequestPipeline() {}
      26             : 
      27             :     // Clients can build and store a (taskId,InstanceId)'s
      28             :     // intermediate information in an object who's type is
      29             :     // derived from InstanceData
      30             :     class InstData {
      31             :     public:
      32             :         virtual ~InstData() {}
      33             :     protected:
      34             :         InstData() {}
      35             :     };
      36             : 
      37             :     // In the callback function, clients can access data from any previous
      38             :     // stage.
      39             :     typedef boost::ptr_vector<InstData> StageData;
      40             : 
      41             :     // Client must provide an allocator for their Data
      42             :     typedef boost::function<InstData*(int stage)> DataFactory;
      43             : 
      44             :     // Clients must provide this callback function on a per-taskID basis
      45             :     struct PipeSpec;
      46             :     typedef boost::function<bool(const Sandesh * sr, const PipeSpec& pspec,
      47             :             int stage, int instNum, InstData* dataInAndOut)> CallbackFunc;
      48             : 
      49             :     // The StageSpec for a Stage of the pipeline contains the taskId to
      50             :     // be used, the InstanceIds to be launched in parallel, the client
      51             :     // callback and an allocator function for allocating InstData
      52             :     // If the allocator function is not provided, NULL will be passed
      53             :     // back in the callback function for that stage
      54             :     struct StageSpec {
      55             :         int taskId_;
      56             :         std::vector<int> instances_;
      57             :         CallbackFunc cbFn_;
      58             :         DataFactory allocFn_;
      59             :     };
      60             :     // The pipespec is used to pass in the stages, and
      61             :     // also has an interface (GetStageData) that the callback can use to
      62             :     // access Data from previous stages
      63             :     struct PipeSpec {
      64             :         PipeSpec(const SandeshRequest * sr);
      65             :         std::vector<StageSpec> stages_;
      66             :         boost::shared_ptr<const SandeshRequest> snhRequest_;
      67             : 
      68             :         const StageData* GetStageData(int stage) const;
      69             : 
      70             :         // This function is not intended for client use
      71        1931 :         PipeSpec(const PipeSpec& ps, PipeImpl * impl) :
      72        1931 :             stages_(ps.stages_), snhRequest_(ps.snhRequest_), impl_(impl) {}
      73             :     private:
      74             :         PipeImpl * impl_;
      75             :     };
      76             : 
      77             :     // Client Construct a Pipeline by passing the specification
      78             :     RequestPipeline(const PipeSpec& spec);
      79             : 
      80             : private:
      81             :     class StageWorker;
      82             : 
      83             :     PipeImpl * impl_;
      84             : };
      85             : 
      86             : #endif // __REQUEST_PIPELINE_H__

Generated by: LCOV version 1.14