Gromacs
2024.4
|
#include <gromacs/onlinehelp/helptopic.h>
Abstract base class for help topics that have simple text and subtopics.
This class implements an internal container for subtopics and provides public methods for adding subtopics (as IHelpTopic objects). Subtopic-related methods from IHelpTopic are implemented to access the internal container. writeHelp() is also implemented such that it uses HelpTopicContext::writeTextBlock() to write out the text returned by a new virtual method helpText(), and a list of subtopics is written after the actual text.
Public Member Functions | |
const char * | name () const override=0 |
Returns the name of the topic. More... | |
const char * | title () const override=0 |
Returns a title for the topic. More... | |
bool | hasSubTopics () const override |
Returns whether the topic has any subtopics. | |
const IHelpTopic * | findSubTopic (const char *name) const override |
Finds a subtopic by name. More... | |
void | writeHelp (const HelpWriterContext &context) const override |
Prints the help text for this topic. More... | |
void | addSubTopic (HelpTopicPointer topic) |
Adds a given topic as a subtopic of this topic. More... | |
template<class Topic > | |
void | registerSubTopic () |
Registers a subtopic of a certain type to this topic. More... | |
Protected Member Functions | |
virtual std::string | helpText () const =0 |
Returns the help text for this topic. More... | |
bool | writeSubTopicList (const HelpWriterContext &context, const std::string &title) const |
Writes the list of subtopics. More... | |
void gmx::AbstractCompositeHelpTopic::addSubTopic | ( | HelpTopicPointer | topic | ) |
Adds a given topic as a subtopic of this topic.
topic | Topis to add. |
std::bad_alloc | if out of memory. |
This topic takes ownership of the object.
|
overridevirtual |
Finds a subtopic by name.
[in] | name | Name of subtopic to find. |
Implements gmx::IHelpTopic.
|
protectedpure virtual |
Returns the help text for this topic.
writeHelp() calls this method to obtain the actual text to format for the topic. Markup substitution etc. is done automatically by writeHelp().
Implemented in gmx::CompositeHelpTopic< HelpText >.
|
overridepure virtual |
Returns the name of the topic.
This should be a single lowercase word, used to identify the topic. It is not used for the root of the help topic tree.
Implements gmx::IHelpTopic.
Implemented in gmx::CompositeHelpTopic< HelpText >.
|
inline |
Registers a subtopic of a certain type to this topic.
Topic | Type of topic to register. |
std::bad_alloc | if out of memory. |
Topic
must be default-constructible and implement IHelpTopic.
This method is provided as a convenient alternative to addSubTopic() for cases where each topic is implemented by a different type (which is a common case outside unit tests).
|
overridepure virtual |
Returns a title for the topic.
May return NULL, in which case the topic is omitted from normal subtopic lists and no title is printed by the methods provided in helptopic.h.
Implements gmx::IHelpTopic.
Implemented in gmx::CompositeHelpTopic< HelpText >.
|
overridevirtual |
Prints the help text for this topic.
[in] | context | Context object for writing the help. |
std::bad_alloc | if out of memory. |
FileIOError | on any I/O error. |
Implements gmx::IHelpTopic.
|
protected |
Writes the list of subtopics.
[in] | context | Context for writing the help. |
[in] | title | Title for the written list. |
std::bad_alloc | if out of memory. |
FileIOError | on any I/O error. |
Subtopics with empty titles are skipped from the list. If there would be no subtopics in the list, title
is not printed either.
This method is provided for cases where helpText() does not provide the needed flexibility and the derived class needs to override writeHelp(). This method can then be called to print the same subtopic list that is printed by the default writeHelp() implementation.