Equalizer  1.6.1
include/eq/client/config.h
1 
2 /* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric Stalder@gmail.com>
4  * 2011-2012, 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 EQ_CONFIG_H
21 #define EQ_CONFIG_H
22 
23 #include <eq/client/api.h>
24 #include <eq/client/types.h>
25 
26 #include <eq/fabric/config.h> // base class
27 #include <co/objectHandler.h> // base class
28 
29 namespace eq
30 {
31 namespace detail { class Config; }
32 
55  class Config : public fabric::Config< Server, Config, Observer, Layout,
56  Canvas, Node, ConfigVisitor >,
57  public co::ObjectHandler
58  {
59  public:
62 
64  EQ_API Config( ServerPtr parent );
65 
67  EQ_API virtual ~Config();
68 
72  EQ_API ClientPtr getClient();
73 
75  EQ_API ConstClientPtr getClient() const;
76 
81  EQ_API co::NodePtr getApplicationNode();
82 
83  EQ_API co::CommandQueue* getMainThreadQueue();
84  EQ_API co::CommandQueue* getCommandThreadQueue();
85 
87  EQ_API uint32_t getCurrentFrame() const;
88 
90  EQ_API uint32_t getFinishedFrame() const;
91 
93  EQ_API GLStats::Data getStatistics() const;
94 
100  EQ_API bool isRunning() const;
101 
103  EQ_API void stopRunning();
104 
116  EQ_API int64_t getTime() const;
117 
120 
122  const Channel* findChannel( const std::string& name ) const
123  { return find< Channel >( name ); }
125 
151  EQ_API virtual bool init( const uint128_t& initID );
152 
169  EQ_API virtual bool exit();
170 
191  EQ_API bool update();
192 
194  EQ_API virtual void setLatency( const uint32_t latency );
196 
206  EQ_API virtual bool registerObject( co::Object* object );
207 
217  EQ_API virtual void deregisterObject( co::Object* object );
218 
226  EQ_API virtual bool mapObject( co::Object* object, const UUID& id,
227  const uint128_t& version = co::VERSION_OLDEST );
228 
229 
231  EQ_API virtual uint32_t mapObjectNB( co::Object* object, const UUID& id,
232  const uint128_t& version = co::VERSION_OLDEST );
233 
238  EQ_API virtual uint32_t mapObjectNB( co::Object* object, const UUID& id,
239  const uint128_t& version, co::NodePtr master );
240 
242  EQ_API virtual bool mapObjectSync( const uint32_t requestID );
243 
251  EQ_API virtual void unmapObject( co::Object* object );
252 
254  EQ_API void releaseObject( co::Object* object );
256 
276  EQ_API virtual uint32_t startFrame( const uint128_t& frameID );
277 
293  EQ_API virtual uint32_t finishFrame();
294 
304  EQ_API virtual uint32_t finishAllFrames();
305 
318  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
319 
329  EQ_API void stopFrames();
330 
332 
335 #ifndef EQ_2_0_API
336 
348  EQ_API const ConfigEvent* nextEvent();
349 
361  EQ_API const ConfigEvent* tryNextEvent();
362 #endif
363 
373  EQ_API void sendEvent( ConfigEvent& event );
374 
386  EQ_API virtual bool handleEvent( const ConfigEvent* event );
387 
399  EQ_API EventOCommand sendEvent( const uint32_t type );
400 
414  EQ_API EventICommand getNextEvent( const uint32_t timeout =
415  LB_TIMEOUT_INDEFINITE ) const;
416 
424  EQ_API virtual bool handleEvent( EventICommand command );
425 
427  EQ_API bool checkEvent() const;
428 
438  EQ_API virtual void handleEvents();
439 
447  void addStatistic( const uint32_t originator, const Statistic& stat );
449 
455  void setupMessagePump( Pipe* pipe );
456 
458  void setupServerConnections( const std::string& connectionData );
459 
460  protected:
462  EQ_API virtual void attach( const UUID& id,
463  const uint32_t instanceID );
464 
465  EQ_API virtual void notifyAttached();
466  EQ_API virtual void notifyDetach();
467 
468  EQ_API virtual void changeLatency( const uint32_t latency );
469  EQ_API virtual bool mapViewObjects() const;
470 
471  private:
472  detail::Config* const _impl;
473 
474  void _frameStart();
475  friend class Node;
476 
477  bool _needsLocalSync() const;
478 
479  bool _handleNewEvent( EventICommand& command );
480  bool _handleEvent( const Event& event );
481  const ConfigEvent* _convertEvent( co::ObjectICommand command );
482 
487  void _updateStatistics( const uint32_t finishedFrame );
488 
491  void _releaseObjects();
492 
494  void _exitMessagePump();
495 
497  bool _cmdSyncClock( co::ICommand& command );
498  bool _cmdCreateNode( co::ICommand& command );
499  bool _cmdDestroyNode( co::ICommand& command );
500  bool _cmdInitReply( co::ICommand& command );
501  bool _cmdExitReply( co::ICommand& command );
502  bool _cmdUpdateVersion( co::ICommand& command );
503  bool _cmdUpdateReply( co::ICommand& command );
504  bool _cmdReleaseFrameLocal( co::ICommand& command );
505  bool _cmdFrameFinish( co::ICommand& command );
506  bool _cmdSwapObject( co::ICommand& command );
507  };
508 }
509 
510 #endif // EQ_CONFIG_H
A configuration is a visualization session driven by an application.
Event structure to report window system and other events.
Definition: event.h:171
Config(ServerPtr parent)
Construct a new config.
virtual uint32_t finishAllFrames()
Finish rendering all pending frames.
A command specialization for config events.
Definition: eventICommand.h:38
A channel represents a two-dimensional viewport within a Window.
virtual bool init(const uint128_t &initID)
Initialize this configuration.
A visitor to traverse configs and all children.
Definition: configVisitor.h:36
bool checkEvent() const
int64_t getTime() const
Get the current time in milliseconds.
virtual void setLatency(const uint32_t latency)
A layout groups one or more View, logically belonging together.
Definition: client/layout.h:44
co::NodePtr getApplicationNode()
virtual void handleEvents()
Handle all config events.
A canvas represents a logical 2D projection surface.
Definition: client/canvas.h:51
virtual void unmapObject(co::Object *object)
Unmap a mapped object.
A Node represents a single computer in the cluster.
const ConfigEvent * nextEvent()
Get the next event.
void stopFrames()
Asynchronously signal all channels to interrupt their rendering.
A Pipe represents a graphics card (GPU) on a Node.
Proxy object for the connection to an Equalizer server.
Definition: client/server.h:38
void releaseObject(co::Object *object)
Convenience method to deregister or unmap an object.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
virtual void deregisterObject(co::Object *object)
Deregister a distributed object.
virtual uint32_t mapObjectNB(co::Object *object, const UUID &id, const uint128_t &version=co::VERSION_OLDEST)
Start mapping a distributed object.
virtual bool handleEvent(const ConfigEvent *event)
Handle one (old) config event.
void sendEvent(ConfigEvent &event)
Send an (old) event to the application node.
virtual bool mapObject(co::Object *object, const UUID &id, const uint128_t &version=co::VERSION_OLDEST)
Map a distributed object.
virtual uint32_t startFrame(const uint128_t &frameID)
Request a new frame of rendering.
void addStatistic(const uint32_t originator, const Statistic &stat)
Add an statistic event to the statistics overlay.
virtual uint32_t finishFrame()
Finish the rendering of a frame.
const ConfigEvent * tryNextEvent()
Try to get the next event.
ClientPtr getClient()
EventICommand getNextEvent(const uint32_t timeout=LB_TIMEOUT_INDEFINITE) const
Get the next event.
uint32_t getFinishedFrame() const
fabric::Config< Server, Config, Observer, Layout, Canvas, Node, ConfigVisitor > Super
base class
lunchbox::RefPtr< Client > ClientPtr
A reference-counted pointer to an eq::Client.
An Observer looks at one or more views from a certain position (head matrix) with a given eye separat...
void releaseFrameLocal(const uint32_t frameNumber)
Release the local synchronization of the config for a frame.
A statistics event.
Definition: statistic.h:36
virtual bool registerObject(co::Object *object)
Register a distributed object.
Base data class for a configuration.
bool update()
Update the configuration.
An interface to process system messages or events.
Definition: messagePump.h:26
virtual bool exit()
Exit this configuration.
virtual bool mapObjectSync(const uint32_t requestID)
Finalize the mapping of a distributed object.
bool isRunning() const
virtual ~Config()
Destruct a config.
uint32_t getCurrentFrame() const
void stopRunning()
Stop the config.
MessagePump * getMessagePump()
lunchbox::RefPtr< const Client > ConstClientPtr
A reference-counted pointer to a const eq::Client.