Equalizer  1.11.0
Parallel Rendering Framework
fabric/config.h
1 
2 /* Copyright (c) 2005-2015, Stefan Eilemann <eile@equalizergraphics.com>
3  * Cedric Stalder <cedric Stalder@gmail.com>
4  * Daniel Nachbaur <danielnachbaur@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQFABRIC_CONFIG_H
21 #define EQFABRIC_CONFIG_H
22 
23 #include <eq/fabric/api.h>
24 #include <eq/fabric/types.h> // typedefs
25 #include <eq/fabric/object.h> // DIRTY_CUSTOM enum
26 
27 namespace eq
28 {
29 namespace fabric
30 {
32 template< class S, class C, class O, class L, class CV, class N, class V >
33 // cppcheck-suppress noConstructor
34 class Config : public Object
35 {
36 public:
37  typedef std::vector< O* > Observers;
38  typedef std::vector< L* > Layouts;
39  typedef std::vector< CV* > Canvases;
40  typedef std::vector< N* > Nodes;
41 
45  EQFABRIC_INL lunchbox::RefPtr< S > getServer();
46 
48  EQFABRIC_INL lunchbox::RefPtr< const S > getServer() const;
49 
51  const Observers& getObservers() const { return _observers; }
52 
54  const Layouts& getLayouts() const { return _layouts; }
55 
57  const Canvases& getCanvases() const { return _canvases; }
58 
63  EQFABRIC_INL uint32_t getTimeout() const;
64 
69  const Nodes& getNodes() const { return _nodes; }
70 
71  EQFABRIC_INL N* findAppNode();
72  EQFABRIC_INL const N* findAppNode() const;
73 
81  EQFABRIC_INL VisitorResult accept( V& visitor );
82 
84  EQFABRIC_INL VisitorResult accept( V& visitor ) const;
85 
87  template< typename T > EQFABRIC_INL T* find( const uint128_t& id );
88 
90  template< typename T >
91  EQFABRIC_INL const T* find( const uint128_t& id ) const;
92 
94  template< typename T >
95  EQFABRIC_INL T* find( const std::string& name );
96 
98  template< typename T >
99  EQFABRIC_INL const T* find( const std::string& name ) const;
100 
102  O* getObserver( const ObserverPath& path );
103 
105  L* getLayout( const LayoutPath& path );
106 
108  CV* getCanvas( const CanvasPath& path );
109 
111  template< typename T > void find( const uint128_t& id, T** result );
112 
114  template< typename T > void find( const std::string& name,
115  const T** result ) const;
116 
118  virtual void updateCanvas( CV* ) { /* NOP */ }
119 
121  virtual void exitCanvas( CV* ) { /* NOP */ }
123 
126  // Note: also update string array initialization in config.ipp
127 
130  {
133  FATTR_LAST,
134  FATTR_ALL = FATTR_LAST + 5
135  };
136 
139  {
141  IATTR_LAST,
142  IATTR_ALL = IATTR_LAST + 5
143  };
144 
146  void setFAttribute( const FAttribute attr, const float value )
147  { _fAttributes[attr] = value; }
149  void setIAttribute( const IAttribute attr, const int32_t value )
150  { _iAttributes[attr] = value; }
151 
153  float getFAttribute( const FAttribute attr ) const
154  { return _fAttributes[attr]; }
155 
157  int32_t getIAttribute( const IAttribute attr ) const
158  { return _iAttributes[attr]; }
159 
161  static const std::string& getFAttributeString( const FAttribute attr );
163  static const std::string& getIAttributeString( const IAttribute attr );
165 
166 
180  virtual void setLatency( const uint32_t latency );
181 
183  uint32_t getLatency() const { return _data.latency; }
184 
186  EQFABRIC_INL virtual void restore();
188 
189  virtual void output( std::ostream& ) const {}
190  void create( O** observer );
191  void release( O* observer );
192  void create( L** layout );
193  void release( L* layout );
194  void create( CV** canvas );
195  void release( CV* canvas );
196  void create( N** node );
197  void release( N* node );
198 
199 protected:
201  EQFABRIC_INL explicit Config( lunchbox::RefPtr< S > parent );
202 
204  EQFABRIC_INL virtual ~Config();
205 
207  EQFABRIC_INL virtual void attach( const uint128_t& id,
208  const uint32_t instanceID );
209 
211  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
212  const uint64_t dirtyBits );
213  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
214  const uint64_t dirtyBits );
215  EQFABRIC_INL virtual void notifyDetach();
216 
218  virtual void _removeChild( const uint128_t& )
219  { LBUNIMPLEMENTED; }
220 
221  template< class, class, class, class, class, class >
222  friend class Server;
223 
224  void setAppNodeID( const co::NodeID& nodeID );
225 
226  const co::NodeID& getAppNodeID() const { return _appNodeID; }
227 
229  EQFABRIC_INL EventOCommand sendError( co::NodePtr node,
230  const uint32_t event,
231  const Error& error );
232 
233  virtual void changeLatency( const uint32_t ) { /* NOP */ }
234  virtual bool mapViewObjects() const { return false; }
235  virtual bool mapNodeObjects() const { return false; }
236 
238  virtual VisitorResult _acceptCompounds( V& )
239  { return TRAVERSE_CONTINUE; }
241  virtual VisitorResult _acceptCompounds( V& ) const
242  { return TRAVERSE_CONTINUE; }
243  template< class C2, class V2 >
244  friend VisitorResult _acceptImpl( C2*, V2& );
245 
246  N* _findNode( const uint128_t& id );
247 
249  EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
250  CO_COMMIT_NEXT );
252 
253 private:
255  lunchbox::RefPtr< S > _server;
256 
258  float _fAttributes[FATTR_ALL];
259 
261  int32_t _iAttributes[IATTR_ALL];
262 
264  Observers _observers;
265 
267  Layouts _layouts;
268 
270  Canvases _canvases;
271 
273  Nodes _nodes;
274 
276  co::NodeID _appNodeID;
277 
278  struct BackupData
279  {
280  BackupData() : latency( 1 ) {}
281 
283  uint32_t latency;
284  }
285  _data, _backup;
286 
287  struct Private;
288  Private* _private; // placeholder for binary-compatible changes
289 
290  enum DirtyBits
291  {
292  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 0,
293  DIRTY_LATENCY = Object::DIRTY_CUSTOM << 1,
294  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 2,
295  DIRTY_NODES = Object::DIRTY_CUSTOM << 3,
296  DIRTY_OBSERVERS = Object::DIRTY_CUSTOM << 4,
297  DIRTY_LAYOUTS = Object::DIRTY_CUSTOM << 5,
298  DIRTY_CANVASES = Object::DIRTY_CUSTOM << 6,
299  DIRTY_CONFIG_BITS =
300  DIRTY_MEMBER | DIRTY_ATTRIBUTES | DIRTY_OBSERVERS |
301  DIRTY_LAYOUTS | DIRTY_CANVASES | DIRTY_NODES | DIRTY_LATENCY
302  };
303 
305  virtual uint64_t getRedistributableBits() const
306  { return DIRTY_CONFIG_BITS; }
307 
308  template< class, class > friend class Observer;
309  void _addObserver( O* observer );
310  bool _removeObserver( O* observer );
311 
312  template< class, class, class > friend class Layout;
313  void _addLayout( L* layout );
314  bool _removeLayout( L* layout );
315 
316  template< class, class, class, class > friend class Canvas;
317  void _addCanvas( CV* canvas );
318  bool _removeCanvas( CV* canvas );
319 
320  template< class, class, class, class > friend class Node;
321  void _addNode( N* node );
322  EQFABRIC_INL bool _removeNode( N* node );
323 
324  typedef co::CommandFunc< Config< S, C, O, L, CV, N, V > > CmdFunc;
325  bool _cmdNewLayout( co::ICommand& command );
326  bool _cmdNewCanvas( co::ICommand& command );
327  bool _cmdNewObserver( co::ICommand& command );
328  bool _cmdNewEntityReply( co::ICommand& command );
329 };
330 
331 template< class S, class C, class O, class L, class CV, class N, class V >
332 EQFABRIC_INL std::ostream& operator << ( std::ostream& os,
333  const Config< S, C, O, L, CV, N, V >& config );
334 }
335 }
336 #endif // EQFABRIC_CONFIG_H
std::vector< L * > Layouts
A vector of layouts.
Definition: fabric/config.h:38
const Observers & getObservers() const
Definition: fabric/config.h:51
IAttribute
Possible values for integer attributes.
Definition: iAttribute.h:30
A configuration is a visualization session driven by an application.
Definition: config.h:55
EQFABRIC_INL VisitorResult accept(V &visitor)
Perform a depth-first traversal of this config.
Defines export visibility macros for library EqualizerFabric.
std::vector< CV * > Canvases
A vector of canvases.
Definition: fabric/config.h:39
const Nodes & getNodes() const
Definition: fabric/config.h:69
EQFABRIC_INL T * find(const uint128_t &id)
float getFAttribute(const FAttribute attr) const
std::vector< N * > Nodes
A vector of nodes.
Definition: fabric/config.h:40
const Layouts & getLayouts() const
Definition: fabric/config.h:54
const Canvases & getCanvases() const
Definition: fabric/config.h:57
int32_t getIAttribute(const IAttribute attr) const
The Equalizer client library.
Definition: eq/agl/types.h:23
The default interocular distance in meters.
The version of the file loaded.
EQFABRIC_INL lunchbox::RefPtr< S > getServer()
Base data class for a configuration.
Definition: fabric/config.h:34
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:41
std::vector< O * > Observers
A vector of observers.
Definition: fabric/config.h:37
virtual void setLatency(const uint32_t latency)
Set the maximum accepted latency for this config.
uint32_t getLatency() const
Tolerate resource failures.