Debian Codegraph @

plugins/dm.conversation/ConversationCommandLibrary.h

raw
1 #pragma once
2
3 #include "ConversationCommandInfo.h"
4
5 class wxChoice;
6
7 namespace conversation
8 {
9
10 namespace
11 {
12 const std::string GKEY_CONVERSATION_COMMAND_INFO_PREFIX =
13 "/conversationSystem/conversationCommandPrefix";
14 }
15
16 /**
17 * greebo: This class holds all the possible conversation command types,
18 * indexed by name. Each conversation commmand is parsed from an entityDef
19 * matching a given prefix and holding a bunch of information about that command.
20 *
21 * The ConversationCommand editor is using this information to construct
22 * the UI elements.
23 */
24 class ConversationCommandLibrary
25 {
26 // The map containing the named information
27 ConversationCommandInfoMap _commandInfo;
28
29 // Private constructor, loads all matching entityDefs
30 ConversationCommandLibrary();
31
32 public:
33 // Accessor to the singleton instance
34 static ConversationCommandLibrary& Instance();
35
36 /**
37 * Returns the command info with the given typename or ID. Throws an exception if not found.
38 *
39 * @throws: std::runtime error if the named info structure could not be found.
40 */
41 const ConversationCommandInfo& findCommandInfo(const std::string& name);
42 const ConversationCommandInfo& findCommandInfo(int id);
43
44 /**
45 * greebo: This populates the given choice field with all available commands. The command ID
46 * will be attached to the items as wxStringClientData.
47 */
48 void populateChoice(wxChoice* choice);
49
50 private:
51 // Loads all entityDefs matching the given prefix
52 void loadConversationCommands();
53 };
54
55 } // namespace conversation