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

Generated by: LCOV version 1.11