Equalizer
1.4.1
|
00001 00002 /* Copyright (c) 2010-2011, Stefan Eilemann <eile@eyescale.ch> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #ifndef EQFABRIC_CANVAS_H 00019 #define EQFABRIC_CANVAS_H 00020 00021 #include <eq/fabric/types.h> 00022 #include <eq/fabric/visitorResult.h> // enum 00023 #include <eq/fabric/frustum.h> // base class 00024 #include <eq/fabric/object.h> // base class 00025 #include <eq/fabric/swapBarrier.h> // RefPtr member 00026 00027 #include <string> 00028 00029 namespace eq 00030 { 00031 namespace fabric 00032 { 00034 template< class CFG, class C, class S, class L > 00035 class Canvas : public Object, public Frustum 00036 { 00037 public: 00038 typedef std::vector< C* > Canvases; 00039 typedef std::vector< S* > Segments; 00040 typedef std::vector< L* > Layouts; 00041 00042 typedef ElementVisitor< C, LeafVisitor< S > > Visitor; 00043 00047 CFG* getConfig() { return _config; } 00049 const CFG* getConfig() const { return _config; } 00050 00052 CanvasPath getPath() const; 00053 00055 uint32_t getActiveLayoutIndex() const { return _data.activeLayout; } 00056 00058 EQFABRIC_INL const L* getActiveLayout() const; 00059 00061 const Segments& getSegments() const { return _segments; } 00062 00064 S* findSegment( const std::string& name ); 00065 00067 const S* findSegment( const std::string& name ) const; 00068 00070 const Layouts& getLayouts() const { return _layouts; } 00071 00073 EQFABRIC_INL void addLayout( L* layout ); 00074 00076 EQFABRIC_INL bool removeLayout( L* layout ); 00077 00086 EQFABRIC_INL void setSwapBarrier( SwapBarrierPtr barrier ); 00087 00089 SwapBarrierConstPtr getSwapBarrier() const { return _swapBarrier; } 00090 00092 SwapBarrierPtr getSwapBarrier() { return _swapBarrier; } 00093 00095 EQFABRIC_INL virtual void setWall( const Wall& wall ); 00096 00098 EQFABRIC_INL virtual void setProjection( const Projection& ); 00099 00101 EQFABRIC_INL virtual void unsetFrustum(); 00103 00111 EQFABRIC_INL virtual bool useLayout( const uint32_t index ); 00112 00120 EQFABRIC_INL VisitorResult accept( Visitor& visitor ); 00121 00123 EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const; 00124 00125 EQFABRIC_INL virtual void backup(); 00126 EQFABRIC_INL virtual void restore(); 00127 00128 void create( S** segment ); 00129 void release( S* segment ); 00130 00131 00132 protected: 00134 EQFABRIC_INL Canvas( CFG* config ); 00135 00137 EQFABRIC_INL virtual ~Canvas(); 00138 00140 EQFABRIC_INL virtual void attach( const UUID& id, 00141 const uint32_t instanceID ); 00142 00144 EQFABRIC_INL void serialize( co::DataOStream& os, 00145 const uint64_t dirtyBits ); 00147 EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 00148 const uint64_t dirtyBits ); 00149 00150 EQFABRIC_INL virtual void notifyDetach(); 00151 00153 EQFABRIC_INL virtual void setDirty( const uint64_t bits ); 00154 00156 virtual void activateLayout( const uint32_t index ) 00157 { _data.activeLayout = index; } 00158 00159 private: 00161 CFG* const _config; 00162 00163 struct BackupData 00164 { 00165 BackupData() : activeLayout( 0 ) {} 00166 00168 uint32_t activeLayout; 00169 } 00170 _data, _backup; 00171 00173 Layouts _layouts; 00174 00176 Segments _segments; 00177 00178 SwapBarrierPtr _swapBarrier; 00179 00180 struct Private; 00181 Private* _private; // placeholder for binary-compatible changes 00182 00183 enum DirtyBits 00184 { 00185 DIRTY_LAYOUT = Object::DIRTY_CUSTOM << 0, 00186 DIRTY_SEGMENTS = Object::DIRTY_CUSTOM << 1, 00187 DIRTY_LAYOUTS = Object::DIRTY_CUSTOM << 2, 00188 DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3, 00189 DIRTY_CANVAS_BITS = DIRTY_LAYOUT | DIRTY_SEGMENTS | DIRTY_LAYOUTS | 00190 DIRTY_FRUSTUM | DIRTY_OBJECT_BITS 00191 }; 00192 00194 virtual uint64_t getRedistributableBits() const 00195 { return DIRTY_CANVAS_BITS; } 00196 00197 template< class, class, class > friend class Segment; 00198 friend class Object; 00199 void _addChild( S* segment ); 00200 bool _removeChild( S* segment ); 00201 00203 EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation ); 00204 bool _mapViewObjects(); 00205 00206 typedef co::CommandFunc< Canvas< CFG, C, S, L > > CmdFunc; 00207 bool _cmdNewSegment( co::Command& command ); 00208 bool _cmdNewSegmentReply( co::Command& command ); 00209 }; 00210 00211 template< class CFG, class C, class S, class L > 00212 std::ostream& operator << ( std::ostream&, const Canvas< CFG, C, S, L >& ); 00213 } 00214 } 00215 #endif // EQFABRIC_CANVAS_H