Equalizer 1.0
|
00001 00002 /* Copyright (c) 2005-2011, 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/types.h> 00023 #include <eq/visitorResult.h> // enum 00024 #include <eq/fabric/node.h> // base class 00025 00026 #include <co/types.h> 00027 #include <co/base/mtQueue.h> // member 00028 #include <eq/api.h> 00029 00030 namespace eq 00031 { 00047 class Node : public fabric::Node< Config, Node, Pipe, NodeVisitor > 00048 { 00049 public: 00051 EQ_API Node( Config* parent ); 00052 00054 EQ_API virtual ~Node(); 00055 00057 EQ_API ClientPtr getClient(); 00058 00060 EQ_API ServerPtr getServer(); 00061 00062 EQ_API co::CommandQueue* getMainThreadQueue(); 00063 EQ_API co::CommandQueue* getCommandThreadQueue(); 00064 00072 co::Barrier* getBarrier( const co::ObjectVersion barrier ); 00073 00081 FrameData* getFrameData( const co::ObjectVersion& dataVersion ); 00082 00084 EQ_API void waitInitialized() const; 00085 00090 EQ_API bool isRunning() const; 00091 00096 EQ_API bool isStopped() const; 00097 00108 EQ_API void waitFrameStarted( const uint32_t frameNumber ) const; 00109 00111 uint32_t getFinishedFrame() const { return _finishedFrame; } 00112 00114 class TransmitThread : public co::base::Thread 00115 { 00116 public: 00117 TransmitThread( Node* parent ) : _node( parent ) {} 00118 virtual ~TransmitThread() {} 00119 00120 co::CommandQueue& getQueue() { return _queue; } 00121 00122 protected: 00123 virtual void run(); 00124 00125 private: 00126 co::CommandQueue _queue; 00127 Node* const _node; 00128 } transmitter; 00129 00131 EQ_API virtual void setDirty( const uint64_t bits ); 00132 00133 protected: 00135 EQ_API virtual void attach( const UUID& id, const uint32_t instanceID ); 00136 00145 EQ_API void startFrame( const uint32_t frameNumber ); 00146 00153 EQ_API void releaseFrame( const uint32_t frameNumber ); 00154 00161 EQ_API void releaseFrameLocal( const uint32_t frameNumber ); 00163 00171 00178 EQ_API virtual bool configInit( const uint128_t& initID ); 00179 00181 EQ_API virtual bool configExit(); 00182 00196 EQ_API virtual void frameStart( const uint128_t& frameID, 00197 const uint32_t frameNumber ); 00198 00211 EQ_API virtual void frameFinish( const uint128_t& frameID, 00212 const uint32_t frameNumber ); 00213 00226 EQ_API virtual void frameDrawFinish( const uint128_t& frameID, 00227 const uint32_t frameNumber ); 00228 00244 EQ_API virtual void frameTasksFinish( const uint128_t& frameID, 00245 const uint32_t frameNumber ); 00247 00248 private: 00249 enum State 00250 { 00251 STATE_STOPPED, 00252 STATE_INITIALIZING, 00253 STATE_INIT_FAILED, 00254 STATE_RUNNING, 00255 STATE_FAILED 00256 }; 00258 co::base::Monitor< State > _state; 00259 00261 co::base::Monitor< uint32_t > _currentFrame; 00262 00264 uint32_t _finishedFrame; 00265 00267 uint32_t _unlockedFrame; 00268 00269 typedef stde::hash_map< uint128_t, co::Barrier* > BarrierHash; 00271 co::base::Lockable< BarrierHash > _barriers; 00272 00273 typedef stde::hash_map< uint128_t, FrameData* > FrameDataHash; 00275 co::base::Lockable< FrameDataHash > _frameDatas; 00276 00277 struct Private; 00278 Private* _private; // placeholder for binary-compatible changes 00279 00280 void _finishFrame( const uint32_t frameNumber ) const; 00281 void _frameFinish( const uint128_t& frameID, 00282 const uint32_t frameNumber ); 00283 00284 void _flushObjects(); 00285 00287 bool _cmdCreatePipe( co::Command& command ); 00288 bool _cmdDestroyPipe( co::Command& command ); 00289 bool _cmdConfigInit( co::Command& command ); 00290 bool _cmdConfigExit( co::Command& command ); 00291 bool _cmdFrameStart( co::Command& command ); 00292 bool _cmdFrameFinish( co::Command& command ); 00293 bool _cmdFrameDrawFinish( co::Command& command ); 00294 bool _cmdFrameTasksFinish( co::Command& command ); 00295 bool _cmdFrameDataTransmit( co::Command& command ); 00296 bool _cmdFrameDataReady( co::Command& command ); 00297 00298 EQ_TS_VAR( _nodeThread ); 00299 EQ_TS_VAR( _commandThread ); 00300 }; 00301 } 00302 00303 #endif // EQ_NODE_H 00304