compound.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQSERVER_COMPOUND_H
00019 #define EQSERVER_COMPOUND_H
00020
00021 #include "channel.h"
00022 #include "frustum.h"
00023 #include "frustumData.h"
00024
00025 #include <eq/client/colorMask.h>
00026 #include <eq/client/frame.h>
00027 #include <eq/client/frameData.h>
00028 #include <eq/client/global.h>
00029 #include <eq/client/projection.h>
00030 #include <eq/client/range.h>
00031 #include <eq/client/renderContext.h>
00032 #include <eq/client/task.h>
00033 #include <eq/client/viewport.h>
00034 #include <eq/client/wall.h>
00035 #include <eq/client/zoom.h>
00036 #include <eq/net/barrier.h>
00037 #include <eq/base/thread.h>
00038 #include <vmmlib/vector.hpp>
00039 #include <iostream>
00040 #include <vector>
00041
00042 namespace eq
00043 {
00044 namespace server
00045 {
00046 class ConstCompoundVisitor;
00047 class CompoundListener;
00048 class CompoundVisitor;
00049 class Frame;
00050 class SwapBarrier;
00051
00055 class Compound
00056 {
00057 public:
00061 EQSERVER_EXPORT Compound();
00062
00066 Compound( const Compound& from, Config* config, Compound* parent );
00067
00069 virtual ~Compound();
00070
00074 enum EyeMask
00075 {
00076 EYE_UNDEFINED = 0,
00077 EYE_CYCLOP_BIT = 1<<eq::EYE_CYCLOP,
00078 EYE_LEFT_BIT = 1<<eq::EYE_LEFT,
00079 EYE_RIGHT_BIT = 1<<eq::EYE_RIGHT
00080 };
00081
00083 enum ColorMask
00084 {
00085 COLOR_MASK_NONE = 0,
00086 COLOR_MASK_RED = 0x02,
00087 COLOR_MASK_GREEN = 0x04,
00088 COLOR_MASK_BLUE = 0x08,
00089 COLOR_MASK_ALL = 0xff
00090 };
00091
00096
00097 enum IAttribute
00098 {
00099 IATTR_STEREO_MODE,
00100 IATTR_STEREO_ANAGLYPH_LEFT_MASK,
00101 IATTR_STEREO_ANAGLYPH_RIGHT_MASK,
00102 IATTR_HINT_OFFSET,
00103 IATTR_FILL1,
00104 IATTR_FILL2,
00105 IATTR_ALL
00106 };
00107
00117 EQSERVER_EXPORT void addChild( Compound* child );
00118
00126 bool removeChild( Compound* child );
00127
00129 bool isLeaf() const { return _children.empty(); }
00130
00132 bool isDestination() const;
00133
00135 const CompoundVector& getChildren() const { return _children; }
00136
00138 Compound* getParent() const
00139 { return _parent; }
00140
00142 Compound* getRoot()
00143 { return _parent ? _parent->getRoot() : this; }
00144 const Compound* getRoot() const
00145 { return _parent ? _parent->getRoot() : this; }
00146
00148 Compound* getNext() const;
00149
00150 Config* getConfig() { return getRoot()->_config; }
00151 const Config* getConfig() const { return getRoot()->_config; }
00152
00153 Node* getNode();
00154
00155 void setName( const std::string& name ) { _name = name; }
00156 const std::string& getName() const { return _name; }
00157
00166 EQSERVER_EXPORT void setChannel( Channel* channel );
00167
00176 EQSERVER_EXPORT Channel* getChannel();
00177 EQSERVER_EXPORT const Channel* getChannel() const;
00178
00179 Window* getWindow();
00180 const Window* getWindow() const;
00181
00182 Pipe* getPipe();
00183 const Pipe* getPipe() const;
00184
00186 Frustum& getFrustum() { return _frustum; }
00187
00189 EQSERVER_EXPORT void addEqualizer( Equalizer* equalizer );
00190
00192 const EqualizerVector& getEqualizers() const
00193 { return _equalizers; }
00194
00205 void setTasks( const uint32_t tasks ) { _data.tasks = tasks; }
00206
00212 void enableTask( const eq::Task task ) { _data.tasks |= task; }
00213
00215 uint32_t getTasks() const { return _data.tasks; }
00216
00223 void setBuffers( const uint32_t buffers ) { _data.buffers = buffers; }
00224
00231 void enableBuffer( const eq::Frame::Buffer buffer )
00232 { _data.buffers |= buffer; }
00233
00235 uint32_t getBuffers() const { return _data.buffers; }
00236
00237 void setViewport( const eq::Viewport& vp ) { _data.vp = vp; }
00238 const eq::Viewport& getViewport() const { return _data.vp; }
00239
00240 void setRange( const eq::Range& range ) { _data.range = range; }
00241 const eq::Range& getRange() const { return _data.range; }
00242
00243 void setPeriod( const uint32_t period ) { _data.period = period; }
00244 uint32_t getPeriod() const { return _data.period; }
00245
00246 void setPhase( const uint32_t phase ) { _data.phase = phase; }
00247 uint32_t getPhase() const { return _data.phase; }
00248
00249 void setPixel( const eq::Pixel& pixel ) { _data.pixel = pixel; }
00250 const eq::Pixel& getPixel() const { return _data.pixel; }
00251
00252 void setZoom( const eq::Zoom& zoom ) { _data.zoom = zoom; }
00253 const eq::Zoom& getZoom() const { return _data.zoom; }
00254
00255 void setMaxFPS( const float fps ) { _data.maxFPS = fps; }
00256 float getMaxFPS() const { return _data.maxFPS; }
00257
00258 void setUsage( const float usage ) { _usage = usage; }
00259 float getUsage() const { return _usage; }
00260
00261 void setTaskID( const uint32_t id ) { _taskID = id; }
00262 uint32_t getTaskID() const { return _taskID; }
00264
00276 void setSwapBarrier( SwapBarrier* barrier );
00277
00279 const SwapBarrier* getSwapBarrier() const { return _swapBarrier; }
00280
00286 EQSERVER_EXPORT void addInputFrame( Frame* frame );
00287
00289 const FrameVector& getInputFrames() const {return _inputFrames; }
00290
00296 EQSERVER_EXPORT void addOutputFrame( Frame* frame );
00297
00299 const FrameVector& getOutputFrames() const { return _outputFrames; }
00301
00310 uint32_t getInheritBuffers() const { return _inherit.buffers; }
00311 const eq::PixelViewport& getInheritPixelViewport() const
00312 { return _inherit.pvp; }
00313 const Vector4i& getInheritOverdraw() const
00314 { return _inherit.overdraw; }
00315 const eq::Viewport& getInheritViewport() const { return _inherit.vp; }
00316 const eq::Range& getInheritRange() const { return _inherit.range; }
00317 const eq::Pixel& getInheritPixel() const { return _inherit.pixel; }
00318 const eq::Zoom& getInheritZoom() const { return _inherit.zoom; }
00319 uint32_t getInheritPeriod() const { return _inherit.period; }
00320 float getInheritMaxFPS() const { return _inherit.maxFPS; }
00321 int32_t getInheritIAttribute( const IAttribute attr ) const
00322 { return _inherit.iAttributes[attr]; }
00323 const FrustumData& getInheritFrustumData() const
00324 { return _inherit.frustumData; }
00325 uint32_t getInheritTasks() const { return _inherit.tasks; }
00326 uint32_t getInheritEyes() const { return _inherit.eyes; }
00327 const Channel* getInheritChannel() const { return _inherit.channel; }
00328
00330 bool testInheritTask( const eq::Task task ) const
00331 { return (_inherit.tasks & task); }
00332
00334 void unsetInheritTask( const eq::Task task )
00335 { _inherit.tasks &= ~task; }
00336
00338 bool testInheritEye( const eq::Eye eye ) const
00339 { return ( _inherit.eyes & (1<<eye) ); }
00341
00351 EQSERVER_EXPORT void setWall( const eq::Wall& wall );
00352
00354 const eq::Wall& getWall() const { return _frustum.getWall(); }
00355
00361 EQSERVER_EXPORT void setProjection( const eq::Projection& projection );
00362
00364 const eq::Projection& getProjection() const
00365 { return _frustum.getProjection(); }
00366
00368 eq::Frustum::Type getFrustumType() const
00369 { return _frustum.getCurrentType(); }
00370
00372 const eq::Frustum& getFrustum() const { return _frustum; }
00373
00375 void updateFrustum();
00376
00378 uint32_t getEyes() const { return _data.eyes; }
00379
00387 void setEyes( const uint32_t eyes ) { _data.eyes = eyes; }
00388
00396 void enableEye( const uint32_t eyes ) { _data.eyes |= eyes; }
00398
00407 EQSERVER_EXPORT VisitorResult accept( ConstCompoundVisitor& visitor )
00408 const;
00410 EQSERVER_EXPORT VisitorResult accept( CompoundVisitor& visitor );
00411
00412
00414 void activate();
00415
00417 void deactivate();
00418
00420 void setActive( const bool active )
00421 { EQASSERT( _active != active ); _active = active; }
00422
00424 bool isActive() const;
00425
00429 void init();
00430
00434 void exit();
00435
00441 void update( const uint32_t frameNumber );
00442
00444 void updateInheritData( const uint32_t frameNumber );
00446
00450 void addListener( CompoundListener* listener );
00452 void removeListener( CompoundListener* listener );
00453
00455 void fireUpdatePre( const uint32_t frameNumber );
00457
00462 void setIAttribute( const IAttribute attr, const int32_t value )
00463 { _data.iAttributes[attr] = value; }
00464 int32_t getIAttribute( const IAttribute attr ) const
00465 { return _data.iAttributes[attr]; }
00466 static const std::string& getIAttributeString( const IAttribute attr )
00467 { return _iAttributeStrings[attr]; }
00469
00470 typedef stde::hash_map<std::string, net::Barrier*> BarrierMap;
00471 typedef stde::hash_map<std::string, Frame*> FrameMap;
00472
00473 private:
00474
00475 std::string _name;
00476
00481 friend class Config;
00482 Config* _config;
00483
00484 Compound* _parent;
00485 CompoundVector _children;
00486
00488 bool _active;
00489
00491 static std::string _iAttributeStrings[IATTR_ALL];
00492
00494 float _usage;
00495
00497 uint32_t _taskID;
00498
00499 struct InheritData
00500 {
00501 InheritData();
00502
00503 Channel* channel;
00504 eq::Viewport vp;
00505 eq::PixelViewport pvp;
00506 Vector4i overdraw;
00507 eq::Range range;
00508 eq::Pixel pixel;
00509 FrustumData frustumData;
00510 eq::Zoom zoom;
00511 uint32_t buffers;
00512 uint32_t eyes;
00513 uint32_t tasks;
00514 uint32_t period;
00515 uint32_t phase;
00516 int32_t iAttributes[IATTR_ALL];
00517 float maxFPS;
00518 bool active;
00519
00520 union
00521 {
00522 char dummy[16];
00523 };
00524 };
00525
00526 InheritData _data;
00527 InheritData _inherit;
00528
00530 Frustum _frustum;
00531
00532 typedef std::vector< CompoundListener* > CompoundListeners;
00533 CompoundListeners _listeners;
00534
00535 EqualizerVector _equalizers;
00536
00537 SwapBarrier* _swapBarrier;
00538
00539 FrameVector _inputFrames;
00540 FrameVector _outputFrames;
00541
00542 union
00543 {
00544 char dummy[64];
00545 };
00546
00547 CHECK_THREAD_DECLARE( _serverThread );
00548
00549
00550 void _updateOverdraw( Wall& wall );
00551 void _updateInheritPVP();
00552 void _updateInheritOverdraw();
00553
00554 void _setDefaultFrameName( Frame* frame );
00555
00556 void _fireChildAdded( Compound* child );
00557 void _fireChildRemove( Compound* child );
00558 };
00559
00560 std::ostream& operator << ( std::ostream& os, const Compound* compound );
00561 }
00562 }
00563 #endif // EQSERVER_COMPOUND_H