Merge branch 'release-4-6'
[alexxy/gromacs.git] / src / gromacs / options / filenameoption.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
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.
13
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.
18  *
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.
25  *
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.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \file
32  * \brief
33  * Declares gmx::FileNameOption for setting file name options.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \inpublicapi
37  * \ingroup module_options
38  */
39 #ifndef GMX_OPTIONS_FILENAMEOPTION_H
40 #define GMX_OPTIONS_FILENAMEOPTION_H
41
42 #include <string>
43
44 #include "abstractoption.h"
45 #include "optionfiletype.h"
46
47 namespace gmx
48 {
49
50 class FileNameOptionStorage;
51
52 /*! \brief
53  * Specifies an option that provides file names.
54  *
55  * Public methods in this class do not throw.
56  *
57  * This class is currently a stub implementation.
58  *
59  * \inpublicapi
60  * \ingroup module_options
61  */
62 class FileNameOption : public OptionTemplate<std::string, FileNameOption>
63 {
64     public:
65         //! Initializes an option with the given name.
66         explicit FileNameOption(const char *name)
67             : MyBase(name), filetype_(eftUnknown),
68               bRead_(false), bWrite_(false), bLibrary_(false)
69         {
70         }
71
72         /*! \brief
73          * Sets the type of the file this option accepts.
74          *
75          * This attribute must be provided.
76          */
77         MyClass &filetype(OptionFileType type)
78         { filetype_ = type; return me(); }
79         //! Tells that the file provided by this option is used for input only.
80         MyClass &inputFile()
81         { bRead_ = true; bWrite_ = false; return me(); }
82         //! Tells that the file provided by this option is used for output only.
83         MyClass &outputFile()
84         { bRead_ = false; bWrite_ = true; return me(); }
85         /*! \brief
86          * Tells that the file provided by this option is used for input and
87          * output both.
88          */
89         MyClass &inputOutputFile()
90         { bRead_ = bWrite_ = true; return me(); }
91         /*! \brief
92          * Tells that the file will be looked up in library directories in
93          * addition to working directory.
94          */
95         MyClass &libraryFile() { bLibrary_ = true; return me(); }
96
97     private:
98         //! Creates a FileNameOptionStorage object.
99         virtual AbstractOptionStoragePointer createStorage() const;
100
101         OptionFileType          filetype_;
102         bool                    bRead_;
103         bool                    bWrite_;
104         bool                    bLibrary_;
105
106         /*! \brief
107          * Needed to initialize FileNameOptionStorage from this class without
108          * otherwise unnecessary accessors.
109          */
110         friend class FileNameOptionStorage;
111 };
112
113 } // namespace gmx
114
115 #endif