eqPly/main.cpp

00001 
00002 /* Copyright (c) 2005-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #include "eqPly.h"
00019 
00020 #include "channel.h"
00021 #include "config.h"
00022 #include "node.h"
00023 #include "pipe.h"
00024 #include "view.h"
00025 #include "window.h"
00026 
00027 #include <stdlib.h>
00028 
00029 using namespace eq::base;
00030 using namespace std;
00031 
00032 class NodeFactory : public eq::NodeFactory
00033 {
00034 public:
00035     virtual eq::Config*  createConfig( eq::ServerPtr parent )
00036         { return new eqPly::Config( parent ); }
00037     virtual eq::Node*    createNode( eq::Config* parent )  
00038         { return new eqPly::Node( parent ); }
00039     virtual eq::Pipe*    createPipe( eq::Node* parent )
00040         { return new eqPly::Pipe( parent ); }
00041     virtual eq::Window*  createWindow( eq::Pipe* parent )
00042         { return new eqPly::Window( parent ); }
00043     virtual eq::Channel* createChannel( eq::Window* parent )
00044         { return new eqPly::Channel( parent ); }
00045     virtual eq::View* createView() { return new eqPly::View(); }
00046 };
00047 
00048 int main( const int argc, char** argv )
00049 {
00050     // 1. parse arguments
00051     eqPly::LocalInitData initData;
00052     initData.parseArguments( argc, argv );
00053 
00054     // 2. Redirect log output to file, if requested
00055     std::ofstream* logFile = 0;
00056     const std::string& logFilename = initData.getLogFilename();
00057     if( !logFilename.empty( ))
00058     {
00059         logFile = new ofstream( logFilename.c_str( ));
00060         eq::base::Log::setOutput( *logFile );
00061     }
00062     
00063     // 3. Equalizer initialization
00064     NodeFactory nodeFactory;
00065     if( !eq::init( argc, argv, &nodeFactory ))
00066     {
00067         EQERROR << "Equalizer init failed" << endl;
00068         return EXIT_FAILURE;
00069     }
00070     
00071     // 4. initialization of local client node
00072     RefPtr< eqPly::EqPly > client = new eqPly::EqPly( initData );
00073     if( !client->initLocal( argc, argv ))
00074     {
00075         EQERROR << "Can't init client" << endl;
00076         eq::exit();
00077         return EXIT_FAILURE;
00078     }
00079 
00080     // 5. run client
00081     const int ret = client->run();
00082 
00083     // 6. cleanup and exit
00084     client->exitLocal();
00085 
00086     // TODO EQASSERTINFO( client->getRefCount() == 1, client->getRefCount( ));
00087     client = 0;
00088 
00089     eq::exit();
00090 
00091     if( logFile )
00092         logFile->close();
00093     delete logFile;
00094 
00095     return ret;
00096 }
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8