VR-Link API Documentation for HLA Evolved
cmdUnlabeledValueArg.h
Go to the documentation of this file.
00001 
00002 /****************************************************************************** 
00003  * 
00004  *  file:  UnlabeledValueArg.h
00005  * 
00006  *  Copyright (c) 2003, Michael E. Smoot .
00007  *  Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
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 DtCmdLine_UNLABELED_VALUE_ARGUMENT_H
00025 #define DtCmdLine_UNLABELED_VALUE_ARGUMENT_H
00026 
00030 
00031 #include <string>
00032 #include <vector>
00033 
00034 #include "cmdValueArg.h"
00035 
00036 #ifdef DtUSE_UTILITIES_NAMESPACE
00037 namespace DtUSE_UTILITIES_NAMESPACE
00038 {
00039 #endif
00040 
00041    namespace DtCmdLine {
00042 
00049 
00050       template<class T>
00051          class UnlabeledValueArg : public ValueArg<T>
00052          {
00053 
00056             using ValueArg<T>::_ignoreable;
00057             using ValueArg<T>::_hasBlanks;
00058             using ValueArg<T>::_extractValue;
00059             using ValueArg<T>::_typeDesc;
00060             using ValueArg<T>::_name;
00061             using ValueArg<T>::_description;
00062             using ValueArg<T>::_alreadySet;
00063 
00064          public:
00065 
00089             UnlabeledValueArg( const std::string& name, 
00090                                const std::string& desc, 
00091                                T value,
00092                                const std::string& typeDesc,
00093                                bool ignoreable = false,
00094                                Visitor* v = NULL); 
00095 
00120             UnlabeledValueArg( const std::string& name, 
00121                                const std::string& desc, 
00122                                T value,
00123                                const std::string& typeDesc,
00124                                CmdLineInterface& parser,
00125                                bool ignoreable = false,
00126                                Visitor* v = NULL );               
00127 
00149             UnlabeledValueArg( const std::string& name, 
00150                                const std::string& desc, 
00151                                T value,
00152                                const std::vector<T>& allowed,
00153                                bool ignoreable = false,
00154                                Visitor* v = NULL ); 
00155 
00156 
00179             UnlabeledValueArg( const std::string& name, 
00180                                const std::string& desc, 
00181                                T value,
00182                                const std::vector<T>& allowed,
00183                                CmdLineInterface& parser,
00184                                bool ignoreable = false,
00185                                Visitor* v = NULL);
00186 
00195             virtual bool processArg(int* i, std::vector<std::string>& args); 
00196 
00200             virtual std::string shortID(const std::string& val="val") const;
00201 
00205             virtual std::string longID(const std::string& val="val") const;
00206 
00210             virtual bool operator==(const Arg& a ) const;
00211 
00216             virtual void addToList( std::list<Arg*>& argList ) const;
00217          };
00218 
00222       template<class T>
00223          UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, 
00224                                                  const std::string& desc, 
00225                                                  T val,
00226                                                  const std::string& typeDesc,
00227                                                  bool ignoreable,
00228                                                  Visitor* v)
00229          : ValueArg<T>("", name, desc, true, val, typeDesc, v)
00230          { 
00231             _ignoreable = ignoreable;
00232          }
00233 
00234       template<class T>
00235          UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, 
00236                                                  const std::string& desc, 
00237                                                  T val,
00238                                                  const std::string& typeDesc,
00239                                                  CmdLineInterface& parser,
00240                                                  bool ignoreable,
00241                                                  Visitor* v)
00242          : ValueArg<T>("", name, desc, true, val, typeDesc, v)
00243          { 
00244             _ignoreable = ignoreable;
00245             parser.add( this );
00246          }
00247 
00251       template<class T>
00252          UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, 
00253                                                  const std::string& desc, 
00254                                                  T val,
00255                                                  const std::vector<T>& allowed,
00256                                                  bool ignoreable,
00257                                                  Visitor* v)
00258          : ValueArg<T>("", name, desc, true, val, allowed, v)
00259          { 
00260             _ignoreable = ignoreable;
00261          }
00262 
00263       template<class T>
00264          UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, 
00265                                                  const std::string& desc, 
00266                                                  T val,
00267                                                  const std::vector<T>& allowed,
00268                                                  CmdLineInterface& parser,
00269                                                  bool ignoreable,
00270                                                  Visitor* v)
00271          : ValueArg<T>("", name, desc, true, val, allowed,  v)
00272          { 
00273             _ignoreable = ignoreable;
00274             parser.add( this );
00275          }
00276 
00280       template<class T>
00281          bool UnlabeledValueArg<T>::processArg(int *i, std::vector<std::string>& args) 
00282          {
00283 
00284             if ( _alreadySet )
00285                return false;
00286 
00287             if ( _hasBlanks( args[*i] ) )
00288                return false;
00289 
00291 
00292             _extractValue( args[*i] );
00293             _alreadySet = true;
00294             return true;
00295          }
00296 
00300       template<class T>
00301          std::string UnlabeledValueArg<T>::shortID(const std::string& val) const
00302          {
00303             std::string id = "<" + _typeDesc + ">";
00304 
00305             return id;
00306          }
00307 
00311       template<class T>
00312          std::string UnlabeledValueArg<T>::longID(const std::string& val) const
00313          {
00317             std::string id = "<" + _typeDesc + ">";
00318 
00319             return id;  
00320          }
00321 
00325       template<class T>
00326          bool UnlabeledValueArg<T>::operator==(const Arg& a ) const
00327          {
00328             if ( _name == a.getName() || _description == a.getDescription() )
00329                return true;
00330             else
00331                return false;
00332          }
00333 
00334       template<class T>
00335          void UnlabeledValueArg<T>::addToList( std::list<Arg*>& argList ) const
00336          {
00337             argList.push_back( (Arg*)this );
00338          }
00339 
00340    }
00341 
00342 #ifdef DtUSE_UTILITIES_NAMESPACE
00343 }     
00344 #endif
00345 
00346 #endif

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)