Handle registering and unregistering for kernel events
| 152 | |
| 153 | // Handle registering and unregistering for kernel events |
| 154 | bool 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 | } |
nothing calls this directly
no test coverage detected