BasicFramework.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: BasicFramework.cpp 1356 2008-08-19 16:01:12Z architest $"
00002 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 //
00026 //  Copyright 2004, The University of Texas at Austin
00027 //
00028 //============================================================================
00029 
00030 //============================================================================
00031 //
00032 //This software developed by Applied Research Laboratories at the University of
00033 //Texas at Austin, under contract to an agency or agencies within the U.S.
00034 //Department of Defense. The U.S. Government retains all rights to use,
00035 //duplicate, distribute, disclose, or release this software.
00036 //
00037 //Pursuant to DoD Directive 523024
00038 //
00039 // DISTRIBUTION STATEMENT A: This software has been approved for public
00040 //                           release, distribution is unlimited.
00041 //
00042 //=============================================================================
00043 
00044 
00045 #include "Exception.hpp"
00046 #include "BasicFramework.hpp"
00047 
00048 
00049 namespace gpstk
00050 {
00051 
00052    using namespace std;
00053 
00054 
00055    BasicFramework :: BasicFramework( const string& applName,
00056                                      const string& applDesc )
00057       throw()
00058          : debugLevel(0),
00059            verboseLevel(0),
00060            argv0(applName),
00061            appDesc(applDesc),
00062            debugOption('d', "debug", "Increase debug level"),
00063            verboseOption('v', "verbose", "Increase verbosity"),
00064            helpOption('h', "help", "Print help usage")
00065    {} // End of constructor 'BasicFramework::BasicFramework()'
00066 
00067 
00068 
00069    bool BasicFramework :: initialize( int argc,
00070                                       char *argv[],
00071                                       bool pretty )
00072       throw()
00073    {
00074 
00075          // Creating the parser here ensures that all the subclasses'
00076          // option objects are constructed.
00077       CommandOptionParser cop(appDesc);
00078 
00079       cop.parseOptions(argc, argv);
00080 
00081       if (helpOption.getCount())
00082       {
00083          cop.displayUsage(cerr, pretty);
00084          return false;
00085       }
00086 
00087       if (cop.hasErrors())
00088       {
00089          cop.dumpErrors(cerr);
00090          cop.displayUsage(cerr, pretty);
00091          return false;
00092       }
00093 
00094       debugLevel = debugOption.getCount();
00095       verboseLevel = verboseOption.getCount();
00096 
00097       return true;
00098 
00099    }  // End of method 'BasicFramework::initialize()'
00100 
00101 
00102 
00103    bool BasicFramework :: run()
00104       throw()
00105    {
00106 
00107       try
00108       {
00109          completeProcessing();
00110       }
00111       catch (Exception& exc)
00112       {
00113          cerr << exc;
00114          return false;
00115       }
00116       catch (...)
00117       {
00118          cerr << "Caught unknown exception" << endl;
00119          return false;
00120       }
00121 
00122       shutDown();
00123 
00124       return true;
00125 
00126    }  // End of method 'BasicFramework::run()'
00127 
00128 
00129 
00130    void BasicFramework :: completeProcessing()
00131    {
00132       additionalSetup();
00133 
00134       spinUp();
00135 
00136       process();
00137 
00138    }  // End of method 'BasicFramework::completeProcessing()'
00139 
00140 
00141 }  // End of namespace gpstk

Generated on Thu Jul 29 03:30:51 2010 for GPS ToolKit Software Library by  doxygen 1.3.9.1