LCOV - code coverage report
Current view: top level - eq/server/config - server.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 30 35 85.7 %
Date: 2017-12-16 05:07:20 Functions: 4 4 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2015, Stefan Eilemann <eile@eyescale.h>
       3             :  *                          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 "display.h"
      22             : #include "resources.h"
      23             : 
      24             : #include "../config.h"
      25             : #include "../global.h"
      26             : #include "../loader.h"
      27             : #include "../server.h"
      28             : 
      29             : #include <eq/fabric/configParams.h>
      30             : 
      31             : #include <fstream>
      32             : 
      33             : namespace eq
      34             : {
      35             : namespace server
      36             : {
      37             : namespace config
      38             : {
      39           2 : Config* Server::configure(ServerPtr server, const std::string& session,
      40             :                           const fabric::ConfigParams& params)
      41             : {
      42           2 :     if (!server->getConfigs().empty()) // don't do more than one auto config
      43           0 :         return 0;
      44             : 
      45           2 :     Global::instance()->setConfigFAttribute(Config::FATTR_VERSION, 1.2f);
      46             : 
      47           2 :     Config* config = new Config(server);
      48           2 :     config->setName(session + " autoconfig");
      49             : 
      50           2 :     if (!Resources::discover(server, config, session, params))
      51             :     {
      52           0 :         delete config;
      53           0 :         return 0;
      54             :     }
      55             : 
      56           2 :     Display::discoverLocal(config, params);
      57           4 :     const Compounds compounds = Loader::addOutputCompounds(server);
      58           2 :     if (compounds.empty())
      59             :     {
      60           0 :         delete config;
      61           0 :         return 0;
      62             :     }
      63             : 
      64           4 :     const Channels channels = Resources::configureSourceChannels(config);
      65           2 :     Resources::configure(compounds, channels, params);
      66             : 
      67           4 :     std::ofstream configFile;
      68           4 :     const std::string filename = session + ".auto.eqc";
      69           2 :     configFile.open(filename.c_str());
      70           2 :     if (configFile.is_open())
      71             :     {
      72           2 :         std::ostream& previous = lunchbox::Log::getOutput();
      73             : 
      74           2 :         lunchbox::Log::setOutput(configFile);
      75           2 :         lunchbox::Log::instance(__FILE__, __LINE__)
      76           4 :             << lunchbox::disableHeader << Global::instance() << *server
      77           2 :             << std::endl
      78           2 :             << lunchbox::enableHeader;
      79           2 :         lunchbox::Log::setOutput(previous);
      80             : 
      81           2 :         configFile.close();
      82             :     }
      83           2 :     return config;
      84             : }
      85             : 
      86           2 : void Server::release(Config* config)
      87             : {
      88           2 :     const co::Connections& connections = config->getServerConnections();
      89           2 :     config->getServer()->removeListeners(connections);
      90           2 :     delete config;
      91           2 : }
      92             : }
      93             : }
      94          60 : }

Generated by: LCOV version 1.11