LCOV - code coverage report
Current view: top level - eq/server/config - server.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 29 34 85.3 %
Date: 2014-06-18 Functions: 4 4 100.0 %

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

Generated by: LCOV version 1.10