00001 // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 00002 00003 /****************************************************************************** 00004 * 00005 * file: VersionVisitor.h 00006 * 00007 * Copyright (c) 2003, Michael E. Smoot . 00008 * All rights reverved. 00009 * 00010 * See the file COPYING in the top directory of this distribution for 00011 * more information. 00012 * 00013 * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 00014 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00015 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00016 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00017 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00018 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00019 * DEALINGS IN THE SOFTWARE. 00020 * 00021 *****************************************************************************/ 00022 00023 00024 #ifndef TCLAP_VERSION_VISITOR_H 00025 #define TCLAP_VERSION_VISITOR_H 00026 00027 #include <sbia/tclap/CmdLineInterface.h> 00028 #include <sbia/tclap/CmdLineOutput.h> 00029 #include <sbia/tclap/Visitor.h> 00030 00031 namespace TCLAP { 00032 00033 /** 00034 * A Vistor that will call the version method of the given CmdLineOutput 00035 * for the specified CmdLine object and then exit. 00036 */ 00037 class VersionVisitor: public Visitor 00038 { 00039 private: 00040 /** 00041 * Prevent accidental copying 00042 */ 00043 VersionVisitor(const VersionVisitor& rhs); 00044 VersionVisitor& operator=(const VersionVisitor& rhs); 00045 00046 protected: 00047 00048 /** 00049 * The CmdLine of interest. 00050 */ 00051 CmdLineInterface* _cmd; 00052 00053 /** 00054 * The output object. 00055 */ 00056 CmdLineOutput** _out; 00057 00058 public: 00059 00060 /** 00061 * Constructor. 00062 * \param cmd - The CmdLine the output is generated for. 00063 * \param out - The type of output. 00064 */ 00065 VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) 00066 : Visitor(), _cmd( cmd ), _out( out ) { } 00067 00068 /** 00069 * Calls the version method of the output object using the 00070 * specified CmdLine. 00071 */ 00072 void visit() { 00073 (*_out)->version(*_cmd); 00074 throw ExitException(0); 00075 } 00076 00077 }; 00078 00079 } 00080 00081 #endif