LCOV - code coverage report
Current view: top level - seq - application.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 44 74 59.5 %
Date: 2017-12-16 05:07:20 Functions: 12 17 70.6 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2016, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *                          Petros Kataras <petroskataras@gmail.com>
       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 "application.h"
      21             : 
      22             : #include "detail/application.h"
      23             : #include "detail/config.h"
      24             : #include "detail/objectMap.h"
      25             : #include "error.h"
      26             : #include "objectType.h"
      27             : #include "renderer.h"
      28             : #include "viewData.h"
      29             : 
      30             : #include <eq/config.h>
      31             : #include <eq/fabric/configParams.h>
      32             : #include <eq/init.h>
      33             : #include <eq/server.h>
      34             : 
      35             : namespace seq
      36             : {
      37           1 : Application::Application()
      38           1 :     : _impl(0)
      39             : {
      40           1 : }
      41             : 
      42           2 : Application::~Application()
      43             : {
      44           1 :     LBASSERT(!_impl);
      45           1 : }
      46             : 
      47           0 : co::NodePtr Application::getMasterNode()
      48             : {
      49           0 :     eq::Config* config = getConfig();
      50           0 :     LBASSERT(config);
      51           0 :     if (!config)
      52           0 :         return 0;
      53           0 :     return config->getApplicationNode();
      54             : }
      55             : 
      56           2 : eq::Config* Application::getConfig()
      57             : {
      58           2 :     LBASSERT(_impl);
      59           2 :     if (!_impl)
      60           0 :         return 0;
      61           2 :     return _impl->getConfig();
      62             : }
      63             : 
      64           0 : bool Application::registerObject(co::Object* object, const uint32_t type)
      65             : {
      66           0 :     if (!_impl || !_impl->getConfig())
      67           0 :         return false;
      68             : 
      69           0 :     seq::detail::ObjectMap* objectMap = _impl->getConfig()->getObjectMap();
      70           0 :     return objectMap ? objectMap->register_(object, type) : false;
      71             : }
      72             : 
      73           0 : bool Application::deregister(co::Object* object)
      74             : {
      75           0 :     if (!_impl || !_impl->getConfig())
      76           0 :         return false;
      77             : 
      78           0 :     seq::detail::ObjectMap* objectMap = _impl->getConfig()->getObjectMap();
      79           0 :     return objectMap ? objectMap->deregister(object) : false;
      80             : }
      81             : 
      82           2 : void Application::destroyRenderer(Renderer* renderer)
      83             : {
      84           2 :     delete renderer;
      85           2 : }
      86             : 
      87           7 : ViewData* Application::createViewData(View& view)
      88             : {
      89           7 :     return new ViewData(view);
      90             : }
      91             : 
      92           7 : void Application::destroyViewData(ViewData* viewData)
      93             : {
      94           7 :     delete viewData;
      95           7 : }
      96             : 
      97           1 : bool Application::init(const int argc, char** argv, co::Object* initData)
      98             : {
      99           1 :     LBASSERT(!_impl);
     100           1 :     if (_impl)
     101             :     {
     102           0 :         LBERROR << "Already initialized" << std::endl;
     103           0 :         return false;
     104             :     }
     105             : 
     106           1 :     _impl = new detail::Application(this, initData);
     107           1 :     initErrors();
     108           1 :     if (!eq::init(argc, argv, _impl))
     109             :     {
     110           0 :         LBERROR << "Equalizer initialization failed" << std::endl;
     111           0 :         return false;
     112             :     }
     113             : 
     114           1 :     if (!initLocal(argc, argv))
     115             :     {
     116           0 :         LBERROR << "Can't initialization client node" << std::endl;
     117           0 :         exit();
     118           0 :         return false;
     119             :     }
     120             : 
     121           1 :     if (!_impl->init())
     122             :     {
     123           0 :         exit();
     124           0 :         return false;
     125             :     }
     126             : 
     127           1 :     return true;
     128             : }
     129             : 
     130           0 : std::string Application::getHelp()
     131             : {
     132           0 :     return eq::getHelp() + eq::Client::getHelp();
     133             : }
     134             : 
     135           1 : bool Application::run(co::Object* frameData)
     136             : {
     137           1 :     return _impl->run(frameData);
     138             : }
     139             : 
     140           1 : bool Application::exit()
     141             : {
     142           1 :     bool retVal = true;
     143           1 :     if (_impl)
     144           1 :         retVal = _impl->exit();
     145             : 
     146           1 :     if (!exitLocal())
     147           0 :         retVal = false;
     148             : 
     149           1 :     if (!eq::exit())
     150           0 :         retVal = false;
     151             : 
     152           1 :     exitErrors();
     153           1 :     delete _impl;
     154           1 :     _impl = 0;
     155             : 
     156           1 :     LBASSERTINFO(getRefCount() == 1, this->getRefCount());
     157           1 :     return retVal;
     158             : }
     159             : 
     160           2 : void Application::stopRunning()
     161             : {
     162           2 :     getConfig()->stopRunning();
     163           2 : }
     164          30 : }

Generated by: LCOV version 1.11