eqNBody/main.cpp

00001 /*
00002  * Copyright (c) 2009, Philippe Robert <probert@eyescale.ch> 
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 "client.h"
00019 #include "channel.h"
00020 #include "config.h"
00021 #include "node.h"
00022 #include "pipe.h"
00023 #include "window.h"
00024 
00025 #include <eq/eq.h>
00026 #include <stdlib.h>
00027 
00028 using namespace eq::base;
00029 using namespace std;
00030 
00031 class NodeFactory : public eq::NodeFactory
00032 {
00033 public:
00034     virtual eq::Config* createConfig( eq::ServerPtr parent )    { return new eqNbody::Config( parent ); }
00035     virtual eq::Node* createNode( eq::Config* parent )          { return new eqNbody::Node( parent ); }
00036     virtual eq::Pipe* createPipe( eq::Node* parent )            { return new eqNbody::Pipe( parent ); }
00037     virtual eq::Window* createWindow( eq::Pipe* parent )        { return new eqNbody::Window( parent ); }
00038     virtual eq::Channel* createChannel( eq::Window* parent )    { return new eqNbody::Channel( parent ); }
00039 };
00040 
00041 int main( const int argc, char** argv )
00042 {
00043     eqNbody::LocalInitData ld;
00044     NodeFactory nodeFactory;
00045     
00046     if( !eq::init( argc, argv, &nodeFactory ))
00047     {
00048         EQERROR << "Equalizer init failed" << endl;
00049         return EXIT_FAILURE;
00050     }
00051     
00052     RefPtr< eqNbody::Client > client = new eqNbody::Client( ld );
00053     if( !client->initLocal( argc, argv ))
00054     {
00055         EQERROR << "Can't init client" << endl;
00056         eq::exit();
00057         return EXIT_FAILURE;
00058     }
00059 
00060     // Init
00061     if( client->init() != EXIT_SUCCESS ) {
00062         EQERROR << "Can't init client" << endl;
00063         eq::exit();
00064         return EXIT_FAILURE;
00065     }
00066 
00067     // Run the simulation
00068     client->run();
00069 
00070     // Exit
00071     if( client->exit() != EXIT_SUCCESS ) {
00072         EQERROR << "Can't exit client" << endl;
00073     }
00074     
00075     client->exitLocal();    
00076     client = 0;
00077     
00078     eq::exit();
00079     return EXIT_SUCCESS;    
00080 }
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8