LCOV - code coverage report
Current view: top level - eq/fabric - pipe.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 13 16 81.2 %
Date: 2016-09-29 05:02:09 Functions: 20 39 51.3 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2015, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Cedric Stalder <cedric.stalder@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQFABRIC_PIPE_H
      20             : #define EQFABRIC_PIPE_H
      21             : 
      22             : #include <eq/fabric/object.h>        // base class
      23             : #include <eq/fabric/pixelViewport.h> // property
      24             : #include <eq/fabric/types.h>
      25             : 
      26             : namespace eq
      27             : {
      28             : namespace fabric
      29             : {
      30             : /** Base data transport class for pipes. @sa eq::Pipe */
      31             : template< class N, class P, class W, class V > class Pipe : public Object
      32             : {
      33             : public:
      34             :     /** A vector of pointers to windows. @version 1.0 */
      35             :     typedef std::vector< W* >  Windows;
      36             : 
      37             :     /** @name Data Access */
      38             :     //@{
      39             :     /** @return the parent node of this pipe. @version 1.0 */
      40        3059 :     N*       getNode()       { return _node; }
      41             :     /** @return the parent node of this pipe. @version 1.0 */
      42          92 :     const N* getNode() const { return _node; }
      43             : 
      44             :     /** @return the vector of child windows. @version 1.0 */
      45       29157 :     const Windows& getWindows() const { return _windows; }
      46             : 
      47             :     /**
      48             :      * Returns the port number of this pipe.
      49             :      *
      50             :      * The port number identifies the X server for systems using the X11/GLX
      51             :      * window system, i.e., the :<strong>&lt;port&gt;</strong>.&lt;screen&gt; of
      52             :      * the DISPLAY name. It currently has no meaning on all other systems.
      53             :      *
      54             :      * @return the port number of this pipe, or LB_UNDEFINED_UINT32.
      55             :      * @version 1.0
      56             :      */
      57         575 :     uint32_t getPort() const { return _port; }
      58             : 
      59             :     EQFABRIC_INL void setPort( const uint32_t port ); //!< @internal
      60             : 
      61             :     /**
      62             :      * Returns the device number of this pipe.
      63             :      *
      64             :      * The device number identifies the X screen for systems using the X11/GLX
      65             :      * window system, or the number of the virtual screen for the AGL window
      66             :      * system. On Windows systems it identifies the graphics adapter. Normally
      67             :      * the device identifies a GPU.
      68             :      *
      69             :      * @return the device number of this pipe, or LB_UNDEFINED_UINT32.
      70             :      * @version 1.0
      71             :      */
      72         651 :     uint32_t getDevice() const { return _device; }
      73             : 
      74             :     EQFABRIC_INL void setDevice( const uint32_t device ); //!< @internal
      75             : 
      76             :     /** @return the pixel viewport. @version 1.0 */
      77        3352 :     const PixelViewport& getPixelViewport() const { return _data.pvp; }
      78             : 
      79             :     /**
      80             :      * Set the pipe's pixel viewport.
      81             :      *
      82             :      * If invalid, the OSPipe has to set it to the device viewport during
      83             :      * configInit().
      84             :      *
      85             :      * @param pvp the viewport in pixels.
      86             :      * @version 1.0
      87             :      */
      88             :     EQFABRIC_INL void setPixelViewport( const PixelViewport& pvp );
      89             : 
      90             :     /** @internal Notify this pipe that the viewport has changed. */
      91             :     void notifyPixelViewportChanged();
      92             : 
      93             :     /** @internal @return the index path to this pipe. */
      94             :     EQFABRIC_INL PipePath getPath() const;
      95             : 
      96             :     /**
      97             :      * Perform a depth-first traversal of this pipe.
      98             :      *
      99             :      * @param visitor the visitor.
     100             :      * @return the result of the visitor traversal.
     101             :      * @version 1.0
     102             :      */
     103             :     EQFABRIC_INL VisitorResult accept( V& visitor );
     104             : 
     105             :     /** Const-version of accept(). @version 1.0 */
     106             :     EQFABRIC_INL VisitorResult accept( V& visitor ) const;
     107             :     //@}
     108             : 
     109             :     /** @name Attributes */
     110             :     //@{
     111             :     /** Pipe attributes. @version 1.0 */
     112             :     enum IAttribute
     113             :     {
     114             :         // Note: also update string array initialization in pipe.cpp
     115             :         IATTR_HINT_THREAD,   //!< Execute tasks in separate thread (default)
     116             :         IATTR_HINT_AFFINITY, //!< Bind render thread to subset of cores
     117             :         IATTR_LAST,
     118             :         IATTR_ALL = IATTR_LAST + 5
     119             :     };
     120             : 
     121             :     /** @internal Set a pipe attribute. */
     122             :     EQFABRIC_INL void setIAttribute( const IAttribute attr,
     123             :                                      const int32_t value );
     124             : 
     125             :     /** @return the value of a pipe integer attribute. @version 1.0 */
     126        1153 :     int32_t getIAttribute( const IAttribute attr ) const
     127        1153 :     { return _iAttributes[attr]; }
     128             : 
     129             :     /** @internal @return true if tasks are executed in a separate thread.*/
     130           4 :     bool isThreaded() const
     131           4 :     { return (getIAttribute( IATTR_HINT_THREAD ) == 1 ); }
     132             : 
     133             :     /** @internal @return the name of a pipe attribute. */
     134             :     EQFABRIC_INL static const std::string& getIAttributeString(
     135             :         const IAttribute attr );
     136             :     //@}
     137             : 
     138             :     /** @name internal */
     139             :     //@{
     140             :     EQFABRIC_INL virtual void backup(); //!< @internal
     141             :     EQFABRIC_INL virtual void restore(); //!< @internal
     142             :     void create( W** window ); //!< @internal
     143             :     void release( W* window ); //!< @internal
     144           0 :     virtual void output( std::ostream& ) const {} //!< @internal
     145             :     /** @internal */
     146             :     EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
     147             :                                            CO_COMMIT_NEXT );
     148             :     //@}
     149             : 
     150             : protected:
     151             :     /** @internal Construct a new pipe. */
     152             :     explicit Pipe( N* parent );
     153             :     EQFABRIC_INL virtual ~Pipe( ); //!< @internal
     154             : 
     155             :     virtual void attach( const uint128_t& id,
     156             :                          const uint32_t instanceID ); //!< @internal
     157             :     /** @internal */
     158             :     EQFABRIC_INL virtual void serialize( co::DataOStream& os,
     159             :                                          const uint64_t dirtyBits );
     160             :     /** @internal */
     161             :     EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
     162             :                                            const uint64_t dirtyBits );
     163             : 
     164             :     EQFABRIC_INL virtual void notifyDetach(); //!< @internal
     165             : 
     166             :     /** @internal @sa Serializable::setDirty() */
     167             :     EQFABRIC_INL virtual void setDirty( const uint64_t bits );
     168             : 
     169             :     /** @internal */
     170           6 :     virtual ChangeType getChangeType() const { return UNBUFFERED; }
     171             : 
     172             :     W* _findWindow( const uint128_t& id ); //!< @internal
     173             : 
     174             :     enum DirtyBits
     175             :     {
     176             :         DIRTY_ATTRIBUTES      = Object::DIRTY_CUSTOM << 0,
     177             :         DIRTY_WINDOWS         = Object::DIRTY_CUSTOM << 1,
     178             :         DIRTY_PIXELVIEWPORT   = Object::DIRTY_CUSTOM << 2,
     179             :         DIRTY_MEMBER          = Object::DIRTY_CUSTOM << 3,
     180             :         DIRTY_PIPE_BITS =
     181             :         DIRTY_ATTRIBUTES | DIRTY_WINDOWS | DIRTY_PIXELVIEWPORT |
     182             :         DIRTY_MEMBER | DIRTY_OBJECT_BITS
     183             :     };
     184             : 
     185             :     /** @internal @return the bits to be re-committed by the master. */
     186           0 :     virtual uint64_t getRedistributableBits() const
     187           0 :         { return DIRTY_PIPE_BITS; }
     188             : 
     189             : private:
     190             :     /** The parent node. */
     191             :     N* const _node;
     192             : 
     193             :     /** The list of windows. */
     194             :     Windows _windows;
     195             : 
     196             :     /** Integer attributes. */
     197             :     int32_t _iAttributes[IATTR_ALL];
     198             : 
     199             :     /** The display (GLX) or ignored (Win32, AGL). */
     200             :     uint32_t _port;
     201             : 
     202             :     /** The screen (GLX), GPU (Win32) or virtual screen (AGL). */
     203             :     uint32_t _device;
     204             : 
     205        2474 :     struct BackupData
     206             :     {
     207             :         /** The size (and location) of the pipe. */
     208             :         PixelViewport pvp;
     209             :     }
     210             :         _data, _backup;
     211             : 
     212             :     struct Private;
     213             :     Private* _private; // placeholder for binary-compatible changes
     214             : 
     215             :     void _addWindow( W* window );
     216             :     EQFABRIC_INL bool _removeWindow( W* window );
     217             :     template< class, class, class, class > friend class Window;
     218             : 
     219             :     /** @internal */
     220           6 :     bool _mapNodeObjects() { return _node->_mapNodeObjects(); }
     221             : 
     222             :     typedef co::CommandFunc< Pipe< N, P, W, V > > CmdFunc;
     223             :     bool _cmdNewWindow( co::ICommand& command );
     224             :     bool _cmdNewWindowReply( co::ICommand& command );
     225             : };
     226             : 
     227             : template< class N, class P, class W, class V > EQFABRIC_INL
     228             : std::ostream& operator << ( std::ostream&, const Pipe< N, P, W, V >& );
     229             : }
     230             : }
     231             : 
     232             : #endif // EQFABRIC_PIPE_H

Generated by: LCOV version 1.11