Equalizer  1.4.1
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         
00043         N*       getNode()       { return _node; }
00045         const N* getNode() const { return _node; }
00046 
00048         const Windows& getWindows() const { return _windows; }
00049 
00061         uint32_t getPort() const { return _port; }
00062         
00063         EQFABRIC_INL void setPort( const uint32_t port ); 
00064 
00076         uint32_t getDevice() const { return _device; }
00077 
00078         EQFABRIC_INL void setDevice( const uint32_t device ); 
00079 
00081         const PixelViewport& getPixelViewport() const { return _data.pvp; }
00082 
00092         EQFABRIC_INL void setPixelViewport( const PixelViewport& pvp );
00093 
00095         void notifyPixelViewportChanged();
00096 
00098         EQFABRIC_INL PipePath getPath() const;
00099 
00107         EQFABRIC_INL VisitorResult accept( V& visitor );
00108 
00110         EQFABRIC_INL VisitorResult accept( V& visitor ) const;
00112 
00116         enum IAttribute
00117         {
00118             // Note: also update string array initialization in pipe.cpp
00119             IATTR_HINT_THREAD,   
00120             IATTR_HINT_AFFINITY, 
00121             IATTR_HINT_CUDA_GL_INTEROP, 
00122             IATTR_LAST,
00123             IATTR_ALL = IATTR_LAST + 5
00124         };
00125 
00127         EQFABRIC_INL void setIAttribute( const IAttribute attr,
00128                                          const int32_t value );
00129 
00131         int32_t getIAttribute( const IAttribute attr ) const
00132             { return _iAttributes[attr]; }
00133 
00135         bool isThreaded() const
00136             { return (getIAttribute( IATTR_HINT_THREAD ) == 1 ); }
00137         
00139         EQFABRIC_INL static const std::string& getIAttributeString(
00140                                                       const IAttribute attr );
00142 
00145         EQFABRIC_INL virtual void backup(); 
00146         EQFABRIC_INL virtual void restore(); 
00147         void create( W** window ); 
00148         void release( W* window ); 
00149         virtual void output( std::ostream& ) const {} 
00150 
00151         EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
00152                                                CO_COMMIT_NEXT );
00154 
00155     protected:
00156         //-------------------- Members --------------------
00157 
00159         Pipe( N* parent );
00160         EQFABRIC_INL virtual ~Pipe( ); 
00161 
00162         virtual void attach( const UUID& id,
00163                              const uint32_t instanceID ); 
00164 
00165         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00166                                              const uint64_t dirtyBits );
00168         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00169                                                const uint64_t dirtyBits );
00170 
00171         EQFABRIC_INL virtual void notifyDetach(); 
00172 
00174         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00175 
00177         virtual ChangeType getChangeType() const { return UNBUFFERED; }
00178 
00179         W* _findWindow( const UUID& id ); 
00180 
00181         enum DirtyBits
00182         {
00183             DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
00184             DIRTY_WINDOWS         = Object::DIRTY_CUSTOM << 1,
00185             DIRTY_PIXELVIEWPORT   = Object::DIRTY_CUSTOM << 2,
00186             DIRTY_MEMBER          = Object::DIRTY_CUSTOM << 3,
00187             DIRTY_PIPE_BITS =
00188                 DIRTY_ATTRIBUTES | DIRTY_WINDOWS | DIRTY_PIXELVIEWPORT |
00189                 DIRTY_MEMBER | DIRTY_OBJECT_BITS
00190         };
00191 
00193         virtual uint64_t getRedistributableBits() const
00194             { return DIRTY_PIPE_BITS; }
00195 
00196     private:
00198         N* const _node;
00199         
00201         Windows _windows;
00202 
00204         int32_t _iAttributes[IATTR_ALL];
00205 
00207         uint32_t _port;
00208 
00210         uint32_t _device;
00211 
00212         struct BackupData
00213         {
00215             PixelViewport pvp;
00216         }
00217             _data, _backup;
00218 
00219         struct Private;
00220         Private* _private; // placeholder for binary-compatible changes
00221 
00222         void _addWindow( W* window );
00223         EQFABRIC_INL bool _removeWindow( W* window );
00224         template< class, class, class > friend class Window;
00225 
00227         bool _mapNodeObjects() { return _node->_mapNodeObjects(); }
00228 
00229         typedef co::CommandFunc< Pipe< N, P, W, V > > CmdFunc;
00230         bool _cmdNewWindow( co::Command& command );
00231         bool _cmdNewWindowReply( co::Command& command );
00232     };
00233 
00234     template< class N, class P, class W, class V > EQFABRIC_INL
00235     std::ostream& operator << ( std::ostream&, const Pipe< N, P, W, V >& );
00236 }
00237 }
00238 
00239 #endif // EQFABRIC_PIPE_H
00240 
Generated on Mon Nov 26 2012 14:41:49 for Equalizer 1.4.1 by  doxygen 1.7.6.1