AbstractStage.hpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * * Neither the name of Willow Garage, Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 /*
33  * AbstractStage.hpp
34  *
35  * @date 13.11.2015
36  * @author Tristan Igelbrink (Tristan@Igelbrink.com)
37  */
38 
39 
40 #ifndef ABSTRACTSTAGE_HPP__
41 #define ABSTRACTSTAGE_HPP__
42 
44 
45 // A pipeline stage interface class that can be overridden to perform
46 // customized steps. Each stage holds pointer to two queues. The in-queue,
47 // which is the incoming work for this stage, and out-queue, which is the
48 // completed work from this stage.
50 {
51 public:
52 
53  // default constructor
55  : m_done(false)
56  {
57  }
58 
59  void InitQueues( boost::shared_ptr<BlockingQueue > inQueue,
60  boost::shared_ptr<BlockingQueue > outQueue)
61  {
62  m_inQueue = inQueue;
63  m_outQueue = outQueue;
64  }
65 
66  // Activate this stage through this method. FirstStep(), Step() and
67  // LastStep() will be invoked sequentially until it's operation is
68  // completed.
69  void Run()
70  {
71  firstStep();
72 
73  while(done() == false)
74  {
75  step();
76  }
77 
78  lastStep();
79  }
80 
81  // override this method for the first step of this stage
82  virtual void firstStep() = 0;
83  // override this method for intermediate steps of this stage
84  virtual void step() = 0;
85  // override this method as the final step of this stage
86  virtual void lastStep() = 0;
87 
88  boost::shared_ptr<BlockingQueue> getInQueue() const { return m_inQueue; }
89  boost::shared_ptr<BlockingQueue> getOutQueue() const { return m_outQueue; }
90 
91  bool done() const { return m_done; }
92  void done(bool val) { m_done = val; }
93 
94 protected:
95 
96  boost::shared_ptr<BlockingQueue> m_inQueue;
97  boost::shared_ptr<BlockingQueue> m_outQueue;
98 
99  bool m_done;
100 };
101 #endif // ConvertStage_HPP
AbstractStage::firstStep
virtual void firstStep()=0
AbstractStage::done
bool done() const
Definition: AbstractStage.hpp:91
AbstractStage::lastStep
virtual void lastStep()=0
AbstractStage::Run
void Run()
Definition: AbstractStage.hpp:69
AbstractStage::step
virtual void step()=0
AbstractStage
Definition: AbstractStage.hpp:49
BlockingQueue.hpp
AbstractStage::m_outQueue
boost::shared_ptr< BlockingQueue > m_outQueue
Definition: AbstractStage.hpp:97
AbstractStage::done
void done(bool val)
Definition: AbstractStage.hpp:92
AbstractStage::m_inQueue
boost::shared_ptr< BlockingQueue > m_inQueue
Definition: AbstractStage.hpp:96
AbstractStage::InitQueues
void InitQueues(boost::shared_ptr< BlockingQueue > inQueue, boost::shared_ptr< BlockingQueue > outQueue)
Definition: AbstractStage.hpp:59
AbstractStage::AbstractStage
AbstractStage()
Definition: AbstractStage.hpp:54
AbstractStage::getOutQueue
boost::shared_ptr< BlockingQueue > getOutQueue() const
Definition: AbstractStage.hpp:89
AbstractStage::getInQueue
boost::shared_ptr< BlockingQueue > getInQueue() const
Definition: AbstractStage.hpp:88
AbstractStage::m_done
bool m_done
Definition: AbstractStage.hpp:99


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:22