LCOV - code coverage report
Current view: top level - eq/fabric - window.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 12 13 92.3 %
Date: 2014-06-18 Functions: 17 24 70.8 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2014, Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *                    2010, Cedric Stalder <cedric.stalder@gmail.com>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef EQFABRIC_WINDOW_H
      21             : #define EQFABRIC_WINDOW_H
      22             : 
      23             : #include <eq/fabric/object.h>        // base class
      24             : 
      25             : #include <eq/fabric/drawableConfig.h> // enum
      26             : #include <eq/fabric/paths.h>
      27             : #include <eq/fabric/pixelViewport.h>
      28             : #include <eq/fabric/viewport.h>
      29             : #include <eq/fabric/windowSettings.h>
      30             : 
      31             : namespace eq
      32             : {
      33             : namespace fabric
      34             : {
      35             :     /** Base data transport class for windows. @sa eq::Window */
      36             :     template< class P, class W, class C, class Settings = WindowSettings >
      37             :     class Window : public Object
      38             :     {
      39             :     public:
      40             :         /** A vector of pointers to channels. @version 1.0 */
      41             :         typedef std::vector< C* >  Channels;
      42             :         /** The Window visitor type. @version 1.0 */
      43             :         typedef ElementVisitor< W, LeafVisitor< C > > Visitor;
      44             : 
      45             :         /** @name Data Access */
      46             :         //@{
      47             :         /** @internal Initialize this window (calls virtual methods). */
      48             :         void init();
      49             : 
      50             :         /** @return the parent Pipe of this window. @version 1.0 */
      51          63 :         const P* getPipe() const { return _pipe; }
      52             :         /** @return the parent Pipe of this window. @version 1.0 */
      53        2720 :         P* getPipe() { return _pipe; }
      54             : 
      55             :         /** @return a vector of all child channels of this window.  */
      56       19884 :         const Channels& getChannels() const { return _channels; }
      57             : 
      58             :         /** @return the window's drawable configuration. @version 1.0 */
      59         245 :         const DrawableConfig& getDrawableConfig() const
      60         245 :             { return _data.drawableConfig; }
      61             : 
      62             :         /**
      63             :          * @return the window's pixel viewport wrt the parent pipe.
      64             :          * @version 1.0 */
      65             :         EQFABRIC_INL const PixelViewport& getPixelViewport() const;
      66             : 
      67             :         /**
      68             :          * @return the window's fractional viewport wrt the parent pipe.
      69             :          * @version 1.0
      70             :          */
      71         409 :         const Viewport& getViewport() const { return _data.vp; }
      72             : 
      73             :         /** Set the window's name/caption. @version 1.7.2 */
      74             :         EQFABRIC_INL void setName( const std::string& name ) final;
      75             : 
      76             :         /**
      77             :          * Set the window's pixel viewport wrt its parent pipe.
      78             :          *
      79             :          * Updates the fractional viewport of the window and its channels
      80             :          * accordingly.
      81             :          *
      82             :          * @param pvp the viewport in pixels.
      83             :          * @version 1.0
      84             :          */
      85             :         EQFABRIC_INL virtual void setPixelViewport( const PixelViewport& pvp );
      86             : 
      87             :         /**
      88             :          * Set the window's viewport wrt its parent pipe.
      89             :          *
      90             :          * Updates the fractional pixel viewport of the window and its channels
      91             :          * accordingly.
      92             :          *
      93             :          * @param vp the fractional viewport.
      94             :          * @version 1.0
      95             :          */
      96             :         EQFABRIC_INL void setViewport( const Viewport& vp );
      97             : 
      98             :         /** @return true if a viewport was specified last. @version 1.0 */
      99         409 :         bool hasFixedViewport( ) const { return _data.fixedVP; }
     100             : 
     101             :         /** @internal Notify this window that the viewport has changed. */
     102             :         virtual void notifyViewportChanged();
     103             : 
     104             :         /**
     105             :          * Perform a depth-first traversal of this window.
     106             :          *
     107             :          * @param visitor the visitor.
     108             :          * @return the result of the visitor traversal.
     109             :          * @version 1.0
     110             :          */
     111             :         EQFABRIC_INL VisitorResult accept( Visitor& visitor );
     112             : 
     113             :         /** Const-version of accept(). @version 1.0 */
     114             :         EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
     115             : 
     116             :         //@}
     117             : 
     118             :         /** @name Attributes */
     119             :         //@{
     120             :         /** @return the settings of this window. @version 1.7.2 */
     121             :         EQFABRIC_INL const Settings& getSettings() const;
     122             : 
     123             :         /** Set a window attribute. @version 1.0 */
     124             :         EQFABRIC_INL void setIAttribute( const WindowSettings::IAttribute attr,
     125             :                                          const int32_t value );
     126             : 
     127             :         /** @return the value of a window attribute. @version 1.0 */
     128             :         EQFABRIC_INL int32_t
     129             :         getIAttribute( const WindowSettings::IAttribute attr ) const;
     130             : 
     131             :         /** @internal @return the name of a window attribute. */
     132             :         EQFABRIC_INL static const std::string&
     133             :         getIAttributeString( const WindowSettings::IAttribute attr );
     134             :         //@}
     135             : 
     136             :         /** @internal @return the index path to this window. */
     137             :         EQFABRIC_INL WindowPath getPath() const;
     138             : 
     139             :         /** @name internal */
     140             :         //@{
     141             :         EQFABRIC_INL virtual void backup(); //!< @internal
     142             :         EQFABRIC_INL virtual void restore(); //!< @internal
     143             :         void create( C** channel ); //!< @internal
     144             :         void release( C* channel ); //!< @internal
     145           0 :         virtual void output( std::ostream& ) const {} //!< @internal
     146             :         /** @internal */
     147             :         EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
     148             :                                                CO_COMMIT_NEXT );
     149             :         //@}
     150             : 
     151             :     protected:
     152             :         /** @internal Construct a new window. */
     153             :         Window( P* parent );
     154             : 
     155             :         EQFABRIC_INL virtual ~Window(); //!< @internal
     156             :         /** @internal */
     157             :         virtual void attach( const uint128_t& id,
     158             :                              const uint32_t instanceID );
     159             : 
     160             :         /** @internal */
     161             :         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
     162             :                                                 const uint64_t dirtyBits );
     163             :         /** @internal */
     164             :         EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
     165             :                                                   const uint64_t dirtyBits );
     166             : 
     167             :         EQFABRIC_INL virtual void notifyDetach(); //!< @internal
     168             : 
     169             :         /** @sa Serializable::setDirty() @internal */
     170             :         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
     171             : 
     172             :         /** @internal */
     173             :         void _setDrawableConfig( const DrawableConfig& drawableConfig );
     174             : 
     175             :         /** @internal */
     176             :         EQFABRIC_INL Settings& _getSettings();
     177             : 
     178             :         /** @internal */
     179          38 :         virtual ChangeType getChangeType() const { return UNBUFFERED; }
     180             : 
     181             :         C* _findChannel( const uint128_t& id ); //!< @internal
     182             : 
     183             :         /** @internal */
     184             :         enum DirtyBits
     185             :         {
     186             :             DIRTY_SETTINGS        = Object::DIRTY_CUSTOM << 0,
     187             :             DIRTY_CHANNELS        = Object::DIRTY_CUSTOM << 1,
     188             :             DIRTY_VIEWPORT        = Object::DIRTY_CUSTOM << 2,
     189             :             DIRTY_DRAWABLECONFIG  = Object::DIRTY_CUSTOM << 3,
     190             :             DIRTY_WINDOW_BITS =
     191             :                 DIRTY_SETTINGS | DIRTY_CHANNELS | DIRTY_VIEWPORT |
     192             :                 DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
     193             :         };
     194             : 
     195             :         /** @internal @return the bits to be re-committed by the master. */
     196          22 :         virtual uint64_t getRedistributableBits() const
     197          22 :             { return DIRTY_WINDOW_BITS; }
     198             : 
     199             :     private:
     200             :         /** The parent pipe. */
     201             :         P* const _pipe;
     202             : 
     203             :         /** The channels of this window. */
     204             :         Channels _channels;
     205             : 
     206        1561 :         struct BackupData
     207             :         {
     208             :             BackupData();
     209             : 
     210             :             /** Window settings. */
     211             :             Settings windowSettings;
     212             : 
     213             :             /** Drawable characteristics of this window */
     214             :             DrawableConfig drawableConfig;
     215             : 
     216             :             /** The absolute size and position of the window. */
     217             :             PixelViewport pvp;
     218             : 
     219             :             /** The fractional size and position of the window. */
     220             :             Viewport vp;
     221             : 
     222             :             /** true if the pixel viewport is mutable, false if the viewport
     223             :                 is immutable */
     224             :             bool fixedVP;
     225             :         }
     226             :             _data, _backup;
     227             : 
     228             :         struct Private;
     229             :         Private* _private; // placeholder for binary-compatible changes
     230             : 
     231             :         friend class Channel< W, C >;
     232             :         /** Add a new channel to this window. */
     233             :         void _addChannel( C* channel );
     234             : 
     235             :         /** Remove a channel from this window. */
     236             :         EQFABRIC_INL bool _removeChannel( C* channel );
     237             : 
     238             :         /** @internal */
     239          67 :         bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
     240             : 
     241             :         typedef co::CommandFunc< Window< P, W, C, Settings > > CmdFunc;
     242             :         bool _cmdNewChannel( co::ICommand& command );
     243             :         bool _cmdNewChannelReply( co::ICommand& command );
     244             :     };
     245             : 
     246             :     template< class P, class W, class C, class Settings > EQFABRIC_INL
     247             :     std::ostream& operator << ( std::ostream& os,
     248             :                                 const Window< P, W, C, Settings >& window );
     249             : }
     250             : }
     251             : 
     252             : #endif // EQFABRIC_WINDOW_H

Generated by: LCOV version 1.10