Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / onlinehelp / helptopicinterface.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::HelpTopicInterface.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \inpublicapi
37  * \ingroup module_onlinehelp
38  */
39 #ifndef GMX_ONLINEHELP_HELPTOPICINTERFACE_H
40 #define GMX_ONLINEHELP_HELPTOPICINTERFACE_H
41
42 #include "../utility/uniqueptr.h"
43
44 namespace gmx
45 {
46
47 class HelpWriterContext;
48
49 /*! \brief
50  * Provides a single online help topic.
51  *
52  * \if libapi
53  * Implementations of these methods should not throw, except that writeHelp()
54  * is allowed to throw on out-of-memory or I/O errors since those it cannot
55  * avoid.
56  *
57  * Header helptopic.h contains classes that implement this interface and make
58  * it simple to write concrete help topic classes.
59  * \endif
60  *
61  * This class is in a public header, and exposed through HelpTopicPointer, but
62  * it is not intended to be used outside the library.  To access a help topic
63  * with public API methods, use HelpManager.
64  *
65  * \inlibraryapi
66  * \ingroup module_onlinehelp
67  */
68 class HelpTopicInterface
69 {
70     public:
71         virtual ~HelpTopicInterface() {}
72
73         /*! \brief
74          * Returns the name of the topic.
75          *
76          * This should be a single lowercase word, used to identify the topic.
77          * It is not used for the root of the help topic tree.
78          */
79         virtual const char *name() const = 0;
80         /*! \brief
81          * Returns a title for the topic.
82          *
83          * May return NULL, in which case the topic is omitted from normal
84          * subtopic lists and no title is printed by the methods provided in
85          * helptopic.h.
86          */
87         virtual const char *title() const = 0;
88
89         //! Returns whether the topic has any subtopics.
90         virtual bool hasSubTopics() const = 0;
91         /*! \brief
92          * Finds a subtopic by name.
93          *
94          * \param[in] name  Name of subtopic to find.
95          * \returns   Pointer to the found subtopic, or NULL if matching topic
96          *      is not found.
97          */
98         virtual const HelpTopicInterface *findSubTopic(const char *name) const = 0;
99
100         /*! \brief
101          * Prints the help text for this topic.
102          *
103          * \param[in] context  Context object for writing the help.
104          * \throws    std::bad_alloc if out of memory.
105          * \throws    FileIOError on any I/O error.
106          */
107         virtual void writeHelp(const HelpWriterContext &context) const = 0;
108 };
109
110 //! Smart pointer type to manage a HelpTopicInterface object.
111 typedef gmx_unique_ptr<HelpTopicInterface>::type HelpTopicPointer;
112
113 } // namespace gmx
114
115 #endif