Slice Tools libFoundation |
example-minimal.ccDemonstrates a minimal use of Foundation.This file can be used as a template for new programs to incorporate the services provided by Foundation. // $Id: example-minimal.cc,v 1.1 2005/07/29 02:55:16 mschatz Exp $ // Demonstrates a minimal template for using Foundation. // Only need to include the main header file #include "Foundation.hh" using namespace std; // This could be any function that the program uses void doWork() { cout << "In doWork()" << endl; } // Instantiates Foundation, parses standard options, calls doWork int main(int argc, char ** argv) { string helptext = "Foundation minimal example"; string version = "Foundation example-minimal 1.0"; string dependencies = "Foundation"; try { // Instantiate a new Foundation object Foundation *app = new Foundation (version, helptext, dependencies, argc, argv); // Parse the command line for options (-h, -V, --depend, ...) app->handleStandardOptions(); // Call your main functions here. doWork(); // Close logfiles, configfiles, and options handler by deleting the // Foundation object delete app; } catch (ExitProgramNormally e) { // Non-fatal error (help, version, or dependencies were requested) // fall through to return 0 below } catch (Exception e) { // Fatal error, print out message cerr << e << endl; // Exit with a non-zero error message exit (100); } return 0; } |