Equalizer  1.9.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fabric/config.h
1 
2 /* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric Stalder@gmail.com>
4  * 2011, 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  class Config : public Object
34  {
35  public:
36  typedef std::vector< O* > Observers;
37  typedef std::vector< L* > Layouts;
38  typedef std::vector< CV* > Canvases;
39  typedef std::vector< N* > Nodes;
40 
44  EQFABRIC_INL lunchbox::RefPtr< S > getServer();
45 
47  EQFABRIC_INL lunchbox::RefPtr< const S > getServer() const;
48 
50  const Observers& getObservers() const { return _observers; }
51 
53  const Layouts& getLayouts() const { return _layouts; }
54 
56  const Canvases& getCanvases() const { return _canvases; }
57 
62  EQFABRIC_INL uint32_t getTimeout() const;
63 
68  const Nodes& getNodes() const { return _nodes; }
69 
70  EQFABRIC_INL N* findAppNode();
71  EQFABRIC_INL const N* findAppNode() const;
72 
80  EQFABRIC_INL VisitorResult accept( V& visitor );
81 
83  EQFABRIC_INL VisitorResult accept( V& visitor ) const;
84 
86  template< typename T > EQFABRIC_INL T* find( const uint128_t& id );
87 
89  template< typename T >
90  EQFABRIC_INL const T* find( const uint128_t& id ) const;
91 
93  template< typename T >
94  EQFABRIC_INL T* find( const std::string& name );
95 
97  template< typename T >
98  EQFABRIC_INL const T* find( const std::string& name ) const;
99 
101  O* getObserver( const ObserverPath& path );
102 
104  L* getLayout( const LayoutPath& path );
105 
107  CV* getCanvas( const CanvasPath& path );
108 
110  template< typename T > void find( const uint128_t& id, T** result );
111 
113  template< typename T > void find( const std::string& name,
114  const T** result ) const;
115 
117  virtual void updateCanvas( CV* ) { /* NOP */ }
118 
120  virtual void exitCanvas( CV* ) { /* NOP */ }
122 
125  // Note: also update string array initialization in config.ipp
126 
129  {
132  FATTR_LAST,
133  FATTR_ALL = FATTR_LAST + 5
134  };
135 
138  {
140  IATTR_LAST,
141  IATTR_ALL = IATTR_LAST + 5
142  };
143 
145  void setFAttribute( const FAttribute attr, const float value )
146  { _fAttributes[attr] = value; }
148  void setIAttribute( const IAttribute attr, const int32_t value )
149  { _iAttributes[attr] = value; }
150 
152  float getFAttribute( const FAttribute attr ) const
153  { return _fAttributes[attr]; }
154 
156  int32_t getIAttribute( const IAttribute attr ) const
157  { return _iAttributes[attr]; }
158 
160  static const std::string& getFAttributeString( const FAttribute attr );
162  static const std::string& getIAttributeString( const IAttribute attr );
164 
165 
179  virtual void setLatency( const uint32_t latency );
180 
182  uint32_t getLatency() const { return _data.latency; }
183 
185  EQFABRIC_INL virtual void restore();
187 
188  virtual void output( std::ostream& ) const {}
189  void create( O** observer );
190  void release( O* observer );
191  void create( L** layout );
192  void release( L* layout );
193  void create( CV** canvas );
194  void release( CV* canvas );
195  void create( N** node );
196  void release( N* node );
197 
198  protected:
200  EQFABRIC_INL Config( lunchbox::RefPtr< S > parent );
201 
203  EQFABRIC_INL virtual ~Config();
204 
206  EQFABRIC_INL virtual void attach( const uint128_t& id,
207  const uint32_t instanceID );
208 
210  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
211  const uint64_t dirtyBits );
212  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
213  const uint64_t dirtyBits );
214  EQFABRIC_INL virtual void notifyDetach();
215 
217  virtual void _removeChild( const uint128_t& )
218  { LBUNIMPLEMENTED; }
219 
220  template< class, class, class, class, class, class >
221  friend class Server;
222 
223  void setAppNodeID( const co::NodeID& nodeID );
224 
225  const co::NodeID& getAppNodeID() const { return _appNodeID; }
226 
228  EQFABRIC_INL EventOCommand sendError( co::NodePtr node,
229  const uint32_t event,
230  const Error& error );
231 
232  virtual void changeLatency( const uint32_t ) { /* NOP */ }
233  virtual bool mapViewObjects() const { return false; }
234  virtual bool mapNodeObjects() const { return false; }
235 
237  virtual VisitorResult _acceptCompounds( V& )
238  { return TRAVERSE_CONTINUE; }
240  virtual VisitorResult _acceptCompounds( V& ) const
241  { return TRAVERSE_CONTINUE; }
242  template< class C2, class V2 >
243  friend VisitorResult _acceptImpl( C2*, V2& );
244 
245  N* _findNode( const uint128_t& id );
246 
248  EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
249  CO_COMMIT_NEXT );
251 
252  private:
254  lunchbox::RefPtr< S > _server;
255 
257  float _fAttributes[FATTR_ALL];
258 
260  int32_t _iAttributes[IATTR_ALL];
261 
263  Observers _observers;
264 
266  Layouts _layouts;
267 
269  Canvases _canvases;
270 
272  Nodes _nodes;
273 
275  co::NodeID _appNodeID;
276 
277  struct BackupData
278  {
279  BackupData() : latency( 1 ) {}
280 
282  uint32_t latency;
283  }
284  _data, _backup;
285 
286  struct Private;
287  Private* _private; // placeholder for binary-compatible changes
288 
289  enum DirtyBits
290  {
291  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 0,
292  DIRTY_LATENCY = Object::DIRTY_CUSTOM << 1,
293  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 2,
294  DIRTY_NODES = Object::DIRTY_CUSTOM << 3,
295  DIRTY_OBSERVERS = Object::DIRTY_CUSTOM << 4,
296  DIRTY_LAYOUTS = Object::DIRTY_CUSTOM << 5,
297  DIRTY_CANVASES = Object::DIRTY_CUSTOM << 6,
298  DIRTY_CONFIG_BITS =
299  DIRTY_MEMBER | DIRTY_ATTRIBUTES | DIRTY_OBSERVERS |
300  DIRTY_LAYOUTS | DIRTY_CANVASES | DIRTY_NODES | DIRTY_LATENCY
301  };
302 
304  virtual uint64_t getRedistributableBits() const
305  { return DIRTY_CONFIG_BITS; }
306 
307  template< class, class > friend class Observer;
308  void _addObserver( O* observer );
309  bool _removeObserver( O* observer );
310 
311  template< class, class, class > friend class Layout;
312  void _addLayout( L* layout );
313  bool _removeLayout( L* layout );
314 
315  template< class, class, class, class > friend class Canvas;
316  void _addCanvas( CV* canvas );
317  bool _removeCanvas( CV* canvas );
318 
319  template< class, class, class, class > friend class Node;
320  void _addNode( N* node );
321  EQFABRIC_INL bool _removeNode( N* node );
322 
323  typedef co::CommandFunc< Config< S, C, O, L, CV, N, V > > CmdFunc;
324  bool _cmdNewLayout( co::ICommand& command );
325  bool _cmdNewCanvas( co::ICommand& command );
326  bool _cmdNewObserver( co::ICommand& command );
327  bool _cmdNewEntityReply( co::ICommand& command );
328  };
329 
330  template< class S, class C, class O, class L, class CV, class N, class V >
331  EQFABRIC_INL std::ostream& operator << ( std::ostream& os,
332  const Config< S, C, O, L, CV, N, V >& config );
333 }
334 }
335 #endif // EQFABRIC_CONFIG_H
std::vector< L * > Layouts
A vector of layouts.
Definition: fabric/config.h:37
const Observers & getObservers() const
Definition: fabric/config.h:50
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.
std::vector< CV * > Canvases
A vector of canvases.
Definition: fabric/config.h:38
const Nodes & getNodes() const
Definition: fabric/config.h:68
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:39
const Layouts & getLayouts() const
Definition: fabric/config.h:53
const Canvases & getCanvases() const
Definition: fabric/config.h:56
int32_t getIAttribute(const IAttribute attr) const
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:33
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:36
virtual void setLatency(const uint32_t latency)
Set the maximum accepted latency for this config.
uint32_t getLatency() const
Tolerate resource failures.