MCPcopy Create free account
hub / github.com/SoarGroup/Soar / HandleRegisterForEvent

Method HandleRegisterForEvent

Core/KernelSML/src/sml_KernelSMLHandlers.cpp:154–339  ·  view source on GitHub ↗

Handle registering and unregistering for kernel events

Source from the content-addressed store, hash-verified

152
153// Handle registering and unregistering for kernel events
154bool KernelSML::HandleRegisterForEvent(AgentSML* pAgentSML, char const* pCommandName, Connection* pConnection, AnalyzeXML* pIncoming, soarxml::ElementXML* pResponse)
155{
156 // Decide if registering or unregistering
157 bool registerForEvent = (strcmp(pCommandName, sml_Names::kCommand_RegisterForEvent) == 0) ;
158
159 // Get the parameters
160 char const* pEventName = pIncoming->GetArgString(sml_Names::kParamEventID) ;
161
162 if (!pEventName)
163 {
164 return InvalidArg(pConnection, pResponse, pCommandName, "Event id is missing") ;
165 }
166
167 // Convert from the event name to the id value
168 int id = ConvertStringToEvent(pEventName) ;
169
170 // Decide what type of event this is and where to register/unregister it
171 if (IsSystemEventID(id))
172 {
173 // System Events
174 if (registerForEvent)
175 {
176 this->AddSystemListener(static_cast<smlSystemEventId>(id), pConnection) ;
177 }
178 else
179 {
180 this->RemoveSystemListener(static_cast<smlSystemEventId>(id), pConnection) ;
181 }
182
183 }
184 else if (IsAgentEventID(id))
185 {
186
187 // Agent events
188 if (registerForEvent)
189 {
190 this->AddAgentListener(static_cast<smlAgentEventId>(id), pConnection) ;
191 }
192 else
193 {
194 this->RemoveAgentListener(static_cast<smlAgentEventId>(id), pConnection) ;
195 }
196 }
197 else if (IsRhsEventID(id))
198 {
199
200 // Rhs user functions
201 char const* pRhsFunctionName = pIncoming->GetArgString(sml_Names::kParamName) ;
202
203 if (!pRhsFunctionName)
204 {
205 return InvalidArg(pConnection, pResponse, pCommandName, "Registering for rhs user function, but no function name was provided") ;
206 }
207
208 if (registerForEvent)
209 {
210 this->AddRhsListener(pRhsFunctionName, pConnection) ;
211 }

Callers

nothing calls this directly

Calls 15

AddUpdateListenerFunction · 0.85
RemoveUpdateListenerFunction · 0.85
AddStringListenerFunction · 0.85
RemoveStringListenerFunction · 0.85
GetArgStringMethod · 0.80
AddRhsListenerMethod · 0.80
RemoveRhsListenerMethod · 0.80
IsSystemEventIDFunction · 0.50
IsAgentEventIDFunction · 0.50
IsRhsEventIDFunction · 0.50
IsRunEventIDFunction · 0.50
IsProductionEventIDFunction · 0.50

Tested by

no test coverage detected