Carna  Version 3.3.2
RenderStageSequence.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 - 2015 Leonid Kostrykin
3  *
4  * Chair of Medical Engineering (mediTEC)
5  * RWTH Aachen University
6  * Pauwelsstr. 20
7  * 52074 Aachen
8  * Germany
9  *
10  */
11 
12 #ifndef RENDERSTAGESEQUENCE_H_0874895466
13 #define RENDERSTAGESEQUENCE_H_0874895466
14 
15 #include <Carna/Carna.h>
16 #include <Carna/base/Aggregation.h>
17 #include <Carna/base/noncopyable.h>
18 #include <memory>
19 
24 namespace Carna
25 {
26 
27 namespace base
28 {
29 
30 
31 
32 // ----------------------------------------------------------------------------------
33 // RenderStageSequence
34 // ----------------------------------------------------------------------------------
35 
42 class CARNA_LIB RenderStageSequence
43 {
44 
46 
47  struct Details;
48  const std::unique_ptr< Details > pimpl;
49 
50 public:
51 
56 
60  virtual ~RenderStageSequence();
61 
65  std::size_t stages() const;
66 
70  void appendStage( RenderStage* stage );
71 
75  virtual void clearStages();
76 
80  RenderStage& stageAt( std::size_t position ) const;
81 
87  template< typename RenderStage >
88  Aggregation< RenderStage > findStage() const;
89 
90 protected:
91 
96  void releaseStages();
97 
98 }; // RenderStageSequence
99 
100 
101 template< typename RenderStage >
103 {
104  for( std::size_t index = 0; index < stages(); ++index )
105  {
106  RenderStage* const rs = dynamic_cast< RenderStage* >( &stageAt( index ) );
107  if( rs != nullptr )
108  {
109  return Aggregation< RenderStage >( *rs );
110  }
111  }
113 }
114 
115 
116 
117 } // namespace Carna :: base
118 
119 } // namespace Carna
120 
121 #endif // RENDERSTAGESEQUENCE_H_0874895466
Represents an aggregation, i.e. a weak reference.
Definition: Aggregation.h:40
Aggregation< RenderStage > findStage() const
References the first RenderStage within the rendering stages sequence. This method performs a linear ...
Defines Carna::base::Aggregation.
Base abstract class of each rendering stage. Refer to the documentation of the rendering process...
Definition: RenderStage.h:42
#define NON_COPYABLE
Features class it is placed in as non-copyable.
Definition: noncopyable.h:109
Represents a rendering stages sequence.