LCOV - code coverage report
Current view: top level - co - init.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 21 27 77.8 %
Date: 2015-11-03 13:48:53 Functions: 5 5 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This file is part of Collage <https://github.com/Eyescale/Collage>
       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             : #include "init.h"
      21             : 
      22             : #include "global.h"
      23             : #include "node.h"
      24             : #include "socketConnection.h"
      25             : 
      26             : #include <lunchbox/init.h>
      27             : #include <lunchbox/os.h>
      28             : #include <pression/pluginRegistry.h>
      29             : 
      30             : namespace co
      31             : {
      32             : namespace
      33             : {
      34          21 : static int32_t _checkVersion()
      35             : {
      36          21 :     static std::string version = Version::getString();
      37          21 :     if( version != Version::getString( ))
      38           0 :         LBWARN << "Duplicate DSO loading, Collage v" << version
      39           0 :                << " already loaded while loading v" << Version::getString()
      40           0 :                << std::endl;
      41          21 :     return 0;
      42             : }
      43             : 
      44          21 : static lunchbox::a_int32_t _initialized( _checkVersion( ));
      45             : }
      46             : 
      47          19 : bool _init( const int argc, char** argv )
      48             : {
      49          19 :     if( ++_initialized > 1 ) // not first
      50           0 :         return true;
      51             : 
      52          19 :     if( !lunchbox::init( argc, argv ))
      53           0 :         return false;
      54             : 
      55             :     // init all available plugins
      56          19 :     pression::PluginRegistry& plugins = Global::getPluginRegistry();
      57          19 :     plugins.addLunchboxPlugins();
      58          19 :     plugins.addDirectory( "/opt/local/lib" ); // MacPorts
      59          19 :     plugins.addDirectory( "/usr/local/lib" ); // Homebrew
      60          19 :     plugins.init();
      61             : 
      62             : #ifdef _WIN32
      63             :     WORD    wsVersion = MAKEWORD( 2, 0 );
      64             :     WSADATA wsData;
      65             :     if( WSAStartup( wsVersion, &wsData ) != 0 )
      66             :     {
      67             :         LBERROR << "Initialization of Windows Sockets failed"
      68             :                 << lunchbox::sysError << std::endl;
      69             :         return false;
      70             :     }
      71             : #endif
      72             : 
      73          19 :     return true;
      74             : }
      75             : 
      76          19 : bool exit()
      77             : {
      78          19 :     if( --_initialized > 0 ) // not last
      79           0 :         return true;
      80          19 :     LBASSERT( _initialized == 0 );
      81             : 
      82             : #ifdef _WIN32
      83             :     if( WSACleanup() != 0 )
      84             :     {
      85             :         LBERROR << "Cleanup of Windows Sockets failed"
      86             :                 << lunchbox::sysError << std::endl;
      87             :         return false;
      88             :     }
      89             : #endif
      90             : 
      91             :     // de-initialize registered plugins
      92          19 :     pression::PluginRegistry& plugins = Global::getPluginRegistry();
      93          19 :     plugins.exit();
      94             : 
      95          19 :     return lunchbox::exit();
      96             : }
      97             : 
      98          63 : }

Generated by: LCOV version 1.11