LCOV - code coverage report
Current view: top level - co - init.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 16 22 72.7 %
Date: 2016-12-14 01:26:48 Functions: 5 5 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2016, 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 "dataOStream.h"
      23             : #include "global.h"
      24             : #include "node.h"
      25             : #include "socketConnection.h"
      26             : 
      27             : #include <lunchbox/init.h>
      28             : #include <lunchbox/os.h>
      29             : 
      30             : namespace co
      31             : {
      32             : namespace
      33             : {
      34          22 : static int32_t _checkVersion()
      35             : {
      36          22 :     static std::string version = Version::getString();
      37          22 :     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          22 :     return 0;
      42             : }
      43             : 
      44          22 : static lunchbox::a_int32_t _initialized( _checkVersion( ));
      45             : }
      46             : 
      47          21 : bool _init( const int argc, char** argv )
      48             : {
      49          21 :     if( ++_initialized > 1 ) // not first
      50           0 :         return true;
      51             : 
      52          21 :     if( !lunchbox::init( argc, argv ))
      53           0 :         return false;
      54             : 
      55             : #ifdef _WIN32
      56             :     WORD    wsVersion = MAKEWORD( 2, 0 );
      57             :     WSADATA wsData;
      58             :     if( WSAStartup( wsVersion, &wsData ) != 0 )
      59             :     {
      60             :         LBERROR << "Initialization of Windows Sockets failed"
      61             :                 << lunchbox::sysError << std::endl;
      62             :         return false;
      63             :     }
      64             : #endif
      65             : 
      66          21 :     return true;
      67             : }
      68             : 
      69          21 : bool exit()
      70             : {
      71          21 :     if( --_initialized > 0 ) // not last
      72           0 :         return true;
      73          21 :     LBASSERT( _initialized == 0 );
      74             : 
      75             : #ifdef _WIN32
      76             :     if( WSACleanup() != 0 )
      77             :     {
      78             :         LBERROR << "Cleanup of Windows Sockets failed"
      79             :                 << lunchbox::sysError << std::endl;
      80             :         return false;
      81             :     }
      82             : #endif
      83             : 
      84          21 :     LBDEBUG << DataOStream::printStatistics << std::endl;
      85          21 :     DataOStream::clearStatistics();
      86          21 :     return lunchbox::exit();
      87             : }
      88             : 
      89          66 : }

Generated by: LCOV version 1.11