LCOV - code coverage report
Current view: top level - eq/server - config.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 16 23 69.6 %
Date: 2016-07-30 05:04:55 Functions: 15 20 75.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2014, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *               2010-2011, Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *                    2010, Cedric Stalder <cedric Stalder@gmail.com>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef EQSERVER_CONFIG_H
      21             : #define EQSERVER_CONFIG_H
      22             : 
      23             : #include <eq/server/api.h>
      24             : #include "types.h"
      25             : #include "server.h"        // used in inline method
      26             : #include "state.h"         // enum
      27             : #include "visitorResult.h" // enum
      28             : 
      29             : #include <eq/fabric/config.h> // base class
      30             : #include <lunchbox/monitor.h> // member
      31             : 
      32             : #include <iostream>
      33             : #include <vector>
      34             : 
      35             : namespace eq
      36             : {
      37             : namespace server
      38             : {
      39             : /** The config. */
      40             : class Config : public fabric::Config< Server, Config, Observer, Layout,
      41             :                                       Canvas, Node, ConfigVisitor >
      42             : {
      43             : public:
      44             :     typedef fabric::Config< Server, Config, Observer, Layout, Canvas, Node,
      45             :                             ConfigVisitor > Super;
      46             : 
      47             :     /** Construct a new config. */
      48             :     EQSERVER_API explicit Config( ServerPtr parent );
      49             :     virtual ~Config();
      50             : 
      51             :     /**
      52             :      * @name Data Access.
      53             :      */
      54             :     //@{
      55             :     Channel* getChannel( const ChannelPath& path );
      56             :     Segment* getSegment( const SegmentPath& path );
      57             :     View* getView( const ViewPath& path );
      58             : 
      59           4 :     bool isRunning() const { return ( _state == STATE_RUNNING ); }
      60           8 :     bool isUsed() const { return _state != STATE_UNUSED; }
      61           4 :     bool isAutoConfig() const
      62           4 :     { return getName().find( " autoconfig" ) != std::string::npos; }
      63             : 
      64          28 :     co::CommandQueue* getMainThreadQueue()
      65          28 :     { return getServer()->getMainThreadQueue(); }
      66          24 :     co::CommandQueue* getCommandThreadQueue()
      67          24 :     { return getServer()->getCommandThreadQueue(); }
      68             : 
      69             :     /**
      70             :      * Adds a new compound to this config.
      71             :      *
      72             :      * @param compound the compound.
      73             :      */
      74             :     EQSERVER_API void addCompound( Compound* compound );
      75             : 
      76             :     /**
      77             :      * Removes a compound from this config.
      78             :      *
      79             :      * @param compound the compound
      80             :      * @return <code>true</code> if the compound was removed,
      81             :      *         <code>false</code> otherwise.
      82             :      */
      83             :     EQSERVER_API bool removeCompound( Compound* compound );
      84             : 
      85             :     /** @return the vector of compounds. */
      86        2214 :     const Compounds& getCompounds() const { return _compounds; }
      87             : 
      88             :     /**
      89             :      * Find the first channel of a given name.
      90             :      *
      91             :      * @param name the name of the channel to find
      92             :      * @return the first channel with the name, or <code>0</code> if no
      93             :      *         channel with the name exists.
      94             :      */
      95             :     const Channel* findChannel( const std::string& name ) const;
      96             : 
      97             :     /**
      98             :      * Find the channel for the given view/segment intersection.
      99             :      *
     100             :      * @param segment the segment.
     101             :      * @param view the view.
     102             :      * @return the channel for updating the view/segment intersection.
     103             :      */
     104             :     EQSERVER_API Channel* findChannel( const Segment* segment,
     105             :                                        const View* view );
     106             : 
     107             :     /** @return the application node, or 0. */
     108             :     EQSERVER_API Node* findApplicationNode();
     109             :     //@}
     110             : 
     111             :     /** @sa fabric::Config::changeLatency() */
     112             :     virtual void changeLatency( const uint32_t latency );
     113             : 
     114             :     /**
     115             :      * Set the network node running the application thread.
     116             :      *
     117             :      * @param node the application node.
     118             :      */
     119             :     void setApplicationNetNode( co::NodePtr node );
     120             : 
     121             :     /** @return network node running the application thread. */
     122             :     co::NodePtr findApplicationNetNode();
     123             : 
     124             :     /** @internal set auto-configured server connections */
     125           0 :     void setServerConnections( const co::Connections& connections )
     126           0 :     { _connections = connections; }
     127             : 
     128             :     /** @internal @return the auto-configured server connections */
     129           0 :     const co::Connections& getServerConnections() const
     130           0 :     { return _connections; }
     131             : 
     132             :     /**
     133             :      * Set the name of the render client executable.
     134             :      *
     135             :      * @param rc the name of the render client executable.
     136             :      */
     137           4 :     void setRenderClient( const std::string& rc ){ _renderClient = rc; }
     138             : 
     139             :     /** @return the name of the render client executable. */
     140           0 :     const std::string& getRenderClient() const { return _renderClient; }
     141             : 
     142             :     /**
     143             :      * Set the working directory for render client.
     144             :      *
     145             :      * @param workDir the working directory for the  render client.
     146             :      */
     147           4 :     void setWorkDir( const std::string& workDir ){ _workDir = workDir; }
     148             : 
     149             :     /** @return the working directory for the  render client. */
     150           0 :     const std::string& getWorkDir() const { return _workDir; }
     151             : 
     152             :     /** Notify that a node of this config has finished a frame. */
     153             :     void notifyNodeFrameFinished( const uint32_t frameNumber );
     154             : 
     155             :     // Used by Server::releaseConfig() to make sure config is exited
     156             :     bool exit();
     157             : 
     158             :     /** Register the config and all shared object children. */
     159             :     void register_();
     160             : 
     161             :     /** Deregister all shared objects and the config. */
     162             :     void deregister();
     163             : 
     164             :     /** Commit the config for the current frame. */
     165             :     uint128_t commit();
     166             : 
     167             :     virtual void restore();
     168             : 
     169             :     EventOCommand sendError( const uint32_t type, const Error& error );
     170             : 
     171             :     /** Return the initID, used for late initialization  */
     172             :     uint128_t getInitID(){ return _initID; }
     173             : 
     174             :     /** Activate the given canvas after it is complete (dest channels). */
     175             :     virtual void activateCanvas( Canvas* canvas );
     176             : 
     177             :     /** Initialize the given canvas in a running configuration */
     178             :     virtual void updateCanvas( Canvas* canvas );
     179             : 
     180             :     /** Request a finish of outstanding frames on next frame */
     181           4 :     void postNeedsFinish() { _needsFinish = true; }
     182             : 
     183             :     /** @internal @return the last finished frame */
     184           4 :     uint32_t getFinishedFrame() const { return _finishedFrame.get(); }
     185             : 
     186             :     /** @internal */
     187             :     virtual VisitorResult _acceptCompounds( ConfigVisitor& visitor );
     188             :     /** @internal */
     189             :     virtual VisitorResult _acceptCompounds( ConfigVisitor& visitor ) const;
     190             : 
     191             :     void output( std::ostream& os ) const; //!< @internal
     192           0 :     virtual bool mapViewObjects() const { return true; } //!< @internal
     193           6 :     virtual bool mapNodeObjects() const { return true; } //!< @internal
     194             : 
     195             : protected:
     196             :     /** @internal */
     197             :     virtual void attach( const uint128_t& id, const uint32_t instanceID );
     198             : 
     199             :     /** @internal Execute the slave remove request. */
     200             :     virtual void removeChild( const uint128_t& id );
     201             : 
     202             : private:
     203             :     Config( const Config& from );
     204             : 
     205             :     /** The initID for late initialization. */
     206             :     uint128_t _initID;
     207             : 
     208             :     /** The list of compounds. */
     209             :     Compounds _compounds;
     210             : 
     211             :     /** Auto-configured server connections. */
     212             :     co::Connections _connections;
     213             : 
     214             :     /** The name of the render client executable. */
     215             :     std::string _renderClient;
     216             : 
     217             :     /** The working directory of the render client. */
     218             :     std::string _workDir;
     219             : 
     220             :     /** The last started frame, or 0. */
     221             :     uint32_t _currentFrame;
     222             : 
     223             :     /** The eternal frame commit counter, starting at 1 (#66). */
     224             :     uint32_t _incarnation;
     225             : 
     226             :     /** The last finished frame, or 0. */
     227             :     lunchbox::Monitor< uint32_t > _finishedFrame;
     228             : 
     229             :     State _state;
     230             : 
     231             :     bool _needsFinish; //!< true after runtime changes
     232             : 
     233             :     int64_t _lastCheck;
     234             : 
     235             :     struct Private;
     236             :     Private* _private; // placeholder for binary-compatible changes
     237             : 
     238             :     /**
     239             :      * @name Operations
     240             :      */
     241             :     //@{
     242             :     /** @return true on success, false on error */
     243             :     bool _updateRunning( const bool canFail );
     244             : 
     245             :     void _updateCanvases();
     246             :     bool _connectNodes();
     247             :     bool _connectNode( Node* node );
     248             :     bool _syncConnectNode( Node* node, const lunchbox::Clock& clock );
     249             :     void _startNodes();
     250             :     lunchbox::Request< void > _createConfig( Node* node );
     251             :     bool _updateNodes( const bool canFail );
     252             :     void _stopNodes();
     253             :     template< class T >
     254             :     void _deleteEntities( const std::vector< T* >& entities );
     255             :     void _syncClock();
     256             :     void _verifyFrameFinished( const uint32_t frameNumber );
     257             :     bool _init( const uint128_t& initID );
     258             : 
     259             :     void _startFrame( const uint128_t& frameID );
     260             :     void _flushAllFrames();
     261             :     //@}
     262             : 
     263             :     virtual Observer* createObserver();
     264             :     virtual void releaseObserver( Observer* observer );
     265             :     virtual Layout* createLayout();
     266             :     virtual void releaseLayout( Layout* layout );
     267             :     virtual Canvas* createCanvas();
     268             :     virtual void releaseCanvas( Canvas* canvas );
     269             : 
     270             :     /** @internal Post deletion for the given child, returns true if found*/
     271             :     template< class T > bool _postDelete( const uint128_t& id );
     272             : 
     273             :     /** The command functions. */
     274             :     bool _cmdInit( co::ICommand& command );
     275             :     bool _cmdExit( co::ICommand& command );
     276             :     bool _cmdUpdate( co::ICommand& command );
     277             :     bool _cmdStartFrame( co::ICommand& command );
     278             :     bool _cmdStopFrames( co::ICommand& command );
     279             :     bool _cmdFinishAllFrames( co::ICommand& command );
     280             :     bool _cmdCreateReply( co::ICommand& command );
     281             :     bool _cmdFreezeLoadBalancing( co::ICommand& command );
     282             :     bool _cmdCheckFrame( co::ICommand& command );
     283             : 
     284         850 :     LB_TS_VAR( _cmdThread );
     285         850 :     LB_TS_VAR( _mainThread );
     286             : };
     287             : }
     288             : }
     289             : #endif // EQSERVER_CONFIG_H

Generated by: LCOV version 1.11