Equalizer  1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fabric/segment.h
1 
2 /* Copyright (c) 2010-2013, Stefan Eilemann <eile@eyescale.ch>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef EQFABRIC_SEGMENT_H
19 #define EQFABRIC_SEGMENT_H
20 
21 #include <eq/fabric/types.h>
22 #include <eq/fabric/frustum.h> // base class
23 #include <eq/fabric/object.h> // base class
24 #include <eq/fabric/swapBarrier.h> // RefPtr member
25 #include <eq/fabric/viewport.h> // member
26 
27 namespace eq
28 {
29 namespace fabric
30 {
32  template< class C, class S, class CH >
33  class Segment : public Object, public Frustum
34  {
35  public:
38 
42  const C* getCanvas() const { return _canvas; }
43 
45  C* getCanvas() { return _canvas; }
46 
48  const Viewport& getViewport() const { return _vp; }
49 
60  EQFABRIC_INL void setViewport( const Viewport& vp );
61 
71  void setChannel( CH* channel )
72  { _channel = channel; setDirty( DIRTY_CHANNEL ); }
73 
75  CH* getChannel() { return _channel; }
76 
78  const CH* getChannel() const { return _channel; }
79 
81  EQFABRIC_INL virtual void setWall( const Wall& wall );
82 
84  EQFABRIC_INL virtual void setProjection( const Projection& );
85 
87  EQFABRIC_INL virtual void unsetFrustum();
88 
90  uint32_t getEyes() const { return _eyes; }
91 
100  EQFABRIC_INL void setEyes( const uint32_t eyes );
101 
110  void enableEye( const uint32_t eyes ) { _eyes |= eyes; }
111 
120  EQFABRIC_INL void setSwapBarrier( SwapBarrierPtr barrier );
121 
123  SwapBarrierConstPtr getSwapBarrier() const { return _swapBarrier; }
124 
126  SwapBarrierPtr getSwapBarrier() { return _swapBarrier; }
128 
138  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
139 
141  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
142 
144  void inheritFrustum();
145 
146  virtual void backup();
147  virtual void restore();
148 
150  virtual uint128_t commit( const uint32_t incarnation=CO_COMMIT_NEXT );
152 
153  protected:
155  EQFABRIC_INL Segment( C* canvas );
156 
158  EQFABRIC_INL virtual ~Segment();
159 
161  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
162  const uint64_t dirtyBits );
164  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
165  const uint64_t dirtyBits );
166  virtual void setDirty( const uint64_t bits );
167 
169  enum DirtyBits
170  {
171  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 0,
172  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 1,
173  DIRTY_CHANNEL = Object::DIRTY_CUSTOM << 2,
174  DIRTY_EYES = Object::DIRTY_CUSTOM << 3,
175  DIRTY_SEGMENT_BITS = DIRTY_VIEWPORT | DIRTY_FRUSTUM |
176  DIRTY_CHANNEL | DIRTY_EYES | DIRTY_OBJECT_BITS
177  };
178 
180  virtual uint64_t getRedistributableBits() const
181  { return DIRTY_SEGMENT_BITS; }
182 
184  virtual void notifyFrustumChanged() { setDirty( DIRTY_FRUSTUM ); }
185 
186  private:
188  C* const _canvas;
189 
191  Viewport _vp;
192 
194  CH* _channel;
195 
196  uint32_t _eyes;
197 
198  SwapBarrierPtr _swapBarrier;
199 
200  struct Private;
201  Private* _private; // placeholder for binary-compatible changes
202  };
203 
204  template< class C, class S, class CH >
205  std::ostream& operator << ( std::ostream&, const Segment< C, S, CH >& );
206 }
207 }
208 #endif // EQFABRIC_SEGMENT_H
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
const Viewport & getViewport() const
uint32_t getEyes() const
A wall defining a view frustum.
Definition: wall.h:36
A visitor to traverse leaf nodes of a graph.
Definition: admin/types.h:32
A projector definition defining a view frustum.
Definition: projection.h:38
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Traverse this segment using a segment visitor.
const C * getCanvas() const
LeafVisitor< S > Visitor
The segment visitor type.
CH * getChannel()
Return the output channel of this segment.
Base data transport class for segments.
const CH * getChannel() const
Return the output channel of this segment.
lunchbox::VisitorResult VisitorResult
The result code from any visit operation.
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:41
A distributed object for frustum data.
Definition: frustum.h:30