OXYGENHUB
◆ main openmsx / src / commands / InfoTopic.hh
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef INFOTOPIC_HH
2
#define INFOTOPIC_HH
3
4
#include "Completer.hh"
5
#include <span>
6
#include <string>
7
#include <vector>
8
9
namespace openmsx {
10
11
class TclObject;
12
class Interpreter;
13
class InfoCommand;
14
15
class InfoTopic : public Completer
16
{
17
public:
18
	InfoTopic(const InfoTopic&) = delete;
19
	InfoTopic(InfoTopic&&) = delete;
20
	InfoTopic& operator=(const InfoTopic&) = delete;
21
	InfoTopic& operator=(InfoTopic&&) = delete;
22
23
	/** Show info on this topic
24
	  * @param tokens Tokenized command line;
25
	  *     tokens[1] is the topic.
26
	  * @param result The result of this topic must be assigned to this
27
	  *               parameter.
28
	  * @throw CommandException Thrown when there was an error while
29
	  *                         executing this InfoTopic.
30
	  */
31
	virtual void execute(std::span<const TclObject> tokens,
32
	                     TclObject& result) const = 0;
33
34
	/** Print help for this topic.
35
	  * @param tokens Tokenized command line;
36
	  *     tokens[1] is the topic.
37
	  */
38
	[[nodiscard]] std::string help(std::span<const TclObject> tokens) const override = 0;
39
40
	/** Attempt tab completion for this topic.
41
	  * Default implementation does nothing.
42
	  * @param tokens Tokenized command line;
43
	  *     tokens[1] is the topic.
44
	  *     The last token is incomplete, this method tries to complete it.
45
	  */
46
	void tabCompletion(std::vector<std::string>& tokens) const override;
47
48
	[[nodiscard]] Interpreter& getInterpreter() const final;
49
50
protected:
51
	InfoTopic(InfoCommand& infoCommand, const std::string& name);
52
	~InfoTopic();
53
54
private:
55
	InfoCommand& infoCommand;
56
};
57
58
} // namespace openmsx
59
60
#endif