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

Generated by: LCOV version 1.14