server/pipe.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQSERVER_PIPE_H
00019 #define EQSERVER_PIPE_H
00020
00021 #include "types.h"
00022 #include "visitorResult.h"
00023
00024 #include <eq/client/global.h>
00025 #include <eq/client/pixelViewport.h>
00026 #include <eq/net/object.h>
00027 #include <eq/base/monitor.h>
00028
00029 #include <ostream>
00030 #include <vector>
00031
00032 namespace eq
00033 {
00034 namespace server
00035 {
00036 class PipeVisitor;
00037 class ConstPipeVisitor;
00038 struct ChannelPath;
00039 struct PipePath;
00040
00044 class Pipe : public net::Object
00045 {
00046 public:
00047 enum State
00048 {
00049 STATE_STOPPED = 0,
00050 STATE_INITIALIZING,
00051 STATE_INIT_SUCCESS,
00052 STATE_INIT_FAILED,
00053 STATE_RUNNING,
00054 STATE_EXITING,
00055 STATE_EXIT_SUCCESS,
00056 STATE_EXIT_FAILED,
00057 };
00058
00062 EQSERVER_EXPORT Pipe();
00063
00067 Pipe( const Pipe& from, Node* node );
00068
00069 Server* getServer();
00070 const Server* getServer() const;
00071
00072 Node* getNode() { return _node; }
00073 const Node* getNode() const { return _node; }
00074
00075 Config* getConfig();
00076 const Config* getConfig() const;
00077
00078 net::CommandQueue* getServerThreadQueue();
00079 net::CommandQueue* getCommandThreadQueue();
00080
00082 PipePath getPath() const;
00083
00084 Channel* getChannel( const ChannelPath& path );
00085
00087 State getState() const { return _state.get(); }
00088
00094 EQSERVER_EXPORT void addWindow( Window* window );
00095
00103 bool removeWindow( Window* window );
00104
00106 const WindowVector& getWindows() const { return _windows; }
00107
00114 VisitorResult accept( PipeVisitor& visitor );
00115 VisitorResult accept( ConstPipeVisitor& visitor ) const;
00116
00118 void activate();
00119
00121 void deactivate();
00122
00124 bool isActive() const { return (_active != 0); }
00125
00130 void addTasks( const uint32_t tasks );
00131
00132 void setName( const std::string& name ) { _name = name; }
00133 const std::string& getName() const { return _name; }
00134
00139 void setPort( const uint32_t port ) { _port = port; }
00140 uint32_t getPort() const { return _port; }
00141 void setDevice( const uint32_t device ) { _device = device; }
00142 uint32_t getDevice() const { return _device; }
00143
00153 void setPixelViewport( const eq::PixelViewport& pvp );
00154
00156 const eq::PixelViewport& getPixelViewport() const { return _pvp; }
00157
00159 void setLastDrawWindow( const Window* window )
00160 { _lastDrawWindow = window; }
00161 const Window* getLastDrawWindow() const { return _lastDrawWindow; }
00163
00169 void updateRunning( const uint32_t initID, const uint32_t frameNumber );
00170
00172 bool syncRunning();
00173
00181 void update( const uint32_t frameID, const uint32_t frameNumber );
00183
00188
00189 enum IAttribute
00190 {
00191 IATTR_HINT_THREAD,
00192 IATTR_FILL1,
00193 IATTR_FILL2,
00194 IATTR_ALL
00195 };
00196
00197 void setIAttribute( const IAttribute attr, const int32_t value )
00198 { _iAttributes[attr] = value; }
00199 int32_t getIAttribute( const IAttribute attr ) const
00200 { return _iAttributes[attr]; }
00201 static const std::string& getIAttributeString( const IAttribute attr )
00202 { return _iAttributeStrings[attr]; }
00203
00204 bool isThreaded() const
00205 { return (getIAttribute( IATTR_HINT_THREAD ) != eq::OFF ); }
00207
00211 const std::string& getErrorMessage() const { return _error; }
00213
00214 void send( net::ObjectPacket& packet );
00215
00216 protected:
00217 virtual ~Pipe();
00218
00220 base::RequestHandler _requestHandler;
00221
00223 virtual void attachToSession( const uint32_t id,
00224 const uint32_t instanceID,
00225 net::Session* session );
00226 private:
00228 std::string _name;
00229
00231 int32_t _iAttributes[IATTR_ALL];
00233 static std::string _iAttributeStrings[IATTR_ALL];
00234
00236 WindowVector _windows;
00237
00239 uint32_t _active;
00240
00242 std::string _error;
00243
00245 Node* _node;
00246 friend class Node;
00247
00249 uint32_t _tasks;
00250
00252 base::Monitor< State > _state;
00253
00255 uint32_t _port;
00256
00258 uint32_t _device;
00259
00260
00261
00262
00264 eq::PixelViewport _pvp;
00265
00267 const Window* _lastDrawWindow;
00268
00269 union
00270 {
00271 char dummy[64];
00272 };
00273
00275 void _construct();
00276
00277 void _send( net::ObjectPacket& packet, const std::string& string ) ;
00278
00279 void _configInit( const uint32_t initID, const uint32_t frameNumber );
00280 bool _syncConfigInit();
00281 void _configExit();
00282 bool _syncConfigExit();
00283
00284 virtual void getInstanceData( net::DataOStream& os ) { EQDONTCALL }
00285 virtual void applyInstanceData( net::DataIStream& is ) { EQDONTCALL }
00286
00287
00288 net::CommandResult _cmdConfigInitReply( net::Command& command );
00289 net::CommandResult _cmdConfigExitReply( net::Command& command );
00290 };
00291
00292 std::ostream& operator << ( std::ostream& os, const Pipe* pipe );
00293 }
00294 }
00295 #endif // EQSERVER_PIPE_H