LCOV - code coverage report
Current view: top level - eq/server - observer.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 3 5 60.0 %
Date: 2014-06-18 Functions: 2 3 66.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2011, 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 EQSERVER_OBSERVER_H
      20             : #define EQSERVER_OBSERVER_H
      21             : 
      22             : #include "api.h"
      23             : #include "types.h"
      24             : 
      25             : #include <eq/fabric/observer.h>   // base class
      26             : #include <eq/fabric/eye.h>        // enum
      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             :         /**
      40             :          * Constructs a new Observer.
      41             :          */
      42             :         EQSERVER_API Observer( Config* parent );
      43             : 
      44             :         /** Destruct this observer. */
      45             :         virtual ~Observer();
      46             : 
      47             :         /** @name Data Access */
      48             :         //@{
      49             :         /** @return the Server of this observer. @version 1.0 */
      50             :         ServerPtr getServer();
      51             : 
      52             :         /** @return the position of an eye in world-space coordinates. */
      53          26 :         const fabric::Vector3f& getEyeWorld( const fabric::Eye eye ) const
      54          26 :         { return _eyeWorld[ lunchbox::getIndexOfLastBit( eye ) ]; }
      55             : 
      56             :         /** @return the inverse of the current head matrix. */
      57           0 :         const fabric::Matrix4f& getInverseHeadMatrix() const
      58           0 :             { return _inverseHeadMatrix; }
      59             : 
      60             :         /** @return true if this observer should be deleted. */
      61          16 :         bool needsDelete() const { return _state == STATE_DELETE; }
      62             :         //@}
      63             : 
      64             :         /**
      65             :          * @name Operations
      66             :          */
      67             :         //@{
      68             :         /** Initialize the observer parameters. */
      69             :         void init();
      70             : 
      71             :         /** Schedule deletion of this observer. */
      72             :         void postDelete();
      73             :         //@}
      74             : 
      75             :         void addView( View* view );    //!< @internal
      76             :         void removeView( View* view ); //!< @internal
      77             : 
      78             :     protected:
      79             :         virtual void setDirty( const uint64_t bits ); //!< @internal
      80             : 
      81             :         /** @sa Object::deserialize */
      82             :         virtual void deserialize( co::DataIStream& is,
      83             :                                   const uint64_t dirtyBits );
      84             : 
      85             :     private:
      86             :         /** Cached inverse head matrix. */
      87             :         fabric::Matrix4f _inverseHeadMatrix;
      88             : 
      89             :         /** The eye positions in world space. */
      90             :         fabric::Vector3f _eyeWorld[ eq::fabric::NUM_EYES ];
      91             : 
      92             :         /** Views tracked by this observer. */
      93             :         Views _views;
      94             : 
      95             :         enum State
      96             :         {
      97             :             STATE_ACTIVE = 0,  // next: DELETE
      98             :             STATE_DELETE,      // next: destructor
      99             :         }
     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.10