|
MASA-Core
|
00001 /******************************************************************************* 00002 * 00003 * Copyright (c) 2010-2015 Edans Sandes 00004 * 00005 * This file is part of MASA-Core. 00006 * 00007 * MASA-Core is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * MASA-Core is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with MASA-Core. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 ******************************************************************************/ 00021 00022 #ifndef IALIGNERPARAMETER_HPP_ 00023 #define IALIGNERPARAMETER_HPP_ 00024 00025 00026 /* 00027 * Used in the forkId parameter to indicates that the current process is not 00028 * a forked process 00029 */ 00030 #define NOT_FORKED_INSTANCE (-1) 00031 00032 #define ARGUMENT_OK (0) 00033 #define ARGUMENT_ERROR (-1) 00034 #define ARGUMENT_ERROR_NOT_FOUND (-2) 00035 #define ARGUMENT_ERROR_NO_OPTION (-3) 00036 00037 /** 00038 * The customized parameters of a MASA Extension, used for receiving, 00039 * manipulating and customizing command line parameters. 00040 * 00041 * Each MASA Extension must have its own subclass of the 00042 * IAlignerParameters class. The subclass may customize 00043 * the command line parameters using the <a href="http://www.gnu.org/software/libc/manual/html_node/Getopt.html">GNU getopt C library</a>. 00044 * This is done by calling 00045 * the AbstractAlignerParameters::callGetOpt method with the option structure 00046 * of the getopt library. The IAlignerParameters::processArgument() pure 00047 * virtual method will be invoked whenever MASA encounters one of the 00048 * customized parameters defined with the setArguments method. Using this 00049 * method, all the parameters may be set as an attribute of the subclass. 00050 * 00051 * The aligner must set default values for each parameters because the 00052 * IAlignerParameters::processArgument() 00053 * methods may never be called if there is no argument. 00054 * 00055 * The Aligner class must hold one instance of the IAlignerParameters 00056 * class and it must return this instance in the IAlign::getParameters() method. 00057 * 00058 * One command line that the IAlignerParameters must manipulate is the 00059 * <tt>--fork</tt> parameter, since MASA use this parameter to fork as many 00060 * processes as the architecture supports. If MASA forks many processes, 00061 * the IAlignerParameters::getForkId() method will return the 00062 * identifier of this forked process (from 0 to n-1), or NOT_FORKED_INSTANCE 00063 * if there was no forked process. Use this 00064 * Id to customize the execution uniquely to your architecture. 00065 * 00066 * The AbstractAlignerParameters class implements the basic operations of the 00067 * IAlignerParameter. Extend this class to implement Aligner specific parameters. 00068 * You can create a hierarchy of parameter classes, but always call the overwritten 00069 * methods in order to parse the parameters of the super classes. 00070 * 00071 * @see AbstractAligner, AbstractAlignerParameters 00072 * @see <a href="http://www.gnu.org/software/libc/manual/html_node/Getopt.html">GNU getopt C library</a> (External link) 00073 */ 00074 class IAlignerParameters { 00075 00076 00077 public: 00078 00079 /** 00080 * Prints the usage text in the command line. Use the 00081 * AbstractAlignerParameters::printUsage method to print 00082 * with a pretty bash format. 00083 */ 00084 virtual void printUsage() const = 0; 00085 00086 /** 00087 * Processes each customized command line option. 00088 * 00089 * For instance, suppose that the customized parameter was "--arg=OPT". The 00090 * we will have this methos will be invoked with the following parameters: 00091 * <ul> 00092 * <li>argument_str: the code associated with "--arg" in the option structure; 00093 * <li>argument_str: the "--arg=OPT" string; 00094 * <li>argument_option: the "OPT" string. 00095 * </ul> 00096 * Inside this method, the subclass should set the "arg" variable to OPT. 00097 * 00098 * @param argument_code The code of the argument associated in the 00099 * AbstractAlignerParameters::setArguments method. 00100 * @param argument_str The argument string with its option. 00101 * @param argument_option The option passed to the argument. NULL if there 00102 * is not any argument. 00103 * @return ARGUMENT_OK (0) if succeeded, non-zero otherwise (ARGUMENT_ERROR, 00104 * ARGUMENT_ERROR_NOT_FOUND or ARGUMENT_ERROR_NO_OPTION). If there is 00105 * an error, set the error string using the 00106 * AbstractAlignerParameters::setLastError function. 00107 */ 00108 virtual int processArgument(int argc, char** argv) = 0; 00109 00110 /** 00111 * Returns the last error defined by the AbstractAlignerParameters::setLastError 00112 * method. 00113 * @return the last error string. 00114 */ 00115 virtual const char* getLastError() const = 0; 00116 00117 /** 00118 * Returns the Id of the forked process. 00119 * 00120 * @return the Id of the forked process, from 0 to n-1 (where n is the 00121 * number of forked process), or NOT_FORKED_INSTANCE (-1) if no process 00122 * was forked. 00123 */ 00124 virtual int getForkId() const = 0; 00125 00126 /** 00127 * Defines the Id of the forked process. 00128 * @param forkId the unique Id of this forked process. 00129 */ 00130 virtual void setForkId(int forkId) = 0; 00131 00132 00133 protected: 00134 /* protected constructors avoid the direct creation/deletion of this interface */ 00135 ~IAlignerParameters() {}; 00136 IAlignerParameters() {}; 00137 00138 }; 00139 00140 00141 #endif /* IALIGNERPARAMETER_HPP_ */
1.7.6.1