server/config.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQSERVER_CONFIG_H
00019 #define EQSERVER_CONFIG_H
00020
00021 #include "base.h"
00022 #include "types.h"
00023 #include "server.h"
00024 #include "visitorResult.h"
00025
00026 #include <eq/net/session.h>
00027
00028 #include <iostream>
00029 #include <vector>
00030
00031 namespace eq
00032 {
00033 namespace server
00034 {
00035 class ConfigSerializer;
00036 class ConfigVisitor;
00037 class ConstConfigVisitor;
00038 struct CanvasPath;
00039 struct ChannelPath;
00040 struct LayoutPath;
00041 struct ObserverPath;
00042 struct SegmentPath;
00043 struct ViewPath;
00044
00048 class Config : public net::Session
00049 {
00050 public:
00054 EQSERVER_EXPORT Config();
00055 virtual ~Config();
00056
00060 Config( const Config& from );
00061
00066 Server* getServer() { return _server; }
00067
00068 Channel* getChannel( const ChannelPath& path );
00069 Canvas* getCanvas( const CanvasPath& path );
00070 Segment* getSegment( const SegmentPath& path );
00071 Layout* getLayout( const LayoutPath& path );
00072 Observer* getObserver( const ObserverPath& path );
00073 View* getView( const ViewPath& path );
00074
00075 bool isRunning() const { return ( _state == STATE_RUNNING ); }
00076
00077 net::CommandQueue* getServerThreadQueue()
00078 { EQASSERT( _server ); return _server->getServerThreadQueue(); }
00079
00080 void setName( const std::string& name ) { _name = name; }
00081 const std::string& getName() const { return _name; }
00082
00088 EQSERVER_EXPORT void addNode( Node* node );
00089
00097 bool removeNode( Node* node );
00098
00100 const NodeVector& getNodes() const { return _nodes; }
00101
00107 void addObserver( Observer* observer );
00108
00116 bool removeObserver( Observer* observer );
00117
00119 const ObserverVector& getObservers() const { return _observers; }
00120
00128 Observer* findObserver( const std::string& name );
00129 const Observer* findObserver( const std::string& name ) const;
00130
00132 Observer* findObserver( const uint32_t id );
00133
00139 EQSERVER_EXPORT void addLayout( Layout* layout );
00140
00148 bool removeLayout( Layout* layout );
00149
00151 const LayoutVector& getLayouts() const { return _layouts; }
00152
00160 Layout* findLayout( const std::string& name );
00161 const Layout* findLayout( const std::string& name ) const;
00162
00164 Layout* findLayout( const uint32_t id );
00165
00173 View* findView( const std::string& name );
00174 const View* findView( const std::string& name ) const;
00175
00181 EQSERVER_EXPORT void addCanvas( Canvas* canvas );
00182
00190 bool removeCanvas( Canvas* canvas );
00191
00193 const CanvasVector& getCanvases() const { return _canvases; }
00194
00202 Canvas* findCanvas( const std::string& name );
00203 const Canvas* findCanvas( const std::string& name ) const;
00204
00212 Segment* findSegment( const std::string& name );
00213 const Segment* findSegment( const std::string& name ) const;
00214
00220 EQSERVER_EXPORT void addCompound( Compound* compound );
00221
00229 bool removeCompound( Compound* compound );
00230
00232 const CompoundVector& getCompounds() const { return _compounds; }
00233
00241 EQSERVER_EXPORT Channel* findChannel( const std::string& name );
00242 const Channel* findChannel( const std::string& name ) const;
00243
00251 Channel* findChannel( const Segment* segment, const View* view );
00252
00259 VisitorResult accept( ConfigVisitor& visitor );
00260 VisitorResult accept( ConstConfigVisitor& visitor ) const;
00262
00272 void setLatency( const uint32_t latency ) { _latency = latency; }
00273
00275 uint32_t getLatency() const { return _latency; }
00276
00278 uint32_t getFinishedFrame() const { return _finishedFrame; }
00284 void setApplicationName( const std::string& name ) { _appName = name; }
00285
00291 void addApplicationNode( Node* node );
00292
00294 Node* getApplicationNode() { return _appNode; }
00295
00297 bool isApplicationNode( const Node* node ) const
00298 { return (_appNode == node); }
00299
00305 void setApplicationNetNode( net::NodePtr node );
00306
00312 void setRenderClient( const std::string& rc ){ _renderClient = rc; }
00313
00319 void setWorkDir( const std::string& workDir ){ _workDir = workDir; }
00320
00322 void notifyNodeFrameFinished( const uint32_t frameNumber );
00323
00324
00325 bool exit();
00326
00331 void unmap();
00332
00335
00336 enum FAttribute
00337 {
00338 FATTR_EYE_BASE,
00339 FATTR_VERSION,
00340 FATTR_FILL1,
00341 FATTR_FILL2,
00342 FATTR_ALL
00343 };
00344
00345 void setFAttribute( const FAttribute attr, const float value )
00346 { _fAttributes[attr] = value; }
00347 float getFAttribute( const FAttribute attr ) const
00348 { return _fAttributes[attr]; }
00349 static const std::string& getFAttributeString( const FAttribute attr )
00350 { return _fAttributeStrings[attr]; }
00352
00356 const std::string& getErrorMessage() const { return _error; }
00358
00360 uint32_t getDistributorID();
00361
00363 uint32_t getInitID(){ return _initID; }
00364
00365 protected:
00367 virtual void notifyMapped( net::NodePtr node );
00368
00369 private:
00371 std::string _name;
00372
00374 uint32_t _initID;
00375
00377 float _fAttributes[FATTR_ALL];
00378
00380 static std::string _fAttributeStrings[FATTR_ALL];
00381
00383 Server* _server;
00384 friend class Server;
00385
00387 NodeVector _nodes;
00388
00390 ObserverVector _observers;
00391
00393 LayoutVector _layouts;
00394
00396 CanvasVector _canvases;
00397
00399 CompoundVector _compounds;
00400
00402 std::string _error;
00403
00405 std::string _appName;
00406
00408 Node* _appNode;
00409
00411 net::NodePtr _appNetNode;
00412
00414 std::string _renderClient;
00415
00417 std::string _workDir;
00418
00420 uint32_t _latency;
00421
00423 uint32_t _currentFrame;
00424
00426 uint32_t _finishedFrame;
00427
00428 enum State
00429 {
00430 STATE_STOPPED = 0,
00431 STATE_INITIALIZING,
00432 STATE_RUNNING,
00433 STATE_EXITING,
00434 }
00435 _state;
00436
00437 ConfigSerializer* _serializer;
00438
00440 base::Clock _clock;
00441 union
00442 {
00443 char dummy[64];
00444 };
00445
00451 void _construct();
00452
00453 bool _updateRunning();
00454 bool _connectNodes();
00455 bool _connectNode( Node* node );
00456 bool _syncConnectNode( Node* node );
00457 void _startNodes();
00458 uint32_t _createConfig( Node* node );
00459 void _stopNodes();
00460 void _syncClock();
00461
00462 bool _init( const uint32_t initID );
00463
00464 bool _startFrame( const uint32_t frameID );
00465 void _flushAllFrames();
00467
00469 net::CommandResult _cmdInit( net::Command& command );
00470 net::CommandResult _cmdExit( net::Command& command );
00471 net::CommandResult _cmdStartFrame( net::Command& command );
00472 net::CommandResult _cmdFinishAllFrames( net::Command& command );
00473 net::CommandResult _cmdCreateReply( net::Command& command );
00474 net::CommandResult _cmdFreezeLoadBalancing( net::Command& command );
00475 net::CommandResult _cmdUnmapReply( net::Command& command );
00476 };
00477
00478 std::ostream& operator << ( std::ostream& os, const Config* config );
00479 }
00480 }
00481 #endif // EQSERVER_CONFIG_H