LCOV - code coverage report
Current view: top level - eq/server - observer.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 3 5 60.0 %
Date: 2017-12-16 05:07:20 Functions: 2 3 66.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2015, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          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 EQSERVER_OBSERVER_H
      20             : #define EQSERVER_OBSERVER_H
      21             : 
      22             : #include "types.h"
      23             : #include <eq/server/api.h>
      24             : 
      25             : #include <eq/fabric/eye.h>         // enum
      26             : #include <eq/fabric/observer.h>    // base class
      27             : #include <lunchbox/bitOperation.h> // function getIndexOfLastBit
      28             : 
      29             : #include <string>
      30             : 
      31             : namespace eq
      32             : {
      33             : namespace server
      34             : {
      35             : /** The observer. @sa eq::Observer */
      36             : class Observer : public fabric::Observer<Config, Observer>
      37             : {
      38             : public:
      39             :     /** Construct a new Observer. */
      40             :     EQSERVER_API explicit Observer(Config* parent);
      41             : 
      42             :     /** Destruct this observer. */
      43             :     virtual ~Observer();
      44             : 
      45             :     /** @name Data Access */
      46             :     //@{
      47             :     /** @return the Server of this observer. @version 1.0 */
      48             :     ServerPtr getServer();
      49             : 
      50             :     /** @return the position of an eye in world-space coordinates. */
      51          32 :     const fabric::Vector3f& getEyeWorld(const fabric::Eye eye) const
      52             :     {
      53          32 :         return _eyeWorld[lunchbox::getIndexOfLastBit(eye)];
      54             :     }
      55             : 
      56             :     /** @return the inverse of the current head matrix. */
      57           0 :     const fabric::Matrix4f& getInverseHeadMatrix() const
      58             :     {
      59           0 :         return _inverseHeadMatrix;
      60             :     }
      61             : 
      62             :     /** @return true if this observer should be deleted. */
      63           4 :     bool needsDelete() const { return _state == STATE_DELETE; }
      64             :     //@}
      65             : 
      66             :     /**
      67             :      * @name Operations
      68             :      */
      69             :     //@{
      70             :     /** Initialize the observer parameters. */
      71             :     void init();
      72             : 
      73             :     /** Schedule deletion of this observer. */
      74             :     void postDelete();
      75             :     //@}
      76             : 
      77             :     void addView(View* view);    //!< @internal
      78             :     void removeView(View* view); //!< @internal
      79             : 
      80             : protected:
      81             :     virtual void setDirty(const uint64_t bits); //!< @internal
      82             : 
      83             :     /** @sa Object::deserialize */
      84             :     virtual void deserialize(co::DataIStream& is, const uint64_t dirtyBits);
      85             : 
      86             : private:
      87             :     /** Cached inverse head matrix. */
      88             :     fabric::Matrix4f _inverseHeadMatrix;
      89             : 
      90             :     /** The eye positions in world space. */
      91             :     fabric::Vector3f _eyeWorld[eq::fabric::NUM_EYES];
      92             : 
      93             :     /** Views tracked by this observer. */
      94             :     Views _views;
      95             : 
      96             :     enum State
      97             :     {
      98             :         STATE_ACTIVE = 0, // next: DELETE
      99             :         STATE_DELETE,     // next: destructor
     100             :     } _state;
     101             : 
     102             :     struct Private;
     103             :     Private* _private; // placeholder for binary-compatible changes
     104             : 
     105             :     void _updateEyes();
     106             :     void _updateViews();
     107             : };
     108             : }
     109             : }
     110             : #endif // EQSERVER_OBSERVER_H

Generated by: LCOV version 1.11