LCOV - code coverage report
Current view: top level - eq/server/equalizers - framerateEqualizer.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 3 7 42.9 %
Date: 2014-06-18 Functions: 2 8 25.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #ifndef EQS_FRAMERATEEQUALIZER_H
      19             : #define EQS_FRAMERATEEQUALIZER_H
      20             : 
      21             : #include "../channelListener.h" // base class
      22             : #include "equalizer.h"          // base class
      23             : 
      24             : #include <deque>
      25             : #include <map>
      26             : 
      27             : namespace eq
      28             : {
      29             : namespace server
      30             : {
      31             :     std::ostream& operator << ( std::ostream& os, const FramerateEqualizer* );
      32             : 
      33             :     /**
      34             :      * Adapts the frame rate of a compound to smoothen its output.
      35             :      *
      36             :      * Does not support period settings underneath a child. One channel should
      37             :      * not be used in compounds with a different inherit period.
      38             :      */
      39             :     class FramerateEqualizer : public Equalizer
      40             :     {
      41             :     public:
      42             :         EQSERVER_API FramerateEqualizer();
      43             :         FramerateEqualizer( const FramerateEqualizer& from );
      44             :         virtual ~FramerateEqualizer();
      45           7 :         virtual void toStream( std::ostream& os ) const { os << this; }
      46             : 
      47             :         /** @sa Equalizer::attach */
      48             :         virtual void attach( Compound* compound );
      49             : 
      50             :         /** @sa CompoundListener::notifyUpdatePre */
      51             :         virtual void notifyUpdatePre( Compound* compound,
      52             :                                       const uint32_t frameNumber );
      53             : 
      54           0 :         virtual uint32_t getType() const { return fabric::FRAMERATE_EQUALIZER; }
      55             : 
      56             :     protected:
      57          34 :         void notifyChildAdded( Compound*, Compound* ) override
      58          34 :             { LBASSERT( _nSamples == 0 ); }
      59           0 :         void notifyChildRemove( Compound*, Compound* ) override
      60           0 :             { LBASSERT( _nSamples == 0 ); }
      61             : 
      62             :     private:
      63             :         /** Frame number with max time. */
      64             :         typedef std::pair< uint32_t, float > FrameTime;
      65             : 
      66             :         /** Historical data to compute new frame rate. */
      67             :         std::deque< FrameTime > _times;
      68             : 
      69             :         /** Helper class connecting on child tree for load gathering. */
      70           0 :         class LoadListener : public ChannelListener
      71             :         {
      72             :         public:
      73             :             /** @sa ChannelListener::notifyLoadData */
      74             :             virtual void notifyLoadData( Channel* channel,
      75             :                                          const uint32_t frameNumber,
      76             :                                          const Statistics& statistics,
      77             :                                          const Viewport& region );
      78             : 
      79             :             FramerateEqualizer* parent;
      80             :             uint32_t period;
      81             :         };
      82             : 
      83             :         /** One listener for each compound child. */
      84             :         std::vector< LoadListener > _loadListeners;
      85             :         friend class LoadListener;
      86             : 
      87             :         /** The number of samples to use from _times. */
      88             :         uint32_t _nSamples;
      89             : 
      90             :         void _init();
      91             :         void _exit();
      92             :     };
      93             : }
      94             : }
      95             : 
      96             : #endif // EQS_LOADBALANCER_H

Generated by: LCOV version 1.10