Line data Source code
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 : {
29 : /** Base data transport class for layouts. @sa eq::Layout */
30 : // cppcheck-suppress noConstructor
31 : template< class C, class L, class V > class Layout : public Object
32 : {
33 : public:
34 : /** @name Data Access */
35 : //@{
36 : /** A vector of pointers to views. @version 1.0 */
37 : typedef std::vector< V* > Views;
38 : /** The layout visitor type. @version 1.0 */
39 : typedef ElementVisitor< L, LeafVisitor< V > > Visitor;
40 :
41 : /** @return the current config. @version 1.0 */
42 2428 : C* getConfig() { return _config; }
43 :
44 : /** @return the current config. @version 1.0 */
45 350 : const C* getConfig() const { return _config; }
46 :
47 : /** Get the list of views. @version 1.0 */
48 18391 : const Views& getViews() const { return _views; }
49 :
50 : /**
51 : * @return true if the layout is activated in at least one canvas.
52 : * @version 1.1.5
53 : */
54 : EQFABRIC_INL bool isActive() const;
55 :
56 : /** @internal @return the view of the given path. */
57 : V* getView( const ViewPath& path );
58 :
59 : /** @internal @return the first view of the given name. */
60 : V* findView( const std::string& name );
61 :
62 : /** @internal @return the index path to this layout. */
63 : LayoutPath getPath() const;
64 : //@}
65 :
66 : /** @name Operations */
67 : //@{
68 : /**
69 : * Traverse this layout and all children using a layout visitor.
70 : *
71 : * @param visitor the visitor.
72 : * @return the result of the visitor traversal.
73 : * @version 1.0
74 : */
75 : EQFABRIC_INL VisitorResult accept( Visitor& visitor );
76 :
77 : /** Const-version of accept(). @version 1.0 */
78 : EQFABRIC_INL VisitorResult accept( Visitor& visitor )
79 : const;
80 :
81 : void create( V** view ); //!< @internal
82 : void release( V* view ); //!< @internal
83 : //@}
84 :
85 : protected:
86 : /** @internal Construct a new layout. */
87 : EQFABRIC_INL explicit Layout( C* config );
88 :
89 : /** @internal Destruct this layout. */
90 : EQFABRIC_INL virtual ~Layout();
91 :
92 : /** @internal */
93 : EQFABRIC_INL virtual void attach( const uint128_t& id,
94 : const uint32_t instanceID );
95 :
96 : /** @internal */
97 : EQFABRIC_INL virtual void serialize( co::DataOStream& os,
98 : const uint64_t dirtyBits );
99 : /** @internal */
100 : EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
101 : const uint64_t dirtyBits );
102 :
103 : EQFABRIC_INL virtual void notifyDetach(); //!< @internal
104 :
105 : /** @internal */
106 : EQFABRIC_INL virtual void setDirty( const uint64_t bits );
107 :
108 : /** @internal */
109 : enum DirtyBits
110 : {
111 : DIRTY_VIEWS = Object::DIRTY_CUSTOM << 0,
112 : DIRTY_LAYOUT_BITS = DIRTY_VIEWS | DIRTY_OBJECT_BITS
113 : };
114 :
115 : /** @internal @return the bits to be re-committed by the master. */
116 0 : virtual uint64_t getRedistributableBits() const
117 0 : { return DIRTY_LAYOUT_BITS; }
118 :
119 : private:
120 : /** The parent Config. */
121 : C* const _config;
122 :
123 : /** Child views on this layout. */
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 :
134 : /** @internal */
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
|