LCOV - code coverage report
Current view: top level - eq/admin - server.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 2 42 4.8 %
Date: 2016-07-30 05:04:55 Functions: 2 10 20.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2010-2014, Stefan Eilemann <eile@eyescale.ch>
       3             :  *               2012, Daniel Nachbaur <danielnachbaur@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             : #include "server.h"
      20             : 
      21             : #include "client.h"
      22             : #include "config.h"
      23             : #include "nodeFactory.h"
      24             : 
      25             : #include <eq/fabric/commands.h>
      26             : #include <co/dispatcher.h>
      27             : #include <co/iCommand.h>
      28             : 
      29             : #include <boost/foreach.hpp>
      30             : 
      31             : namespace eq
      32             : {
      33             : namespace admin
      34             : {
      35             : namespace
      36             : {
      37          28 :     static NodeFactory _nf;
      38             : }
      39             : 
      40             : typedef co::CommandFunc< Server > CmdFunc;
      41             : typedef fabric::Server< Client, Server, Config, NodeFactory, co::Node,
      42             :                         ServerVisitor > Super;
      43             : 
      44           0 : Server::Server()
      45           0 :         : Super( &_nf )
      46           0 : {}
      47             : 
      48           0 : void Server::setClient( ClientPtr client )
      49             : {
      50           0 :     Super::setClient( client );
      51           0 :     if( !client )
      52           0 :         return;
      53             : 
      54           0 :     co::CommandQueue* queue = client->getMainThreadQueue();
      55             :     registerCommand( fabric::CMD_SERVER_MAP_REPLY,
      56           0 :                      CmdFunc( this, &Server::_cmdMapReply ), queue );
      57             :     registerCommand( fabric::CMD_SERVER_UNMAP_REPLY,
      58           0 :                      CmdFunc( this, &Server::_cmdUnmapReply ), queue );
      59             : }
      60             : 
      61           0 : void Server::map()
      62             : {
      63           0 :     ClientPtr client = getClient();
      64             : 
      65           0 :     const lunchbox::Request< void >& request = client->registerRequest<void>();
      66           0 :     send( fabric::CMD_SERVER_MAP ) << request.getID();
      67             : 
      68           0 :     while( !request.isReady( ))
      69           0 :         client->processCommand();
      70           0 : }
      71             : 
      72           0 : void Server::unmap()
      73             : {
      74           0 :     ClientPtr client = getClient();
      75             : 
      76           0 :     const lunchbox::Request< void >& request = client->registerRequest<void>();
      77           0 :     send( fabric::CMD_SERVER_UNMAP ) << request;
      78             : 
      79           0 :     while( !request.isReady( ))
      80           0 :         client->processCommand();
      81           0 : }
      82             : 
      83           0 : void Server::syncConfig( const co::uint128_t& configID,
      84             :                          const co::uint128_t& version  )
      85             : {
      86           0 :     const Configs& configs = getConfigs();
      87           0 :     BOOST_FOREACH( Config* config, configs )
      88             :     {
      89           0 :         if( config->getID() == configID )
      90           0 :             config->sync( version );
      91             :     }
      92           0 : }
      93             : 
      94           0 : co::CommandQueue* Server::getMainThreadQueue()
      95             : {
      96           0 :     return getClient()->getMainThreadQueue();
      97             : }
      98             : 
      99           0 : bool Server::_cmdMapReply( co::ICommand& command )
     100             : {
     101           0 :     ClientPtr client = getClient();
     102           0 :     client->serveRequest( command.read< uint32_t >( ));
     103           0 :     return true;
     104             : }
     105             : 
     106           0 : bool Server::_cmdUnmapReply( co::ICommand& command )
     107             : {
     108           0 :     ClientPtr client = getClient();
     109           0 :     client->serveRequest( command.read< uint32_t >( ));
     110           0 :     return true;
     111             : }
     112             : 
     113             : }
     114             : }
     115             : #include "../fabric/server.ipp"
     116             : template class eq::fabric::Server< eq::admin::Client, eq::admin::Server,
     117             :                                    eq::admin::Config, eq::admin::NodeFactory,
     118             :                                    co::Node, eq::admin::ServerVisitor >;
     119             : 
     120             : /** @cond IGNORE */
     121             : template EQFABRIC_API std::ostream& eq::fabric::operator << ( std::ostream&,
     122          84 :                                                        const eq::admin::Super& );
     123             : /** @endcond */

Generated by: LCOV version 1.11