3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
33 * Declares gmx::FileNameOption and gmx::FileNameOptionInfo.
35 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
37 * \ingroup module_options
39 #ifndef GMX_OPTIONS_FILENAMEOPTION_H
40 #define GMX_OPTIONS_FILENAMEOPTION_H
44 #include "abstractoption.h"
45 #include "optionfiletype.h"
50 class FileNameOptionInfo;
51 class FileNameOptionStorage;
54 * Specifies an option that provides file names.
56 * Public methods in this class do not throw.
58 * This class is currently a stub implementation.
61 * \ingroup module_options
63 class FileNameOption : public OptionTemplate<std::string, FileNameOption>
66 //! OptionInfo subclass corresponding to this option type.
67 typedef FileNameOptionInfo InfoType;
69 //! Initializes an option with the given name.
70 explicit FileNameOption(const char *name)
71 : MyBase(name), filetype_(eftUnknown),
72 bRead_(false), bWrite_(false), bLibrary_(false)
77 * Sets the type of the file this option accepts.
79 * This attribute must be provided.
81 MyClass &filetype(OptionFileType type)
82 { filetype_ = type; return me(); }
83 //! Tells that the file provided by this option is used for input only.
85 { bRead_ = true; bWrite_ = false; return me(); }
86 //! Tells that the file provided by this option is used for output only.
88 { bRead_ = false; bWrite_ = true; return me(); }
90 * Tells that the file provided by this option is used for input and
93 MyClass &inputOutputFile()
94 { bRead_ = bWrite_ = true; return me(); }
96 * Tells that the file will be looked up in library directories in
97 * addition to working directory.
99 MyClass &libraryFile() { bLibrary_ = true; return me(); }
102 //! Creates a FileNameOptionStorage object.
103 virtual AbstractOptionStoragePointer createStorage() const;
105 OptionFileType filetype_;
111 * Needed to initialize FileNameOptionStorage from this class without
112 * otherwise unnecessary accessors.
114 friend class FileNameOptionStorage;
118 * Wrapper class for accessing file name option information.
121 * \ingroup module_options
123 class FileNameOptionInfo : public OptionInfo
126 //! Creates an option info object for the given option.
127 explicit FileNameOptionInfo(FileNameOptionStorage *option);
129 //! Whether the option specifies an input file.
130 bool isInputFile() const;
131 //! Whether the option specifies an output file.
132 bool isOutputFile() const;
133 //! Whether the option specifies a file used for both input and output.
134 bool isInputOutputFile() const;
136 * Whether the option specifies a library file.
138 * \see FileNameOption::libraryFile()
140 bool isLibraryFile() const;
143 const FileNameOptionStorage &option() const;