OpenFOAM logo
Open Source CFD Toolkit

argList.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     argList
00027 
00028 Description
00029     Make, print and check argList
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #ifndef argList_H
00034 #define argList_H
00035 
00036 #include "stringList.H"
00037 #include "SLList.H"
00038 #include "HashTable.H"
00039 #include "word.H"
00040 #include "fileName.H"
00041 #include "parRun.H"
00042 #include "sigFpe.H"
00043 #include "sigInt.H"
00044 #include "sigQuit.H"
00045 #include "sigSegv.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00053 
00054 class argList
00055 {
00056     // Private data
00057 
00058         stringList args_;
00059         HashTable<string> options_;
00060 
00061         word executable_;
00062         fileName rootPath_;
00063         fileName globalCase_;
00064         fileName case_;
00065         bool parRun_;
00066 
00067         ParRunControl parRunControl_;
00068 
00069         // Signal handlers
00070         sigFpe sigFpe_;
00071         sigInt sigInt_;
00072         sigQuit sigQuit_;
00073         sigSegv sigSegv_;
00074 
00075 
00076     // Private member functions
00077 
00078         int findArg(const string& arg);
00079 
00080 
00081 public:
00082 
00083     // Static data members
00084 
00085         static SLList<string> validArgs;
00086         static HashTable<string> validOptions;
00087         static HashTable<string> validParOptions;
00088 
00089         class initValidTables
00090         {
00091         public:
00092 
00093             initValidTables();
00094         };
00095 
00096 
00097     // Constructors
00098 
00099         //- Construct arom argc and argv
00100         argList(int& argc, char**& argv);
00101 
00102 
00103     // Destructor
00104 
00105         virtual ~argList();
00106 
00107 
00108     // Member functions
00109 
00110         // Access
00111 
00112             //- Return arguments
00113             const stringList& args() const
00114             {
00115                 return args_;
00116             }
00117 
00118             //- Return options
00119             const HashTable<string>& options() const
00120             {
00121                 return options_;
00122             }
00123 
00124             //- Name of executable
00125             const word& executable() const
00126             {
00127                 return executable_;
00128             }
00129 
00130             //- Return root path
00131             const fileName& rootPath() const
00132             {
00133                 return rootPath_;
00134             }
00135 
00136             //- Return case name
00137             const fileName& globalCaseName() const
00138             {
00139                 return globalCase_;
00140             }
00141 
00142             //- Return case name
00143             //  or parallel processor case name for parallel run
00144             const fileName& caseName() const
00145             {
00146                 return case_;
00147             }
00148 
00149             //- Return path
00150             fileName path() const
00151             {
00152                 return rootPath()/caseName();
00153             }
00154 
00155             //- Is this a parallel run
00156             bool parRun() const
00157             {
00158                 return parRun_;
00159             }
00160 
00161 
00162         // Edit
00163 
00164             //- Remove the parallel options
00165             static void noParallel();
00166 
00167 
00168         // Print
00169 
00170             //- Print usage
00171             void printUsage() const;
00172 
00173 
00174         // Check
00175 
00176             //- Check argument list
00177             bool check() const;
00178 
00179             //- Check root path and case path
00180             bool checkRootCase() const;
00181 };
00182 
00183 
00184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00185 
00186 } // End namespace Foam
00187 
00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00189 
00190 #endif
00191 
00192 // ************************************************************************* //
For further information go to www.openfoam.org