Equalizer  1.4.1
include/eq/client/node.h
00001 
00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com>
00003  *                    2010, Cedric Stalder<cedric.stalder@gmail.com>
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation .
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQ_NODE_H
00020 #define EQ_NODE_H
00021 
00022 #include <eq/client/api.h>
00023 #include <eq/client/types.h>
00024 #include <eq/client/visitorResult.h>  // enum
00025 #include <eq/fabric/node.h>           // base class
00026 
00027 #include <co/commandQueue.h>
00028 #include <co/types.h>
00029 #include <lunchbox/monitor.h>          // member
00030 #include <lunchbox/mtQueue.h>          // member
00031 
00032 namespace eq
00033 {
00049     class Node : public fabric::Node< Config, Node, Pipe, NodeVisitor >
00050     {
00051     public:
00053         EQ_API Node( Config* parent );
00054 
00056         EQ_API virtual ~Node();
00057 
00059         EQ_API ClientPtr getClient();
00060 
00062         EQ_API ServerPtr getServer();
00063 
00064         EQ_API co::CommandQueue* getMainThreadQueue(); 
00065         EQ_API co::CommandQueue* getCommandThreadQueue(); 
00066 
00068         uint32_t getCurrentFrame() const { return _currentFrame.get(); }
00069 
00077         co::Barrier* getBarrier( const co::ObjectVersion barrier );
00078 
00086         FrameDataPtr getFrameData( const co::ObjectVersion& frameDataVersion );
00087 
00089         void releaseFrameData( FrameDataPtr data );
00090 
00092         EQ_API void waitInitialized() const;
00093 
00098         EQ_API bool isRunning() const;
00099 
00104         EQ_API bool isStopped() const;
00105         
00116         EQ_API void waitFrameStarted( const uint32_t frameNumber ) const;
00117 
00119         uint32_t getFinishedFrame() const { return _finishedFrame; }
00120 
00122         class TransmitThread : public lunchbox::Thread
00123         {
00124         public:
00125             TransmitThread( Node* parent ) : _node( parent ) {}
00126             virtual ~TransmitThread() {}
00127 
00128             co::CommandQueue& getQueue() { return _queue; }
00129             
00130         protected:
00131             virtual void run();
00132 
00133         private:
00134             co::CommandQueue     _queue;
00135             Node* const           _node;
00136         } transmitter;
00137 
00139         EQ_API virtual void setDirty( const uint64_t bits );
00140 
00142         EQ_API void dirtyClientExit();
00143 
00144     protected:
00146         EQ_API virtual void attach( const UUID& id, const uint32_t instanceID );
00147 
00156         EQ_API void startFrame( const uint32_t frameNumber );
00157 
00164         EQ_API void releaseFrame( const uint32_t frameNumber );
00165 
00172         EQ_API void releaseFrameLocal( const uint32_t frameNumber );
00174 
00182 
00189         EQ_API virtual bool configInit( const uint128_t&  initID );
00190 
00192         EQ_API virtual bool configExit();
00193 
00207         EQ_API virtual void frameStart( const uint128_t& frameID, 
00208                                         const uint32_t frameNumber );
00209 
00222         EQ_API virtual void frameFinish( const uint128_t& frameID, 
00223                                          const uint32_t frameNumber );
00224 
00237         EQ_API virtual void frameDrawFinish( const uint128_t& frameID, 
00238                                              const uint32_t frameNumber );
00239 
00255         EQ_API virtual void frameTasksFinish( const uint128_t& frameID, 
00256                                               const uint32_t frameNumber );
00258 
00259     private:
00260         enum State
00261         {
00262             STATE_STOPPED,
00263             STATE_INITIALIZING,
00264             STATE_INIT_FAILED,
00265             STATE_RUNNING,
00266             STATE_FAILED
00267         };
00269         lunchbox::Monitor< State > _state;
00270 
00272         lunchbox::Monitor< uint32_t > _currentFrame;
00273 
00275         uint32_t _finishedFrame;
00276 
00278         uint32_t _unlockedFrame;
00279 
00280         typedef stde::hash_map< uint128_t, co::Barrier* > BarrierHash;
00282         lunchbox::Lockable< BarrierHash > _barriers;
00283 
00284         typedef stde::hash_map< uint128_t, FrameDataPtr > FrameDataHash;
00285         typedef FrameDataHash::const_iterator FrameDataHashCIter;
00286         typedef FrameDataHash::iterator FrameDataHashIter;
00288         lunchbox::Lockable< FrameDataHash > _frameDatas;
00289 
00290         struct Private;
00291         Private* _private; // placeholder for binary-compatible changes
00292 
00293         void _setAffinity();
00294 
00295         void _finishFrame( const uint32_t frameNumber ) const;
00296         void _frameFinish( const uint128_t& frameID,
00297                            const uint32_t frameNumber );
00298 
00299         void _flushObjects();
00300 
00302         bool _cmdCreatePipe( co::Command& command );
00303         bool _cmdDestroyPipe( co::Command& command );
00304         bool _cmdConfigInit( co::Command& command );
00305         bool _cmdConfigExit( co::Command& command );
00306         bool _cmdFrameStart( co::Command& command );
00307         bool _cmdFrameFinish( co::Command& command );
00308         bool _cmdFrameDrawFinish( co::Command& command );
00309         bool _cmdFrameTasksFinish( co::Command& command );
00310         bool _cmdFrameDataTransmit( co::Command& command );
00311         bool _cmdFrameDataReady( co::Command& command );
00312         bool _cmdSetAffinity( co::Command& command );
00313 
00314         LB_TS_VAR( _nodeThread );
00315         LB_TS_VAR( _commandThread );
00316     };
00317 }
00318 
00319 #endif // EQ_NODE_H
00320 
Generated on Mon Nov 26 2012 14:41:49 for Equalizer 1.4.1 by  doxygen 1.7.6.1