lib/client/config.h

00001 
00002 /* Copyright (c) 2005-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQ_CONFIG_H
00019 #define EQ_CONFIG_H
00020 
00021 #include <eq/client/commandQueue.h>  // member
00022 #include <eq/client/observer.h>      // member
00023 #include <eq/client/types.h>         // typedefs
00024 #include <eq/client/visitorResult.h> // enum
00025 
00026 #include <eq/net/session.h>          // base class
00027 #include <eq/base/monitor.h>         // member
00028 
00029 namespace eq
00030 {
00031     class ConfigDeserializer;
00032     class ConfigVisitor;
00033     class Node;
00034     class SceneObject;
00035     struct ConfigEvent;
00036 
00041     class Config : public net::Session
00042     {
00043     public:
00045         EQ_EXPORT Config( ServerPtr parent );
00046 
00048         EQ_EXPORT virtual ~Config();
00049 
00052         EQ_EXPORT ClientPtr getClient();
00053         EQ_EXPORT ServerPtr getServer();
00054 
00055         EQ_EXPORT CommandQueue* getNodeThreadQueue();
00056 
00057         uint32_t getCurrentFrame()  const { return _currentFrame; }
00058         uint32_t getFinishedFrame() const { return _finishedFrame.get(); }
00059         uint32_t getLatency() const { return _latency; }
00060 
00062         const NodeVector& getNodes() const { return _nodes; }
00063 
00065         const ObserverVector& getObservers() const { return _observers; }
00066 
00068         Observer* findObserver( const uint32_t id );
00069 
00071         const LayoutVector& getLayouts() const { return _layouts; }
00072 
00074         EQ_EXPORT Layout* findLayout( const uint32_t id );
00075 
00077         EQ_EXPORT View* findView( const uint32_t id );
00078 
00080         const CanvasVector& getCanvases() const { return _canvases; }
00081 
00083         const std::string& getName() const { return _name; }
00084 
00091         EQ_EXPORT VisitorResult accept( ConfigVisitor& visitor );
00092 
00094         EQ_EXPORT void getStatistics( std::vector< FrameStatistics >& stats );
00095 
00100         bool isRunning() const { return _running; }
00101 
00103         void stopRunning() { _running = false; }
00104 
00106         int64_t getTime() const { return _clock.getTime64(); }
00108 
00117         EQ_EXPORT virtual bool init( const uint32_t initID );
00118 
00128         EQ_EXPORT virtual bool exit();
00130 
00142         EQ_EXPORT virtual uint32_t startFrame( const uint32_t frameID );
00143 
00150         EQ_EXPORT virtual uint32_t finishFrame();
00151 
00157         EQ_EXPORT virtual uint32_t finishAllFrames();
00158 
00167         void releaseFrameLocal( const uint32_t frameNumber )
00168             { _unlockedFrame = frameNumber; }
00170 
00178         EQ_EXPORT void sendEvent( ConfigEvent& event );
00179 
00187         EQ_EXPORT const ConfigEvent* nextEvent();
00188 
00196         EQ_EXPORT const ConfigEvent* tryNextEvent();
00197 
00199         bool checkEvent() const { return !_eventQueue.isEmpty(); }
00200 
00208         EQ_EXPORT virtual void handleEvents();
00209 
00217         EQ_EXPORT virtual bool handleEvent( const ConfigEvent* event );
00219         
00220 #ifdef EQ_USE_DEPRECATED
00221 
00234         EQ_EXPORT void setHeadMatrix( const vmml::Matrix4f& matrix );
00235 
00237         EQ_EXPORT const vmml::Matrix4f& getHeadMatrix() const;
00238 
00240         EQ_EXPORT void setEyeBase( const float eyeBase );
00241 
00243         EQ_EXPORT float getEyeBase() const;
00245 #endif
00246 
00250         const std::string& getErrorMessage() const { return _error; }
00252 
00253 #ifdef EQ_TRANSMISSION_API
00254 
00262         void broadcastData( const void* data, uint64_t size );
00264 #endif
00265 
00267         EQ_EXPORT void freezeLoadBalancing( const bool onOff );
00268 
00274         void setWindowSystem( const WindowSystem windowSystem );
00275 
00276     protected:
00277 
00279         EQ_EXPORT virtual void notifyMapped( net::NodePtr node );
00280 
00281     private:
00283         net::NodeID _appNodeID;
00284         friend class Server;
00285 
00287         std::string _name;
00288 
00290         net::NodePtr _appNode;
00291 
00292 #ifdef EQ_TRANSMISSION_API
00293 
00294         std::vector<net::NodeID> _clientNodeIDs;
00295 
00297         net::NodeVector _clientNodes;
00298 #endif
00299 
00301         NodeVector _nodes;
00302 
00304         ObserverVector _observers;
00305 
00307         LayoutVector _layouts;
00308 
00310         CanvasVector _canvases;
00311 
00313         float _eyeBase;
00314 
00316         std::string _error;
00317 
00319         CommandQueue _eventQueue;
00320         
00322         net::Command* _lastEvent;
00323 
00325         std::deque< FrameStatistics > _statistics;
00326         base::Lock                    _statisticsMutex;
00327 
00329         uint32_t _latency;
00330 
00332         uint32_t _currentFrame;
00334         uint32_t _unlockedFrame;
00336         base::Monitor< uint32_t > _finishedFrame;
00337 
00339         base::Clock _clock;
00340 
00342         bool _running;
00343 
00344         union // placeholder for binary-compatible changes
00345         {
00346             char dummy[64];
00347         };
00348 
00349         friend class Node;
00350         void _addNode( Node* node );
00351         void _removeNode( Node* node );
00352         Node* _findNode( const uint32_t id );
00353 
00354         friend class ConfigDeserializer;
00355         void _addObserver( Observer* observer );
00356         void _removeObserver( Observer* observer );
00357         void _addLayout( Layout* layout );
00358         void _removeLayout( Layout* layout );
00359         void _addCanvas( Canvas* canvas );
00360         void _removeCanvas( Canvas* canvas );
00361 
00362         bool _needsLocalSync() const;
00363 
00368         void _updateStatistics( const uint32_t finishedFrame );
00369 
00370 #ifdef EQ_TRANSMISSION_API
00371 
00372         bool _connectClientNodes();
00373 #endif
00374 
00376         void _initAppNode( const uint32_t distributorID );
00377 
00379         net::CommandResult _cmdSyncClock( net::Command& command );
00380         net::CommandResult _cmdCreateNode( net::Command& command );
00381         net::CommandResult _cmdDestroyNode( net::Command& command );
00382         net::CommandResult _cmdInitReply( net::Command& command );
00383         net::CommandResult _cmdExitReply( net::Command& command );
00384         net::CommandResult _cmdStartFrameReply( net::Command& command );
00385         net::CommandResult _cmdReleaseFrameLocal( net::Command& command );
00386         net::CommandResult _cmdFrameFinish( net::Command& command );
00387 #ifdef EQ_TRANSMISSION_API
00388         net::CommandResult _cmdData( net::Command& command );
00389 #endif
00390         net::CommandResult _cmdUnmap( net::Command& command );
00391     };
00392 }
00393 
00394 #endif // EQ_CONFIG_H
00395 
Generated on Mon Aug 10 18:58:32 2009 for Equalizer 0.9 by  doxygen 1.5.8