LCOV - code coverage report
Current view: top level - eq/fabric - window.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 12 13 92.3 %
Date: 2017-12-16 05:07:20 Functions: 17 36 47.2 %

          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          20 :     const P* getPipe() const { return _pipe; }
      52             :     /** @return the parent Pipe of this window. @version 1.0 */
      53        2521 :     P* getPipe() { return _pipe; }
      54             :     /** @return a vector of all child channels of this window.  */
      55       38806 :     const Channels& getChannels() const { return _channels; }
      56             :     /** @return the window's drawable configuration. @version 1.0 */
      57          89 :     const DrawableConfig& getDrawableConfig() const
      58             :     {
      59          89 :         return _data.drawableConfig;
      60             :     }
      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         752 :     const Viewport& getViewport() const { return _data.vp; }
      72             :     /** Set the window's name/caption. @version 1.7.2 */
      73             :     EQFABRIC_INL void setName(const std::string& name) final;
      74             : 
      75             :     /**
      76             :      * Set the window's pixel viewport wrt its parent pipe.
      77             :      *
      78             :      * Updates the fractional viewport of the window and its channels
      79             :      * accordingly.
      80             :      *
      81             :      * @param pvp the viewport in pixels.
      82             :      * @version 1.0
      83             :      */
      84             :     EQFABRIC_INL virtual void setPixelViewport(const PixelViewport& pvp);
      85             : 
      86             :     /**
      87             :      * Set the window's viewport wrt its parent pipe.
      88             :      *
      89             :      * Updates the fractional pixel viewport of the window and its channels
      90             :      * accordingly.
      91             :      *
      92             :      * @param vp the fractional viewport.
      93             :      * @version 1.0
      94             :      */
      95             :     EQFABRIC_INL void setViewport(const Viewport& vp);
      96             : 
      97             :     /** @return true if a viewport was specified last. @version 1.0 */
      98         756 :     bool hasFixedViewport() const { return _data.fixedVP; }
      99             :     /** @internal Notify this window that the viewport has changed. */
     100             :     virtual void notifyViewportChanged();
     101             : 
     102             :     /**
     103             :      * Perform a depth-first traversal of this window.
     104             :      *
     105             :      * @param visitor the visitor.
     106             :      * @return the result of the visitor traversal.
     107             :      * @version 1.0
     108             :      */
     109             :     EQFABRIC_INL VisitorResult accept(Visitor& visitor);
     110             : 
     111             :     /** Const-version of accept(). @version 1.0 */
     112             :     EQFABRIC_INL VisitorResult accept(Visitor& visitor) const;
     113             : 
     114             :     //@}
     115             : 
     116             :     /** @name Attributes */
     117             :     //@{
     118             :     /** Set the settings of this window. @version 1.9 */
     119             :     EQFABRIC_INL void setSettings(const Settings& settings);
     120             : 
     121             :     /** @return the settings of this window. @version 1.7.2 */
     122             :     EQFABRIC_INL const Settings& getSettings() const;
     123             : 
     124             :     /** Set a window attribute. @version 1.0 */
     125             :     EQFABRIC_INL void setIAttribute(const WindowSettings::IAttribute attr,
     126             :                                     const int32_t value);
     127             : 
     128             :     /** @return the value of a window attribute. @version 1.0 */
     129             :     EQFABRIC_INL int32_t
     130             :         getIAttribute(const WindowSettings::IAttribute attr) const;
     131             : 
     132             :     /** @internal @return the name of a window attribute. */
     133             :     EQFABRIC_INL static const std::string& getIAttributeString(
     134             :         const WindowSettings::IAttribute attr);
     135             :     //@}
     136             : 
     137             :     /** @internal @return the index path to this window. */
     138             :     EQFABRIC_INL WindowPath getPath() const;
     139             : 
     140             :     /** @name internal */
     141             :     //@{
     142             :     EQFABRIC_INL virtual void backup();         //!< @internal
     143             :     EQFABRIC_INL virtual void restore();        //!< @internal
     144             :     void create(C** channel);                   //!< @internal
     145             :     void release(C* channel);                   //!< @internal
     146           0 :     virtual void output(std::ostream&) const {} //!< @internal
     147             :     /** @internal */
     148             :     EQFABRIC_INL virtual uint128_t commit(
     149             :         const uint32_t incarnation = CO_COMMIT_NEXT);
     150             :     //@}
     151             : 
     152             : protected:
     153             :     /** @internal Construct a new window. */
     154             :     explicit Window(P* parent);
     155             : 
     156             :     EQFABRIC_INL virtual ~Window(); //!< @internal
     157             :     /** @internal */
     158             :     virtual void attach(const uint128_t& id, 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           8 :     virtual ChangeType getChangeType() const { return UNBUFFERED; }
     177             :     C* _findChannel(const uint128_t& id); //!< @internal
     178             : 
     179             :     /** @internal */
     180             :     enum DirtyBits
     181             :     {
     182             :         DIRTY_SETTINGS = Object::DIRTY_CUSTOM << 0,
     183             :         DIRTY_CHANNELS = Object::DIRTY_CUSTOM << 1,
     184             :         DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 2,
     185             :         DIRTY_DRAWABLECONFIG = Object::DIRTY_CUSTOM << 3,
     186             :         DIRTY_WINDOW_BITS = DIRTY_SETTINGS | DIRTY_CHANNELS | DIRTY_VIEWPORT |
     187             :                             DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
     188             :     };
     189             : 
     190             :     /** @internal @return the bits to be re-committed by the master. */
     191           8 :     virtual uint64_t getRedistributableBits() const
     192             :     {
     193           8 :         return DIRTY_WINDOW_BITS;
     194             :     }
     195             : 
     196             : private:
     197             :     /** The parent pipe. */
     198             :     P* const _pipe;
     199             : 
     200             :     /** The channels of this window. */
     201             :     Channels _channels;
     202             : 
     203        2992 :     struct BackupData
     204             :     {
     205             :         BackupData();
     206             : 
     207             :         /** Window settings. */
     208             :         Settings windowSettings;
     209             : 
     210             :         /** Drawable characteristics of this window */
     211             :         DrawableConfig drawableConfig;
     212             : 
     213             :         /** The absolute size and position of the window. */
     214             :         PixelViewport pvp;
     215             : 
     216             :         /** The fractional size and position of the window. */
     217             :         Viewport vp;
     218             : 
     219             :         /** true if the pixel viewport is mutable, false if the viewport
     220             :             is immutable */
     221             :         bool fixedVP;
     222             :     } _data, _backup;
     223             : 
     224             :     struct Private;
     225             :     Private* _private; // placeholder for binary-compatible changes
     226             : 
     227             :     friend class Channel<W, C>;
     228             :     /** Add a new channel to this window. */
     229             :     void _addChannel(C* channel);
     230             : 
     231             :     /** Remove a channel from this window. */
     232             :     EQFABRIC_INL bool _removeChannel(C* channel);
     233             : 
     234             :     /** @internal */
     235          19 :     bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
     236             :     typedef co::CommandFunc<Window<P, W, C, Settings>> CmdFunc;
     237             :     bool _cmdNewChannel(co::ICommand& command);
     238             :     bool _cmdNewChannelReply(co::ICommand& command);
     239             : };
     240             : 
     241             : template <class P, class W, class C, class Settings>
     242             : EQFABRIC_INL std::ostream& operator<<(std::ostream& os,
     243             :                                       const Window<P, W, C, Settings>& window);
     244             : }
     245             : }
     246             : 
     247             : #endif // EQFABRIC_WINDOW_H

Generated by: LCOV version 1.11