LCOV - code coverage report
Current view: top level - eq/server/equalizers - treeEqualizer.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 0 13 0.0 %
Date: 2017-12-16 05:07:20 Functions: 0 6 0.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2010, Cedric Stalder <cedric.stalder@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #ifndef EQS_TREEEQUALIZER_H
      20             : #define EQS_TREEEQUALIZER_H
      21             : 
      22             : #include "../channelListener.h" // base class
      23             : #include "equalizer.h"          // base class
      24             : 
      25             : #include <eq/fabric/range.h>    // member
      26             : #include <eq/fabric/viewport.h> // member
      27             : 
      28             : #include <deque>
      29             : #include <vector>
      30             : 
      31             : namespace eq
      32             : {
      33             : namespace server
      34             : {
      35             : std::ostream& operator<<(std::ostream& os, const TreeEqualizer*);
      36             : 
      37             : /** Adapts the 2D tiling or DB range of the attached compound's children. */
      38             : class TreeEqualizer : public Equalizer, protected ChannelListener
      39             : {
      40             : public:
      41             :     EQSERVER_API TreeEqualizer();
      42             :     TreeEqualizer(const TreeEqualizer& from);
      43             :     virtual ~TreeEqualizer();
      44           0 :     void toStream(std::ostream& os) const final { os << this; }
      45             :     /** @sa CompoundListener::notifyUpdatePre */
      46             :     void notifyUpdatePre(Compound* compound, const uint32_t frameNumber) final;
      47             : 
      48             :     /** @sa ChannelListener::notifyLoadData */
      49             :     void notifyLoadData(Channel* channel, uint32_t frameNumber,
      50             :                         const Statistics& statistics,
      51             :                         const Viewport& region) final;
      52             : 
      53           0 :     uint32_t getType() const final { return fabric::TREE_EQUALIZER; }
      54             : protected:
      55           0 :     void notifyChildAdded(Compound*, Compound*) override { LBASSERT(!_tree); }
      56           0 :     void notifyChildRemove(Compound*, Compound*) override { LBASSERT(!_tree); }
      57             : private:
      58             :     struct Node
      59             :     {
      60           0 :         Node()
      61           0 :             : left(0)
      62             :             , right(0)
      63             :             , compound(0)
      64             :             , mode(MODE_VERTICAL)
      65             :             , resources(0.0f)
      66             :             , split(0.5f)
      67             :             , oldsplit(0.0f)
      68             :             , boundaryf(0.0f)
      69             :             , resistancef(0.0f)
      70           0 :             , time(1)
      71             :         {
      72           0 :         }
      73           0 :         ~Node()
      74           0 :         {
      75           0 :             delete left;
      76           0 :             delete right;
      77           0 :         }
      78             : 
      79             :         Node* left;               //<! Left child (only on non-leafs)
      80             :         Node* right;              //<! Right child (only on non-leafs)
      81             :         Compound* compound;       //<! The corresponding child (only on leafs)
      82             :         TreeEqualizer::Mode mode; //<! What to adapt
      83             :         float resources;          //<! total amount of resources of subtree
      84             :         float split;              //<! 0..1 local (vp, range) split
      85             :         float oldsplit;
      86             :         float boundaryf;
      87             :         Vector2i boundary2i;
      88             :         float resistancef;
      89             :         Vector2i resistance2i;
      90             :         Vector2i maxSize;
      91             :         int64_t time;
      92             :     };
      93             :     friend std::ostream& operator<<(std::ostream& os, const Node* node);
      94             :     typedef std::vector<Node*> LBNodes;
      95             : 
      96             :     Node* _tree; // <! The binary split tree of all children
      97             : 
      98             :     //-------------------- Methods --------------------
      99             :     /** @return true if we have a valid LB tree */
     100             :     Node* _buildTree(const Compounds& children);
     101             : 
     102             :     /** Clear the tree, does not delete the nodes. */
     103             :     void _clearTree(Node* node);
     104             : 
     105             :     void _notifyLoadData(Node* node, Channel* channel,
     106             :                          const Statistics& statistics);
     107             : 
     108             :     /** Update all node fields influencing the split */
     109             :     void _update(Node* node);
     110             : 
     111             :     /** Adjust the split of each node based on the front-most _history. */
     112             :     void _split(Node* node);
     113             :     void _assign(Node* node, const Viewport& vp, const Range& range);
     114             : };
     115             : }
     116             : }
     117             : 
     118             : #endif // EQS_TREEEQUALIZER_H

Generated by: LCOV version 1.11