LCOV - code coverage report
Current view: top level - eq/server/equalizers - viewEqualizer.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 4 10 40.0 %
Date: 2017-12-16 05:07:20 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 "../channelListener.h" // nested base class
      22             : #include "equalizer.h"          // base class
      23             : 
      24             : #include <deque>
      25             : #include <lunchbox/hash.h>
      26             : #include <map>
      27             : 
      28             : namespace eq
      29             : {
      30             : namespace server
      31             : {
      32             : std::ostream& operator<<(std::ostream& os, const ViewEqualizer*);
      33             : 
      34             : /**
      35             :  * An Equalizer allocating resources to multiple destination channels of a
      36             :  * single view.
      37             :  */
      38             : class ViewEqualizer : public Equalizer
      39             : {
      40             : public:
      41             :     EQSERVER_API ViewEqualizer();
      42             :     ViewEqualizer(const ViewEqualizer& from);
      43             :     virtual ~ViewEqualizer();
      44          16 :     void toStream(std::ostream& os) const final { os << this; }
      45             :     /** @sa Equalizer::attach. */
      46             :     void attach(Compound* compound) final;
      47             : 
      48             :     /** @sa CompoundListener::notifyUpdatePre */
      49             :     void notifyUpdatePre(Compound* compound, const uint32_t frameNumber) final;
      50             : 
      51           0 :     uint32_t getType() const final { return fabric::VIEW_EQUALIZER; }
      52             : protected:
      53          96 :     void notifyChildAdded(Compound*, Compound*) override
      54             :     {
      55          96 :         LBASSERT(_listeners.empty());
      56          96 :     }
      57           0 :     void notifyChildRemove(Compound*, Compound*) override
      58             :     {
      59           0 :         LBASSERT(_listeners.empty());
      60           0 :     }
      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, uint32_t frameNumber,
      73             :                                     const Statistics& statistics,
      74             :                                     const Viewport& region);
      75             :         struct Load
      76             :         {
      77             :             static Load NONE;
      78             : 
      79             :             Load(const uint32_t frame_, const uint32_t missing_,
      80             :                  const int64_t time_);
      81             :             bool operator==(const Load& rhs) const;
      82             : 
      83             :             uint32_t frame;
      84             :             uint32_t missing;
      85             :             uint32_t nResources;
      86             :             int64_t time;
      87             :         };
      88             : 
      89             :         /** @return the frame number of the youngest complete load. */
      90             :         uint32_t findYoungestLoad(const uint32_t frame) const;
      91             :         /** Delete older loads and return the load belonging to the frame.*/
      92             :         const Load& useLoad(const uint32_t frameNumber);
      93             :         /** Insert a new, empty load for the given frame. */
      94             :         void newLoad(const uint32_t frameNumber, const uint32_t nChannels);
      95             :         /** @return the size of the history stash. */
      96           0 :         size_t getNLoads() const { return _loads.size(); }
      97             :     private:
      98             :         typedef lunchbox::PtrHash<Channel*, uint32_t> TaskIDHash;
      99             :         TaskIDHash _taskIDs;
     100             : 
     101             :         typedef std::deque<Load> LoadDeque;
     102             :         LoadDeque _loads;
     103             : 
     104             :         Load& _getLoad(const uint32_t frameNumber);
     105             :         friend std::ostream& operator<<(std::ostream& os,
     106             :                                         const ViewEqualizer::Listener&);
     107             :     };
     108             :     friend std::ostream& operator<<(std::ostream& os,
     109             :                                     const ViewEqualizer::Listener&);
     110             :     friend std::ostream& operator<<(std::ostream& os,
     111             :                                     const ViewEqualizer::Listener::Load&);
     112             : 
     113             :     typedef std::vector<Listener::Load> Loads;
     114             :     typedef std::vector<Listener> Listeners;
     115             :     /** Per-child listener gathering load data. */
     116             :     Listeners _listeners;
     117             : 
     118             :     /** The total number of available resources. */
     119             :     size_t _nPipes;
     120             : 
     121             :     /** Update channel load subscription. */
     122             :     void _updateListeners();
     123             :     /** Update resource count. */
     124             :     void _updateResources();
     125             :     /** Assign resources to children. */
     126             :     void _update(const uint32_t frameNumber);
     127             :     /** Find the frame number to use for update. */
     128             :     uint32_t _findInputFrameNumber() const;
     129             : };
     130             : std::ostream& operator<<(std::ostream& os,
     131             :                          const ViewEqualizer::Listener& listener);
     132             : std::ostream& operator<<(std::ostream& os,
     133             :                          const ViewEqualizer::Listener::Load& load);
     134             : }
     135             : }
     136             : 
     137             : #endif // EQS_VIEWEQUALIZER_H

Generated by: LCOV version 1.11