MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / RegisterCommand

Method RegisterCommand

src/engine/ConsoleObjects.cpp:127–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 Object* RegisterCommand(CommandDesc const& desc)
128 {
129 if (IsValidName(desc.name))
130 {
131 if (!desc.on_execute)
132 {
133 donut::log::fatal("attempting to register console command '%s' with no execution function", desc.name);
134 }
135
136 std::lock_guard<std::mutex> lock(m_Mutex);
137 if (auto it = m_Dictionary.find(desc.name); it == m_Dictionary.end())
138 {
139 auto* cmd = new Command(desc.description, desc.on_execute, desc.on_suggest);
140 m_Dictionary[desc.name] = cmd;
141 return cmd;
142 }
143 else
144 donut::log::error("console command with name '%s' already exists", desc.name);
145 }
146 else
147 donut::log::error("attempting to register a console command with invalid name '%s'", desc.name);
148 return nullptr;
149 }
150
151 bool UnregisterCommand(std::string_view name)
152 {

Callers 1

RegisterCommandFunction · 0.80

Calls 3

fatalFunction · 0.85
errorFunction · 0.85
endMethod · 0.45

Tested by

no test coverage detected