MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/Core/MOOSDB/MOOSDBMain.cpp
Go to the documentation of this file.
00001 
00002 //
00003 //   MOOS - Mission Oriented Operating Suite
00004 //
00005 //   A suit of Applications and Libraries for Mobile Robotics Research
00006 //   Copyright (C) 2001-2005 Massachusetts Institute of Technology and
00007 //   Oxford University.
00008 //
00009 //   This software was written by Paul Newman at MIT 2001-2002 and Oxford
00010 //   University 2003-2005. email: pnewman@robots.ox.ac.uk.
00011 //
00012 //   This file is part of a  MOOS Core Component.
00013 //
00014 //   This program is free software; you can redistribute it and/or
00015 //   modify it under the terms of the GNU General Public License as
00016 //   published by the Free Software Foundation; either version 2 of the
00017 //   License, or (at your option) any later version.
00018 //
00019 //   This program is distributed in the hope that it will be useful,
00020 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00022 //   General Public License for more details.
00023 //
00024 //   You should have received a copy of the GNU General Public License
00025 //   along with this program; if not, write to the Free Software
00026 //   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00027 //   02111-1307, USA.
00028 //
00030 #ifdef _WIN32
00031 #pragma warning(disable : 4786)
00032 #endif
00033 
00034 #include <MOOSLIB/MOOSLib.h>
00035 #include "MOOSDB.h"
00036 #include <iostream>
00037 #include <string>
00038 #include <memory>
00039 
00040 #include "MOOSDBHTTPServer.h"
00041 
00042 int main(int argc , char * argv[])
00043 {
00044     //default command line parameters - Mission file and port number
00045     const char * sMissionFile = "Mission.moos";
00046 
00047     if(argc>1)
00048     {
00049         sMissionFile = argv[1];
00050     }
00051 
00052     //this is a main MOOS DB Object
00053     CMOOSDB DB;
00054     DB.Run(sMissionFile);
00055 
00056     //this is a webserver object which allows you
00057     //to access and prod the MOOSDB via HTTP
00058 #ifdef MOOSDB_HAS_WEBSERVER
00059     long lWebServerPort = 0;    
00060 
00061     CMOOSFileReader missionReader;
00062     if(missionReader.SetFile(sMissionFile))
00063     {
00064         std::string sWebServerPort;        
00065         if(missionReader.GetValue("WEBSERVERPORT",sWebServerPort))
00066         {
00067             lWebServerPort = atoi(sWebServerPort.c_str());
00068         }
00069     }
00070 
00071     // Fire off the web server
00072     std::auto_ptr<CMOOSDBHTTPServer> pWebServer;
00073     if (lWebServerPort > 0)
00074         pWebServer = std::auto_ptr<CMOOSDBHTTPServer> (new CMOOSDBHTTPServer(DB.GetDBPort(), lWebServerPort));
00075     else
00076         pWebServer = std::auto_ptr<CMOOSDBHTTPServer> (new CMOOSDBHTTPServer(DB.GetDBPort()));
00077 
00078 #endif
00079 
00080     //nothing to do - all the threads in the DB object
00081     //do the work
00082     while(1)
00083     {
00084         MOOSPause(1000);
00085     }
00086 
00087     return 0;
00088 }
00089 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines