server/channel.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQSERVER_CHANNEL_H
00019 #define EQSERVER_CHANNEL_H
00020
00021 #ifdef EQUALIZERSERVERLIBRARY_EXPORTS
00022
00023
00024 # include <pthread.h>
00025 #endif
00026 #include <eq/base/monitor.h>
00027
00028 #include "base.h"
00029 #include "types.h"
00030 #include "visitorResult.h"
00031
00032 #include <eq/client/channel.h>
00033 #include <eq/client/commands.h>
00034 #include <eq/client/pixelViewport.h>
00035 #include <eq/client/viewport.h>
00036 #include <eq/net/object.h>
00037 #include <eq/net/packets.h>
00038
00039 #include <iostream>
00040 #include <vector>
00041
00042 namespace eq
00043 {
00044
00045 namespace server
00046 {
00047 class ChannelListener;
00048 class ChannelVisitor;
00049 struct ChannelPath;
00050
00054 class Channel : public net::Object
00055 {
00056 public:
00057 enum State
00058 {
00059 STATE_STOPPED = 0,
00060 STATE_INITIALIZING,
00061 STATE_INIT_SUCCESS,
00062 STATE_INIT_FAILED,
00063 STATE_RUNNING,
00064 STATE_EXITING,
00065 STATE_EXIT_SUCCESS,
00066 STATE_EXIT_FAILED,
00067 };
00068
00072 EQSERVER_EXPORT Channel();
00073
00077 Channel( const Channel& from, Window* window );
00078
00080 virtual ~Channel();
00081
00085 State getState() const { return _state.get(); }
00086
00091 Config* getConfig();
00092 const Config* getConfig() const;
00093
00094 EQSERVER_EXPORT Node* getNode();
00095 EQSERVER_EXPORT const Node* getNode() const;
00096
00097 Pipe* getPipe();
00098 const Pipe* getPipe() const;
00099
00100 Window* getWindow() { return _window; }
00101 const Window* getWindow() const { return _window; }
00102
00104 ChannelPath getPath() const;
00105
00106 const CompoundVector& getCompounds() const;
00107
00108 net::CommandQueue* getServerThreadQueue();
00109 net::CommandQueue* getCommandThreadQueue();
00110
00117 EQSERVER_EXPORT VisitorResult accept( ChannelVisitor& visitor );
00118 EQSERVER_EXPORT VisitorResult accept( ChannelVisitor& visitor ) const;
00119
00121 void activate();
00122
00124 void deactivate();
00125
00127 bool isActive() const { return (_active != 0); }
00128
00133 void addTasks( const uint32_t tasks );
00134
00136 void setOutput( View* view, Segment* segment );
00137
00139 void unsetOutput();
00140
00142 const View* getView() const { return _view; }
00143
00145 const Layout* getLayout() const;
00146
00148 const Segment* getSegment() const { return _segment; }
00149
00151 Segment* getSegment() { return _segment; }
00152
00153 void setName( const std::string& name ) { _name = name; }
00154 const std::string& getName() const { return _name; }
00155
00161 void setPixelViewport( const eq::PixelViewport& pvp );
00162
00168 const eq::PixelViewport& getPixelViewport() const { return _pvp; }
00169
00175 void notifyViewportChanged();
00176
00182 void setViewport( const eq::Viewport& vp );
00183
00189 const eq::Viewport& getViewport() const { return _vp; }
00190
00197 void getNearFar( float* nearPlane, float* farPlane ) const
00198 { *nearPlane = _near; *farPlane = _far; }
00199
00201 void setLastDrawCompound( const Compound* compound )
00202 { _lastDrawCompound = compound; }
00203 const Compound* getLastDrawCompound() const { return _lastDrawCompound;}
00205
00211 void updateRunning( const uint32_t initID );
00212
00214 bool syncRunning();
00215
00219 void startConfigExit();
00220
00227 bool syncConfigExit();
00228
00237 bool update( const uint32_t frameID, const uint32_t frameNumber );
00238
00239 void send( net::ObjectPacket& packet );
00240 void send( net::ObjectPacket& packet, const std::string& string );
00241 template< typename T >
00242 void send( net::ObjectPacket &packet, const std::vector<T>& data );
00244
00248 void addListener( ChannelListener* listener );
00250 void removeListener( ChannelListener* listener );
00252
00257 void setIAttribute( const eq::Channel::IAttribute attr,
00258 const int32_t value )
00259 { _iAttributes[attr] = value; }
00260 int32_t getIAttribute( const eq::Channel::IAttribute attr ) const
00261 { return _iAttributes[attr]; }
00263
00267 const std::string& getErrorMessage() const { return _error; }
00269
00270
00271 void setDrawable( const uint32_t drawable );
00272
00273
00274 uint32_t getDrawable() const { return _drawable; }
00275
00276 void setOverdraw( const Vector4i& overdraw )
00277 { _overdraw = overdraw; }
00278 const Vector4i& getOverdraw() const { return _overdraw; }
00279 const Vector2i& getMaxSize() const { return _maxSize; }
00280
00281 protected:
00283 base::RequestHandler _requestHandler;
00284
00286 virtual void attachToSession( const uint32_t id,
00287 const uint32_t instanceID,
00288 net::Session* session );
00289 private:
00290
00292 uint32_t _active;
00293
00295 View* _view;
00296
00298 Segment* _segment;
00299
00301 std::string _error;
00302
00304 Window* _window;
00305 friend class Window;
00306
00307 std::string _name;
00308
00310 int32_t _iAttributes[eq::Channel::IATTR_ALL];
00311
00313 eq::Viewport _vp;
00314
00316 eq::PixelViewport _pvp;
00317
00319 uint32_t _drawable;
00320
00322 bool _fixedPVP;
00323
00325 float _near;
00327 float _far;
00328
00329 Vector4i _overdraw;
00330 Vector2i _maxSize;
00331
00333 uint32_t _tasks;
00334
00336 base::Monitor< State > _state;
00337
00339 const Compound* _lastDrawCompound;
00340
00341 typedef std::vector< ChannelListener* > ChannelListeners;
00342 ChannelListeners _listeners;
00343
00344 CHECK_THREAD_DECLARE( _serverThread );
00345
00346 union
00347 {
00348 char dummy[64];
00349 };
00350
00351
00353 void _construct();
00354
00355 Vector3ub _getUniqueColor() const;
00356
00357 void _configInit( const uint32_t initID );
00358 bool _syncConfigInit();
00359 void _configExit();
00360 bool _syncConfigExit();
00361
00362 void _setupRenderContext( const uint32_t frameID,
00363 eq::RenderContext& context );
00364
00365 void _fireLoadData( const uint32_t frameNumber,
00366 const uint32_t nStatistics,
00367 const eq::Statistic* statistics );
00368
00369 virtual void getInstanceData( net::DataOStream& os ) { EQDONTCALL }
00370 virtual void applyInstanceData( net::DataIStream& is ) { EQDONTCALL }
00371
00372
00373 net::CommandResult _cmdConfigInitReply( net::Command& command );
00374 net::CommandResult _cmdConfigExitReply( net::Command& command );
00375 net::CommandResult _cmdSetNearFar( net::Command& command );
00376 net::CommandResult _cmdFrameFinishReply( net::Command& command );
00377
00378
00379 friend std::ostream& operator << ( std::ostream&, const Channel*);
00380 };
00381
00382 std::ostream& operator << ( std::ostream& os, const Channel* channel);
00383 }
00384 }
00385 #endif // EQSERVER_CHANNEL_H