Equalizer  1.11.0
Parallel Rendering Framework
fabric/pipe.h
1 
2 /* Copyright (c) 2010-2015, Stefan Eilemann <eile@equalizergraphics.com>
3  * Cedric Stalder <cedric.stalder@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQFABRIC_PIPE_H
20 #define EQFABRIC_PIPE_H
21 
22 #include <eq/fabric/object.h> // base class
23 #include <eq/fabric/pixelViewport.h> // property
24 #include <eq/fabric/types.h>
25 
26 namespace eq
27 {
28 namespace fabric
29 {
31 template< class N, class P, class W, class V > class Pipe : public Object
32 {
33 public:
35  typedef std::vector< W* > Windows;
36 
40  N* getNode() { return _node; }
42  const N* getNode() const { return _node; }
43 
45  const Windows& getWindows() const { return _windows; }
46 
57  uint32_t getPort() const { return _port; }
58 
59  EQFABRIC_INL void setPort( const uint32_t port );
60 
72  uint32_t getDevice() const { return _device; }
73 
74  EQFABRIC_INL void setDevice( const uint32_t device );
75 
77  const PixelViewport& getPixelViewport() const { return _data.pvp; }
78 
88  EQFABRIC_INL void setPixelViewport( const PixelViewport& pvp );
89 
91  void notifyPixelViewportChanged();
92 
94  EQFABRIC_INL PipePath getPath() const;
95 
103  EQFABRIC_INL VisitorResult accept( V& visitor );
104 
106  EQFABRIC_INL VisitorResult accept( V& visitor ) const;
108 
113  {
114  // Note: also update string array initialization in pipe.cpp
118  IATTR_LAST,
119  IATTR_ALL = IATTR_LAST + 5
120  };
121 
123  EQFABRIC_INL void setIAttribute( const IAttribute attr,
124  const int32_t value );
125 
127  int32_t getIAttribute( const IAttribute attr ) const
128  { return _iAttributes[attr]; }
129 
131  bool isThreaded() const
132  { return (getIAttribute( IATTR_HINT_THREAD ) == 1 ); }
133 
135  EQFABRIC_INL static const std::string& getIAttributeString(
136  const IAttribute attr );
138 
141  EQFABRIC_INL virtual void backup();
142  EQFABRIC_INL virtual void restore();
143  void create( W** window );
144  void release( W* window );
145  virtual void output( std::ostream& ) const {}
146 
147  EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
148  CO_COMMIT_NEXT );
150 
151 protected:
153  explicit Pipe( N* parent );
154  EQFABRIC_INL virtual ~Pipe( );
155 
156  virtual void attach( const uint128_t& id,
157  const uint32_t instanceID );
158 
159  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
160  const uint64_t dirtyBits );
162  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
163  const uint64_t dirtyBits );
164 
165  EQFABRIC_INL virtual void notifyDetach();
166 
168  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
169 
171  virtual ChangeType getChangeType() const { return UNBUFFERED; }
172 
173  W* _findWindow( const uint128_t& id );
174 
175  enum DirtyBits
176  {
177  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0,
178  DIRTY_WINDOWS = Object::DIRTY_CUSTOM << 1,
179  DIRTY_PIXELVIEWPORT = Object::DIRTY_CUSTOM << 2,
180  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 3,
181  DIRTY_PIPE_BITS =
182  DIRTY_ATTRIBUTES | DIRTY_WINDOWS | DIRTY_PIXELVIEWPORT |
183  DIRTY_MEMBER | DIRTY_OBJECT_BITS
184  };
185 
187  virtual uint64_t getRedistributableBits() const
188  { return DIRTY_PIPE_BITS; }
189 
190 private:
192  N* const _node;
193 
195  Windows _windows;
196 
198  int32_t _iAttributes[IATTR_ALL];
199 
201  uint32_t _port;
202 
204  uint32_t _device;
205 
206  struct BackupData
207  {
209  PixelViewport pvp;
210  }
211  _data, _backup;
212 
213  struct Private;
214  Private* _private; // placeholder for binary-compatible changes
215 
216  void _addWindow( W* window );
217  EQFABRIC_INL bool _removeWindow( W* window );
218  template< class, class, class, class > friend class Window;
219 
221  bool _mapNodeObjects() { return _node->_mapNodeObjects(); }
222 
223  typedef co::CommandFunc< Pipe< N, P, W, V > > CmdFunc;
224  bool _cmdNewWindow( co::ICommand& command );
225  bool _cmdNewWindowReply( co::ICommand& command );
226 };
227 
228 template< class N, class P, class W, class V > EQFABRIC_INL
229 std::ostream& operator << ( std::ostream&, const Pipe< N, P, W, V >& );
230 }
231 }
232 
233 #endif // EQFABRIC_PIPE_H
IAttribute
Possible values for integer attributes.
Definition: iAttribute.h:30
std::vector< W * > Windows
A vector of pointers to windows.
Definition: fabric/pipe.h:35
uint32_t getDevice() const
Returns the device number of this pipe.
Definition: fabric/pipe.h:72
const N * getNode() const
Definition: fabric/pipe.h:42
Bind render thread to subset of cores.
Definition: fabric/pipe.h:116
uint32_t getPort() const
Returns the port number of this pipe.
Definition: fabric/pipe.h:57
Base data transport class for pipes.
Definition: fabric/pipe.h:31
const PixelViewport & getPixelViewport() const
Definition: fabric/pipe.h:77
Execute tasks in separate thread (default)
Definition: fabric/pipe.h:115
The Equalizer client library.
Definition: eq/agl/types.h:23
EQFABRIC_INL void setPixelViewport(const PixelViewport &pvp)
Set the pipe's pixel viewport.
EQFABRIC_INL VisitorResult accept(V &visitor)
Perform a depth-first traversal of this pipe.
const Windows & getWindows() const
Definition: fabric/pipe.h:45
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:41
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
int32_t getIAttribute(const IAttribute attr) const
Definition: fabric/pipe.h:127