Equalizer  2.1.0
Parallel Rendering Framework
fabric/layout.h
1 
2 /* Copyright (c) 2009-2016, Stefan Eilemann <eile@equalizergraphics.com>
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_LAYOUT_H
19 #define EQFABRIC_LAYOUT_H
20 
21 #include <eq/fabric/object.h> // base class
22 #include <eq/fabric/pixelViewport.h> // member
23 #include <eq/fabric/types.h>
24 #include <string>
25 
26 namespace eq
27 {
28 namespace fabric
29 {
31 // cppcheck-suppress noConstructor
32 template <class C, class L, class V>
33 class Layout : public Object
34 {
35 public:
39  typedef std::vector<V*> Views;
42 
44  C* getConfig() { return _config; }
46  const C* getConfig() const { return _config; }
48  const Views& getViews() const { return _views; }
53  EQFABRIC_INL bool isActive() const;
54 
56  V* getView(const ViewPath& path);
57 
59  V* findView(const std::string& name);
60 
62  LayoutPath getPath() const;
64 
74  EQFABRIC_INL VisitorResult accept(Visitor& visitor);
75 
77  EQFABRIC_INL VisitorResult accept(Visitor& visitor) const;
78 
92  EQFABRIC_INL void setPixelViewport(const PixelViewport& pvp);
93 
95  EQFABRIC_INL const PixelViewport& getPixelViewport() const;
96 
97  void create(V** view);
98  void release(V* view);
99 
100 
101 protected:
103  EQFABRIC_INL explicit Layout(C* config);
104 
106  EQFABRIC_INL virtual ~Layout();
107 
109  EQFABRIC_INL virtual void attach(const uint128_t& id,
110  const uint32_t instanceID);
111 
113  EQFABRIC_INL virtual void serialize(co::DataOStream& os,
114  const uint64_t dirtyBits);
116  EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
117  const uint64_t dirtyBits);
118 
119  EQFABRIC_INL virtual void notifyDetach();
120  virtual void notifyViewportChanged() {}
121 
122  EQFABRIC_INL virtual void setDirty(const uint64_t bits);
123 
125  enum DirtyBits
126  {
127  DIRTY_VIEWS = Object::DIRTY_CUSTOM << 0,
128  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 1,
129  DIRTY_LAYOUT_BITS = DIRTY_VIEWS | DIRTY_VIEWPORT | DIRTY_OBJECT_BITS
130  };
131 
133  virtual uint64_t getRedistributableBits() const
134  {
135  return DIRTY_LAYOUT_BITS;
136  }
137 
138 private:
140  C* const _config;
141 
143  Views _views;
144 
145  PixelViewport _pvp;
146 
147  template <class, class, class>
148  friend class View;
149  friend class Object;
150  void _addChild(V* view);
151  bool _removeChild(V* view);
152 
154  EQFABRIC_INL virtual uint128_t commit(const uint32_t incarnation);
155 
156  template <class O>
157  void _removeObserver(const O* observer);
158  template <class, class, class, class, class, class, class>
159  friend class Config;
160 
161  typedef co::CommandFunc<Layout<C, L, V>> CmdFunc;
162  bool _cmdNewView(co::ICommand& command);
163  bool _cmdNewViewReply(co::ICommand& command);
164 };
165 
166 template <class C, class L, class V>
167 std::ostream& operator<<(std::ostream&, const Layout<C, L, V>&);
168 }
169 }
170 #endif // EQFABRIC_LAYOUT_H
ElementVisitor< L, LeafVisitor< V > > Visitor
The layout visitor type.
Definition: fabric/layout.h:41
const C * getConfig() const
Definition: fabric/layout.h:46
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Traverse this layout and all children using a layout visitor.
EQFABRIC_INL const PixelViewport & getPixelViewport() const
std::vector< V * > Views
A vector of pointers to views.
Definition: fabric/layout.h:39
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
A visitor to traverse non-leaf elements and their children in a tree.
Base data transport class for views.
EQFABRIC_INL void setPixelViewport(const PixelViewport &pvp)
Resize the underlying channels to form a layout of the given size.
The Equalizer client library.
Definition: eq/agl/types.h:23
Base data transport class for layouts.
Definition: fabric/layout.h:33
Base data class for a configuration.
Definition: fabric/config.h:34
EQFABRIC_INL bool isActive() const
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
const Views & getViews() const
Get the list of views.
Definition: fabric/layout.h:48