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/subPixel.h>
00033 #include <eq/client/task.h>
00034 #include <eq/client/viewport.h>
00035 #include <eq/client/wall.h>
00036 #include <eq/client/zoom.h>
00037 #include <eq/net/barrier.h>
00038 #include <eq/base/thread.h>
00039 #include <iostream>
00040 #include <vector>
00041
00042 namespace eq
00043 {
00044 namespace server
00045 {
00046 class CompoundListener;
00047 class CompoundVisitor;
00048 class Frame;
00049 class SwapBarrier;
00050
00054 class Compound
00055 {
00056 public:
00060 EQSERVER_EXPORT Compound();
00061
00065 Compound( const Compound& from, Config* config, Compound* parent );
00066
00068 virtual ~Compound();
00069
00073 enum EyeMask
00074 {
00075 EYE_UNDEFINED = 0,
00076 EYE_CYCLOP_BIT = 1<<eq::EYE_CYCLOP,
00077 EYE_LEFT_BIT = 1<<eq::EYE_LEFT,
00078 EYE_RIGHT_BIT = 1<<eq::EYE_RIGHT
00079 };
00080
00082 enum ColorMask
00083 {
00084 COLOR_MASK_NONE = 0,
00085 COLOR_MASK_RED = 0x02,
00086 COLOR_MASK_GREEN = 0x04,
00087 COLOR_MASK_BLUE = 0x08,
00088 COLOR_MASK_ALL = 0xff
00089 };
00090
00095
00096 enum IAttribute
00097 {
00098 IATTR_STEREO_MODE,
00099 IATTR_STEREO_ANAGLYPH_LEFT_MASK,
00100 IATTR_STEREO_ANAGLYPH_RIGHT_MASK,
00101 IATTR_HINT_OFFSET,
00102 IATTR_FILL1,
00103 IATTR_FILL2,
00104 IATTR_ALL
00105 };
00106
00116 EQSERVER_EXPORT void addChild( Compound* child );
00117
00125 EQSERVER_EXPORT bool removeChild( Compound* child );
00126
00128 bool isLeaf() const { return _children.empty(); }
00129
00131 bool isDestination() const;
00132
00134 const CompoundVector& getChildren() const { return _children; }
00135
00137 Compound* getParent() const
00138 { return _parent; }
00139
00141 Compound* getRoot()
00142 { return _parent ? _parent->getRoot() : this; }
00143 const Compound* getRoot() const
00144 { return _parent ? _parent->getRoot() : this; }
00145
00147 Compound* getNext() const;
00148
00149 Config* getConfig() { return getRoot()->_config; }
00150 const Config* getConfig() const { return getRoot()->_config; }
00151
00152 Node* getNode();
00153
00154 void setName( const std::string& name ) { _name = name; }
00155 const std::string& getName() const { return _name; }
00156
00165 EQSERVER_EXPORT void setChannel( Channel* channel );
00166
00175 EQSERVER_EXPORT Channel* getChannel();
00176 EQSERVER_EXPORT const Channel* getChannel() const;
00177
00178 Window* getWindow();
00179 const Window* getWindow() const;
00180
00181 Pipe* getPipe();
00182 const Pipe* getPipe() const;
00183
00185 Frustum& getFrustum() { return _frustum; }
00186
00188 EQSERVER_EXPORT void addEqualizer( Equalizer* equalizer );
00189
00191 const EqualizerVector& getEqualizers() const
00192 { return _equalizers; }
00193
00204 void setTasks( const uint32_t tasks ) { _data.tasks = tasks; }
00205
00211 void enableTask( const eq::Task task ) { _data.tasks |= task; }
00212
00214 uint32_t getTasks() const { return _data.tasks; }
00215
00222 void setBuffers( const uint32_t buffers ) { _data.buffers = buffers; }
00223
00230 void enableBuffer( const eq::Frame::Buffer buffer )
00231 { _data.buffers |= buffer; }
00232
00234 uint32_t getBuffers() const { return _data.buffers; }
00235
00236 void setViewport( const eq::Viewport& vp ) { _data.vp = vp; }
00237 const eq::Viewport& getViewport() const { return _data.vp; }
00238
00239 void setRange( const eq::Range& range ) { _data.range = range; }
00240 const eq::Range& getRange() const { return _data.range; }
00241
00242 void setPeriod( const uint32_t period ) { _data.period = period; }
00243 uint32_t getPeriod() const { return _data.period; }
00244
00245 void setPhase( const uint32_t phase ) { _data.phase = phase; }
00246 uint32_t getPhase() const { return _data.phase; }
00247
00248 void setPixel( const eq::Pixel& pixel ) { _data.pixel = pixel; }
00249 const eq::Pixel& getPixel() const { return _data.pixel; }
00250
00251 void setSubPixel( const eq::SubPixel& subpixel ) { _data.subpixel = subpixel; }
00252 const eq::SubPixel& getSubPixel() const { return _data.subpixel; }
00253
00254 void setZoom( const eq::Zoom& zoom ) { _data.zoom = zoom; }
00255 const eq::Zoom& getZoom() const { return _data.zoom; }
00256
00257 void setMaxFPS( const float fps ) { _data.maxFPS = fps; }
00258 float getMaxFPS() const { return _data.maxFPS; }
00259
00260 void setUsage( const float usage ) { _usage = usage; }
00261 float getUsage() const { return _usage; }
00262
00263 void setTaskID( const uint32_t id ) { _taskID = id; }
00264 uint32_t getTaskID() const { return _taskID; }
00266
00278 void setSwapBarrier( SwapBarrier* barrier );
00279
00281 const SwapBarrier* getSwapBarrier() const { return _swapBarrier; }
00282
00288 EQSERVER_EXPORT void addInputFrame( Frame* frame );
00289
00291 const FrameVector& getInputFrames() const {return _inputFrames; }
00292
00298 EQSERVER_EXPORT void addOutputFrame( Frame* frame );
00299
00301 const FrameVector& getOutputFrames() const { return _outputFrames; }
00303
00312 uint32_t getInheritBuffers() const { return _inherit.buffers; }
00313 const eq::PixelViewport& getInheritPixelViewport() const
00314 { return _inherit.pvp; }
00315 const Vector4i& getInheritOverdraw() const
00316 { return _inherit.overdraw; }
00317 const eq::Viewport& getInheritViewport() const { return _inherit.vp; }
00318 const eq::Range& getInheritRange() const { return _inherit.range; }
00319 const eq::Pixel& getInheritPixel() const { return _inherit.pixel; }
00320 const eq::SubPixel& getInheritSubPixel() const
00321 { return _inherit.subpixel; }
00322 const eq::Zoom& getInheritZoom() const { return _inherit.zoom; }
00323 uint32_t getInheritPeriod() const { return _inherit.period; }
00324 uint32_t getInheritPhase() const { return _inherit.phase; }
00325 float getInheritMaxFPS() const { return _inherit.maxFPS; }
00326 int32_t getInheritIAttribute( const IAttribute attr ) const
00327 { return _inherit.iAttributes[attr]; }
00328 const FrustumData& getInheritFrustumData() const
00329 { return _inherit.frustumData; }
00330 uint32_t getInheritTasks() const { return _inherit.tasks; }
00331 uint32_t getInheritEyes() const { return _inherit.eyes; }
00332 const Channel* getInheritChannel() const { return _inherit.channel; }
00333
00335 bool testInheritTask( const eq::Task task ) const
00336 { return (_inherit.tasks & task); }
00337
00339 void unsetInheritTask( const eq::Task task )
00340 { _inherit.tasks &= ~task; }
00341
00343 bool testInheritEye( const eq::Eye eye ) const
00344 { return ( _inherit.eyes & (1<<eye) ); }
00346
00356 EQSERVER_EXPORT void setWall( const eq::Wall& wall );
00357
00359 const eq::Wall& getWall() const { return _frustum.getWall(); }
00360
00366 EQSERVER_EXPORT void setProjection( const eq::Projection& projection );
00367
00369 const eq::Projection& getProjection() const
00370 { return _frustum.getProjection(); }
00371
00373 eq::Frustum::Type getFrustumType() const
00374 { return _frustum.getCurrentType(); }
00375
00377 const eq::Frustum& getFrustum() const { return _frustum; }
00378
00380 void updateFrustum();
00381
00383 uint32_t getEyes() const { return _data.eyes; }
00384
00392 void setEyes( const uint32_t eyes ) { _data.eyes = eyes; }
00393
00401 void enableEye( const uint32_t eyes ) { _data.eyes |= eyes; }
00403
00412 EQSERVER_EXPORT VisitorResult accept( CompoundVisitor& visitor ) const;
00414 EQSERVER_EXPORT VisitorResult accept( CompoundVisitor& visitor );
00415
00416
00418 void activate();
00419
00421 void deactivate();
00422
00424 void setActive( const bool active )
00425 { EQASSERT( _active != active ); _active = active; }
00426
00428 bool isActive() const;
00429
00433 void init();
00434
00438 void exit();
00439
00445 void update( const uint32_t frameNumber );
00446
00448 void updateInheritData( const uint32_t frameNumber );
00450
00454 void addListener( CompoundListener* listener );
00456 void removeListener( CompoundListener* listener );
00457
00459 void fireUpdatePre( const uint32_t frameNumber );
00461
00466 void setIAttribute( const IAttribute attr, const int32_t value )
00467 { _data.iAttributes[attr] = value; }
00468 int32_t getIAttribute( const IAttribute attr ) const
00469 { return _data.iAttributes[attr]; }
00470 static const std::string& getIAttributeString( const IAttribute attr )
00471 { return _iAttributeStrings[attr]; }
00473
00474 typedef stde::hash_map<std::string, net::Barrier*> BarrierMap;
00475 typedef stde::hash_map<std::string, Frame*> FrameMap;
00476
00477 private:
00478
00479 std::string _name;
00480
00485 friend class Config;
00486 Config* _config;
00487
00488 Compound* _parent;
00489 CompoundVector _children;
00490
00492 bool _active;
00493
00495 static std::string _iAttributeStrings[IATTR_ALL];
00496
00498 float _usage;
00499
00501 uint32_t _taskID;
00502
00503 struct InheritData
00504 {
00505 InheritData();
00506
00507 Channel* channel;
00508 eq::Viewport vp;
00509 eq::PixelViewport pvp;
00510 Vector4i overdraw;
00511 eq::Range range;
00512 eq::Pixel pixel;
00513 eq::SubPixel subpixel;
00514 FrustumData frustumData;
00515 eq::Zoom zoom;
00516 uint32_t buffers;
00517 uint32_t eyes;
00518 uint32_t tasks;
00519 uint32_t period;
00520 uint32_t phase;
00521 int32_t iAttributes[IATTR_ALL];
00522 float maxFPS;
00523 bool active;
00524
00525 union
00526 {
00527 char dummy[16];
00528 };
00529 };
00530
00531 InheritData _data;
00532 InheritData _inherit;
00533
00535 Frustum _frustum;
00536
00537 typedef std::vector< CompoundListener* > CompoundListeners;
00538 CompoundListeners _listeners;
00539
00540 EqualizerVector _equalizers;
00541
00542 SwapBarrier* _swapBarrier;
00543
00544 FrameVector _inputFrames;
00545 FrameVector _outputFrames;
00546
00547 union
00548 {
00549 char dummy[64];
00550 };
00551
00552 CHECK_THREAD_DECLARE( _serverThread );
00553
00554
00555 void _updateOverdraw( Wall& wall );
00556 void _updateInheritPVP();
00557 void _updateInheritOverdraw();
00558
00559 void _setDefaultFrameName( Frame* frame );
00560
00561 void _fireChildAdded( Compound* child );
00562 void _fireChildRemove( Compound* child );
00563 };
00564
00565 std::ostream& operator << ( std::ostream& os, const Compound* compound );
00566 }
00567 }
00568 #endif // EQSERVER_COMPOUND_H