Equalizer 1.0

osgScaleViewer.cpp

00001 
00002 /*
00003  * Copyright (c)
00004  *   2008-2009, Thomas McGuire <thomas.mcguire@student.uni-siegen.de>
00005  *   2010, Stefan Eilemann <eile@eyescale.ch>
00006  *   2010, Sarah Amsellem <sarah.amsellem@gmail.com>
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice, this
00012  *   list of conditions and the following disclaimer.
00013  * - Redistributions in binary form must reproduce the above copyright notice,
00014  *   this list of conditions and the following disclaimer in the documentation
00015  *   and/or other materials provided with the distribution.
00016  * - Neither the name of Eyescale Software GmbH nor the names of its
00017  *   contributors may be used to endorse or promote products derived from this
00018  *   software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00021  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00026  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00029  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  */
00032 
00033 #include "osgScaleViewer.h"
00034 
00035 #include "config.h"
00036 
00037 namespace osgScaleViewer
00038 {
00039 
00040 OSGScaleViewer::OSGScaleViewer( const InitData& initData )
00041     : _initData( initData )
00042 {
00043 }
00044 
00045 int OSGScaleViewer::run()
00046 {
00047     // 1. connect to server
00048     eq::ServerPtr server = new eq::Server();
00049     if( !connectServer( server ))
00050     {
00051         EQERROR << "Can't open server" << std::endl;
00052         return EXIT_FAILURE;
00053     }
00054 
00055     // 2. choose config
00056     eq::ConfigParams configParams;
00057     Config* config = static_cast<Config*>( server->chooseConfig( configParams));
00058 
00059     if( !config )
00060     {
00061         EQERROR << "No matching config on server" << std::endl;
00062         disconnectServer( server );
00063         return EXIT_FAILURE;
00064     }
00065 
00066     config->setInitData( _initData );
00067     if( !config->init( ))
00068     {
00069         server->releaseConfig( config );
00070         disconnectServer( server );
00071         return EXIT_FAILURE;
00072     }
00073     else if( config->getError( ))
00074         EQWARN << "Error during initialization: " << config->getError()
00075                << std::endl;
00076 
00077     // 4. run main loop
00078     while( config->isRunning( ))
00079     {
00080         config->startFrame();
00081         config->finishFrame();
00082     }
00083     config->finishAllFrames();
00084 
00085     // 5. exit config
00086     config->exit();
00087 
00088     // 6. cleanup and exit
00089     server->releaseConfig( config );
00090     if( !disconnectServer( server ))
00091         EQERROR << "Client::disconnectServer failed" << std::endl;
00092 
00093     server = 0;
00094 
00095     return EXIT_SUCCESS;
00096 }
00097 
00098 }
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3