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

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-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_VIEWEQUALIZER_H
      19             : #define EQS_VIEWEQUALIZER_H
      20             : 
      21             : #include "equalizer.h"          // base class
      22             : #include "../channelListener.h" // nested base class
      23             : 
      24             : #include <eq/client/types.h>
      25             : #include <lunchbox/hash.h>
      26             : #include <deque>
      27             : #include <map>
      28             : 
      29             : namespace eq
      30             : {
      31             : namespace server
      32             : {
      33             :     std::ostream& operator << ( std::ostream& os, const ViewEqualizer* );
      34             : 
      35             :     /**
      36             :      * An Equalizer allocating resources to multiple destination channels of a
      37             :      * single view.
      38             :      */
      39             :     class ViewEqualizer : public Equalizer
      40             :     {
      41             :     public:
      42             :         EQSERVER_API ViewEqualizer();
      43             :         ViewEqualizer( const ViewEqualizer& from );
      44             :         virtual ~ViewEqualizer();
      45           8 :         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::VIEW_EQUALIZER; }
      55             : 
      56             :     protected:
      57          48 :         void notifyChildAdded( Compound*, Compound* ) override
      58          48 :             { LBASSERT( _listeners.empty( )); }
      59           0 :         void notifyChildRemove( Compound*, Compound* ) override
      60           0 :             { LBASSERT( _listeners.empty( )); }
      61             : 
      62             :     private:
      63           0 :         class Listener : public ChannelListener
      64             :         {
      65             :         public:
      66             :             Listener();
      67             :             virtual ~Listener();
      68             : 
      69             :             void update( Compound* compound );
      70             :             void clear();
      71             : 
      72             :             virtual void notifyLoadData( Channel* channel,
      73             :                                          const uint32_t frameNumber,
      74             :                                          const Statistics& statistics,
      75             :                                          const Viewport& region );
      76             :             struct Load
      77             :             {
      78             :                 static Load NONE;
      79             : 
      80             :                 Load( const uint32_t frame_, const uint32_t missing_,
      81             :                       const int64_t time_ );
      82             :                 bool operator == ( const Load& rhs ) const;
      83             : 
      84             :                 uint32_t frame;
      85             :                 uint32_t missing;
      86             :                 uint32_t nResources;
      87             :                 int64_t time;
      88             :             };
      89             : 
      90             :             /** @return the frame number of the youngest complete load. */
      91             :             uint32_t findYoungestLoad( const uint32_t frame ) const;
      92             :             /** Delete older loads and return the load belonging to the frame.*/
      93             :             const Load& useLoad( const uint32_t frameNumber );
      94             :             /** Insert a new, empty load for the given frame. */
      95             :             void newLoad( const uint32_t frameNumber, const uint32_t nChannels);
      96             :             /** @return the size of the history stash. */
      97           0 :             size_t getNLoads() const { return _loads.size(); }
      98             : 
      99             :         private:
     100             :             typedef lunchbox::PtrHash< Channel*, uint32_t > TaskIDHash;
     101             :             TaskIDHash _taskIDs;
     102             : 
     103             :             typedef std::deque< Load > LoadDeque;
     104             :             LoadDeque _loads;
     105             : 
     106             :             Load& _getLoad( const uint32_t frameNumber );
     107             :             friend std::ostream& operator << ( std::ostream& os,
     108             :                                                const ViewEqualizer::Listener& );
     109             :         };
     110             :         friend std::ostream& operator << ( std::ostream& os,
     111             :                                            const ViewEqualizer::Listener& );
     112             :         friend std::ostream& operator << ( std::ostream& os,
     113             :                                          const ViewEqualizer::Listener::Load& );
     114             : 
     115             :         typedef std::vector< Listener::Load > Loads;
     116             :         typedef std::vector< Listener > Listeners;
     117             :         /** Per-child listener gathering load data. */
     118             :         Listeners _listeners;
     119             : 
     120             :         /** The total number of available resources. */
     121             :         size_t _nPipes;
     122             : 
     123             :         /** Update channel load subscription. */
     124             :         void _updateListeners();
     125             :         /** Update resource count. */
     126             :         void _updateResources();
     127             :         /** Assign resources to children. */
     128             :         void _update( const uint32_t frameNumber );
     129             :         /** Find the frame number to use for update. */
     130             :         uint32_t _findInputFrameNumber() const;
     131             :     };
     132             :     std::ostream& operator << ( std::ostream& os,
     133             :                                 const ViewEqualizer::Listener& listener );
     134             :     std::ostream& operator << ( std::ostream& os,
     135             :                                 const ViewEqualizer::Listener::Load& load );
     136             : }
     137             : }
     138             : 
     139             : #endif // EQS_VIEWEQUALIZER_H

Generated by: LCOV version 1.10