osgEarth 2.1.1

/home/cube/sources/osgearth/src/applications/osgearth_version/osgearth_version.cpp

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003 * Copyright 2008-2010 Pelican Mapping
00004 * http://osgearth.org
00005 *
00006 * osgEarth is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU Lesser General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU Lesser General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU Lesser General Public License
00017 * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018 */
00019 
00020 #include <iostream>
00021 #include <osg/Notify>
00022 #include <osg/ArgumentParser>
00023 #include <osg/ApplicationUsage>
00024 #include <osgEarth/Version>
00025 #include <osgEarth/Registry>
00026 
00027 using namespace std;
00028 
00029 int main( int argc, char** argv)
00030 {
00031     osg::ArgumentParser arguments(&argc, argv);
00032     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName() + " [options]");
00033     arguments.getApplicationUsage()->addCommandLineOption("-h or --help",                   "Display this information");
00034     arguments.getApplicationUsage()->addCommandLineOption("--caps",                         "Print out system capabilities");
00035     arguments.getApplicationUsage()->addCommandLineOption("--version-number",               "Print out version number only");
00036     arguments.getApplicationUsage()->addCommandLineOption("--major-number",                 "Print out major version number only");
00037     arguments.getApplicationUsage()->addCommandLineOption("--minor-number",                 "Print out minor version number only");
00038     arguments.getApplicationUsage()->addCommandLineOption("--patch-number",                 "Print out patch version number only");
00039     arguments.getApplicationUsage()->addCommandLineOption("--so-number ",                   "Print out shared object version number only");    
00040 
00041     // if user request help write it out to cout.
00042     if (arguments.read("-h") || arguments.read("--help"))
00043     {
00044         cout << arguments.getApplicationUsage()->getCommandLineUsage() << endl;
00045         arguments.getApplicationUsage()->write(cout, arguments.getApplicationUsage()->getCommandLineOptions());
00046         return 1;
00047     }
00048 
00049     if (arguments.read("--version-number"))
00050     {
00051         cout << osgEarthGetVersion() << endl;
00052         return 0;
00053     }
00054 
00055     if (arguments.read("--major-number"))
00056     {
00057         cout << OSGEARTH_MAJOR_VERSION << endl;
00058         return 0;
00059     }
00060 
00061     if (arguments.read("--minor-number"))
00062     {
00063         cout << OSGEARTH_MINOR_VERSION << endl;
00064         return 0;
00065     }
00066 
00067     if (arguments.read("--patch-number"))
00068     {
00069         cout << OSGEARTH_PATCH_VERSION << endl;
00070         return 0;
00071     }
00072 
00073     if (arguments.read("--soversion-number") || arguments.read("--so-number") )
00074     {
00075         cout << osgEarthGetSOVersion() << endl;
00076         return 0;
00077     }    
00078 
00079     cout << osgEarthGetLibraryName() << " " << osgEarthGetVersion() << endl << endl;
00080 
00081     if ( arguments.read("--caps") )
00082     {
00083         osgEarth::setNotifyLevel( osg::INFO );
00084         osgEarth::Registry::instance()->getCapabilities();
00085     }
00086 
00087     return 0;
00088 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines