Equalizer 1.0

include/eq/fabric/pipe.h

00001 
00002 /* Copyright (c) 2010-2011, Stefan Eilemann <eile@equalizergraphics.com>
00003  *                    2010, Cedric Stalder <cedric.stalder@gmail.com> 
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQFABRIC_PIPE_H
00020 #define EQFABRIC_PIPE_H
00021 
00022 #include <eq/fabric/object.h>        // base class
00023 #include <eq/fabric/pixelViewport.h> // property
00024 #include <eq/fabric/types.h>
00025 #include <eq/fabric/visitorResult.h> // enum
00026 
00027 #include <co/types.h>            // LocalNodePtr
00028 
00029 namespace eq
00030 {
00031 namespace fabric
00032 {
00034     template< class N, class P, class W, class V > class Pipe : public Object
00035     {
00036     public:
00038         typedef std::vector< W* >  Windows; 
00039         
00041         N*       getNode()       { return _node; }
00043         const N* getNode() const { return _node; }
00044 
00046         const Windows& getWindows() const { return _windows; }
00047 
00059         uint32_t getPort() const { return _port; }
00060         
00061         EQFABRIC_INL void setPort( const uint32_t port ); 
00062 
00074         uint32_t getDevice() const { return _device; }
00075 
00076         EQFABRIC_INL void setDevice( const uint32_t device ); 
00077 
00079         const PixelViewport& getPixelViewport() const { return _data.pvp; }
00080 
00090         EQFABRIC_INL void setPixelViewport( const PixelViewport& pvp );
00091 
00093         void notifyPixelViewportChanged();
00094 
00096         EQFABRIC_INL PipePath getPath() const;
00097 
00105         EQFABRIC_INL VisitorResult accept( V& visitor );
00106 
00108         EQFABRIC_INL VisitorResult accept( V& visitor ) const;
00110 
00114         enum IAttribute
00115         {
00116             // Note: also update string array initialization in pipe.cpp
00117             IATTR_HINT_THREAD,   
00118             IATTR_HINT_CUDA_GL_INTEROP, 
00119             IATTR_LAST,
00120             IATTR_ALL = IATTR_LAST + 5
00121         };
00122 
00124         EQFABRIC_INL void setIAttribute( const IAttribute attr,
00125                                             const int32_t value );
00126 
00128         int32_t getIAttribute( const IAttribute attr ) const
00129             { return _iAttributes[attr]; }
00130 
00132         bool isThreaded() const
00133             { return (getIAttribute( IATTR_HINT_THREAD ) == 1 ); }
00134         
00136         EQFABRIC_INL static const std::string& getIAttributeString(
00137                                                       const IAttribute attr );
00139 
00140         EQFABRIC_INL virtual void backup(); 
00141         EQFABRIC_INL virtual void restore(); 
00142         void create( W** window ); 
00143         void release( W* window ); 
00144         virtual void output( std::ostream& ) const {} 
00145 
00146     protected:
00147         //-------------------- Members --------------------
00148 
00150         Pipe( N* parent );
00151         EQFABRIC_INL virtual ~Pipe( ); 
00152 
00153         virtual void attach( const co::base::UUID& id,
00154                              const uint32_t instanceID ); 
00155 
00156         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00157                                              const uint64_t dirtyBits );
00159         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00160                                                const uint64_t dirtyBits );
00161 
00162         EQFABRIC_INL virtual void notifyDetach(); 
00163 
00165         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00166 
00168         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00169 
00170         W* _findWindow( const co::base::UUID& id ); 
00171 
00172         enum DirtyBits
00173         {
00174             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00175             DIRTY_WINDOWS         = Object::DIRTY_CUSTOM << 1,
00176             DIRTY_PIXELVIEWPORT   = Object::DIRTY_CUSTOM << 2,
00177             DIRTY_MEMBER          = Object::DIRTY_CUSTOM << 3,
00178             DIRTY_PIPE_BITS =
00179                 DIRTY_ATTRIBUTES | DIRTY_WINDOWS | DIRTY_PIXELVIEWPORT |
00180                 DIRTY_MEMBER | DIRTY_OBJECT_BITS
00181         };
00182 
00184         virtual uint64_t getRedistributableBits() const
00185             { return DIRTY_PIPE_BITS; }
00186 
00187     private:
00189         N* const _node;
00190         
00192         Windows _windows;
00193 
00195         int32_t _iAttributes[IATTR_ALL];
00196 
00198         uint32_t _port;
00199 
00201         uint32_t _device;
00202 
00203         struct BackupData
00204         {
00206             PixelViewport pvp;
00207         }
00208             _data, _backup;
00209 
00210         struct Private;
00211         Private* _private; // placeholder for binary-compatible changes
00212 
00213         void _addWindow( W* window );
00214         EQFABRIC_INL bool _removeWindow( W* window );
00215         template< class, class, class > friend class Window;
00216 
00218         EQFABRIC_INL virtual uint32_t commitNB( const uint32_t incarnation );
00219         bool _mapNodeObjects() { return _node->_mapNodeObjects(); }
00220 
00221         typedef co::CommandFunc< Pipe< N, P, W, V > > CmdFunc;
00222         bool _cmdNewWindow( co::Command& command );
00223         bool _cmdNewWindowReply( co::Command& command );
00224     };
00225 
00226     template< class N, class P, class W, class V > EQFABRIC_INL
00227     std::ostream& operator << ( std::ostream&, const Pipe< N, P, W, V >& );
00228 }
00229 }
00230 
00231 #endif // EQFABRIC_PIPE_H
00232 
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3