Equalizer 1.0

fabric/canvas.h

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 
00026 #include <string>
00027 
00028 namespace eq
00029 {
00030 namespace fabric
00031 {
00032     struct CanvasPath;
00033 
00035     template< class CFG, class C, class S, class L >
00036     class Canvas : public Object, public Frustum
00037     {
00038     public:
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         uint32_t getActiveLayoutIndex() const { return _data.activeLayout; }
00053 
00055         EQFABRIC_INL const L* getActiveLayout() const;
00056 
00058         const Segments& getSegments() const { return _segments; }        
00059 
00061         S* findSegment( const std::string& name );
00062 
00064         const Layouts& getLayouts() const { return _layouts; }        
00065 
00067         EQFABRIC_INL void addLayout( L* layout );
00068 
00070         EQFABRIC_INL bool removeLayout( L* layout );
00071 
00073         EQFABRIC_INL virtual void setWall( const Wall& wall );
00074         
00076         EQFABRIC_INL virtual void setProjection( const Projection& );
00077 
00079         EQFABRIC_INL virtual void unsetFrustum();
00081 
00085         EQFABRIC_INL virtual void useLayout( const uint32_t index );
00086 
00094         EQFABRIC_INL VisitorResult accept( Visitor& visitor );
00095 
00097         EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
00098 
00099         EQFABRIC_INL virtual void backup(); 
00100         EQFABRIC_INL virtual void restore(); 
00101 
00102         void create( S** segment ); 
00103         void release( S* segment ); 
00104 
00105 
00106     protected:
00108         EQFABRIC_INL Canvas( CFG* config );
00109 
00111         EQFABRIC_INL virtual ~Canvas();
00112 
00114         EQFABRIC_INL virtual void attach( const co::base::UUID& id,
00115                                           const uint32_t instanceID );
00116 
00118         EQFABRIC_INL void serialize( co::DataOStream& os, 
00119                                         const uint64_t dirtyBits );
00121         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00122                                                   const uint64_t dirtyBits );
00123 
00124         EQFABRIC_INL virtual void notifyDetach(); 
00125 
00127         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00128 
00130         virtual void activateLayout( const uint32_t index )
00131             { _data.activeLayout = index; }
00132 
00133     private:
00135         CFG* const _config;
00136 
00137         struct BackupData
00138         {
00139             BackupData() : activeLayout( 0 ) {}
00140 
00142             uint32_t activeLayout;
00143         }
00144             _data, _backup;
00145 
00147         Layouts _layouts;
00148 
00150         Segments _segments;
00151 
00152         struct Private;
00153         Private* _private; // placeholder for binary-compatible changes
00154 
00155         enum DirtyBits
00156         {
00157             DIRTY_LAYOUT    = Object::DIRTY_CUSTOM << 0,
00158             DIRTY_SEGMENTS  = Object::DIRTY_CUSTOM << 1,
00159             DIRTY_LAYOUTS   = Object::DIRTY_CUSTOM << 2,
00160             DIRTY_FRUSTUM   = Object::DIRTY_CUSTOM << 3,
00161             DIRTY_CANVAS_BITS = DIRTY_LAYOUT | DIRTY_SEGMENTS | DIRTY_LAYOUTS |
00162                                 DIRTY_FRUSTUM | DIRTY_OBJECT_BITS
00163         };
00164 
00166         virtual uint64_t getRedistributableBits() const
00167             { return DIRTY_CANVAS_BITS; }
00168 
00169         template< class, class, class > friend class Segment;
00170         friend class Object;
00171         void _addChild( S* segment ); 
00172         bool _removeChild( S* segment ); 
00173 
00175         EQFABRIC_INL virtual uint32_t commitNB( const uint32_t incarnation );
00176         bool _mapViewObjects();
00177 
00178         typedef co::CommandFunc< Canvas< CFG, C, S, L > > CmdFunc;
00179         bool _cmdNewSegment( co::Command& command );
00180         bool _cmdNewSegmentReply( co::Command& command );
00181     };
00182 
00183     template< class CFG, class C, class S, class L >
00184     std::ostream& operator << ( std::ostream&, const Canvas< CFG, C, S, L >& );
00185 }
00186 }
00187 #endif // EQFABRIC_CANVAS_H
Generated on Sun May 8 2011 19:11:05 for Equalizer 1.0 by  doxygen 1.7.3