Equalizer  1.10.1
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fabric/layout.h
1 
2 /* Copyright (c) 2009-2015, 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/types.h>
23 #include <string>
24 
25 namespace eq
26 {
27 namespace fabric
28 {
30 // cppcheck-suppress noConstructor
31 template< class C, class L, class V > class Layout : public Object
32 {
33 public:
37  typedef std::vector< V* > Views;
40 
42  C* getConfig() { return _config; }
43 
45  const C* getConfig() const { return _config; }
46 
48  const Views& getViews() const { return _views; }
49 
54  EQFABRIC_INL bool isActive() const;
55 
57  V* getView( const ViewPath& path );
58 
60  V* findView( const std::string& name );
61 
63  LayoutPath getPath() const;
65 
75  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
76 
78  EQFABRIC_INL VisitorResult accept( Visitor& visitor )
79  const;
80 
81  void create( V** view );
82  void release( V* view );
83 
84 
85 protected:
87  EQFABRIC_INL explicit Layout( C* config );
88 
90  EQFABRIC_INL virtual ~Layout();
91 
93  EQFABRIC_INL virtual void attach( const uint128_t& id,
94  const uint32_t instanceID );
95 
97  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
98  const uint64_t dirtyBits );
100  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
101  const uint64_t dirtyBits );
102 
103  EQFABRIC_INL virtual void notifyDetach();
104 
106  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
107 
109  enum DirtyBits
110  {
111  DIRTY_VIEWS = Object::DIRTY_CUSTOM << 0,
112  DIRTY_LAYOUT_BITS = DIRTY_VIEWS | DIRTY_OBJECT_BITS
113  };
114 
116  virtual uint64_t getRedistributableBits() const
117  { return DIRTY_LAYOUT_BITS; }
118 
119 private:
121  C* const _config;
122 
124  Views _views;
125 
126  struct Private;
127  Private* _private; // placeholder for binary-compatible changes
128 
129  template< class, class, class > friend class View;
130  friend class Object;
131  void _addChild( V* view );
132  bool _removeChild( V* view );
133 
135  EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation );
136 
137  template< class O > void _removeObserver( const O* observer );
138  template< class, class, class, class, class, class,
139  class > friend class Config;
140 
141  typedef co::CommandFunc< Layout< C, L, V > > CmdFunc;
142  bool _cmdNewView( co::ICommand& command );
143  bool _cmdNewViewReply( co::ICommand& command );
144 };
145 
146 template< class C, class L, class V >
147 std::ostream& operator << ( std::ostream&, const Layout< C, L, V >& );
148 }
149 }
150 #endif // EQFABRIC_LAYOUT_H
const C * getConfig() const
Definition: fabric/layout.h:45
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Traverse this layout and all children using a layout visitor.
A visitor to traverse non-leaf elements and their children in a tree.
std::vector< V * > Views
A vector of pointers to views.
Definition: fabric/layout.h:37
Base data transport class for layouts.
Definition: fabric/layout.h:31
EQFABRIC_INL bool isActive() const
ElementVisitor< L, LeafVisitor< V > > Visitor
The layout visitor type.
Definition: fabric/layout.h:39
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:41
EQFABRIC_API Object()
Construct a new Object.
const Views & getViews() const
Get the list of views.
Definition: fabric/layout.h:48