Equalizer  2.1.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>
32 class Pipe : public Object
33 {
34 public:
36  typedef std::vector<W*> Windows;
37 
41  N* getNode() { return _node; }
43  const N* getNode() const { return _node; }
45  const Windows& getWindows() const { return _windows; }
56  uint32_t getPort() const { return _port; }
57  EQFABRIC_INL void setPort(const uint32_t port);
58 
70  uint32_t getDevice() const { return _device; }
71  EQFABRIC_INL void setDevice(const uint32_t device);
72 
74  const PixelViewport& getPixelViewport() const { return _data.pvp; }
84  EQFABRIC_INL void setPixelViewport(const PixelViewport& pvp);
85 
87  void notifyPixelViewportChanged();
88 
90  EQFABRIC_INL PipePath getPath() const;
91 
99  EQFABRIC_INL VisitorResult accept(V& visitor);
100 
102  EQFABRIC_INL VisitorResult accept(V& visitor) const;
104 
109  {
110  // Note: also update string array initialization in pipe.cpp
113  IATTR_LAST,
114  IATTR_ALL = IATTR_LAST + 5
115  };
116 
118  EQFABRIC_INL void setIAttribute(const IAttribute attr, const int32_t value);
119 
121  int32_t getIAttribute(const IAttribute attr) const
122  {
123  return _iAttributes[attr];
124  }
125 
127  bool isThreaded() const { return (getIAttribute(IATTR_HINT_THREAD) == 1); }
129  EQFABRIC_INL static const std::string& getIAttributeString(
130  const IAttribute attr);
132 
135  EQFABRIC_INL virtual void backup();
136  EQFABRIC_INL virtual void restore();
137  void create(W** window);
138  void release(W* window);
139  virtual void output(std::ostream&) const {}
140 
141  EQFABRIC_INL virtual uint128_t commit(
142  const uint32_t incarnation = CO_COMMIT_NEXT);
144 
145 protected:
147  explicit Pipe(N* parent);
148  EQFABRIC_INL virtual ~Pipe();
149 
150  virtual void attach(const uint128_t& id,
151  const uint32_t instanceID);
152 
153  EQFABRIC_INL virtual void serialize(co::DataOStream& os,
154  const uint64_t dirtyBits);
156  EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
157  const uint64_t dirtyBits);
158 
159  EQFABRIC_INL virtual void notifyDetach();
160 
162  EQFABRIC_INL virtual void setDirty(const uint64_t bits);
163 
165  virtual ChangeType getChangeType() const { return UNBUFFERED; }
166  W* _findWindow(const uint128_t& id);
167 
168  enum DirtyBits
169  {
170  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0,
171  DIRTY_WINDOWS = Object::DIRTY_CUSTOM << 1,
172  DIRTY_PIXELVIEWPORT = Object::DIRTY_CUSTOM << 2,
173  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 3,
174  DIRTY_PIPE_BITS = DIRTY_ATTRIBUTES | DIRTY_WINDOWS |
175  DIRTY_PIXELVIEWPORT | DIRTY_MEMBER | DIRTY_OBJECT_BITS
176  };
177 
179  virtual uint64_t getRedistributableBits() const { return DIRTY_PIPE_BITS; }
180 private:
182  N* const _node;
183 
185  Windows _windows;
186 
188  int32_t _iAttributes[IATTR_ALL];
189 
191  uint32_t _port;
192 
194  uint32_t _device;
195 
196  struct BackupData
197  {
199  PixelViewport pvp;
200  } _data, _backup;
201 
202  struct Private;
203  Private* _private; // placeholder for binary-compatible changes
204 
205  void _addWindow(W* window);
206  EQFABRIC_INL bool _removeWindow(W* window);
207  template <class, class, class, class>
208  friend class Window;
209 
211  bool _mapNodeObjects() { return _node->_mapNodeObjects(); }
212  typedef co::CommandFunc<Pipe<N, P, W, V>> CmdFunc;
213  bool _cmdNewWindow(co::ICommand& command);
214  bool _cmdNewWindowReply(co::ICommand& command);
215 };
216 
217 template <class N, class P, class W, class V>
218 EQFABRIC_INL std::ostream& operator<<(std::ostream&, const Pipe<N, P, W, V>&);
219 }
220 }
221 
222 #endif // EQFABRIC_PIPE_H
uint32_t getDevice() const
Returns the device number of this pipe.
Definition: fabric/pipe.h:70
const N * getNode() const
Definition: fabric/pipe.h:43
Bind render thread to subset of cores.
Definition: fabric/pipe.h:112
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
uint32_t getPort() const
Returns the port number of this pipe.
Definition: fabric/pipe.h:56
Base data transport class for pipes.
Definition: fabric/pipe.h:32
std::vector< W * > Windows
A vector of pointers to windows.
Definition: fabric/pipe.h:36
const PixelViewport & getPixelViewport() const
Definition: fabric/pipe.h:74
Execute tasks in separate thread (default)
Definition: fabric/pipe.h:111
The Equalizer client library.
Definition: eq/agl/types.h:23
EQFABRIC_INL void setPixelViewport(const PixelViewport &pvp)
Set the pipe&#39;s pixel viewport.
Base data transport class for windows.
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:44
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
int32_t getIAttribute(const IAttribute attr) const
Definition: fabric/pipe.h:121