This is a very dumb filter--it adds "--depth 2" to all commands passed to it.
| 85 | |
| 86 | // This is a very dumb filter--it adds "--depth 2" to all commands passed to it. |
| 87 | std::string Handlers::MyFilterHandler(sml::smlRhsEventId, void* pUserData, sml::Agent*, char const*, char const* pCommandLine) |
| 88 | { |
| 89 | soarxml::ElementXML* pXML = soarxml::ElementXML::ParseXMLFromString(pCommandLine) ; |
| 90 | CPPUNIT_ASSERT(pXML); |
| 91 | CPPUNIT_ASSERT(pXML->GetAttribute(sml::sml_Names::kFilterCommand)); |
| 92 | |
| 93 | std::stringstream commandLine; |
| 94 | commandLine << pXML->GetAttribute(sml::sml_Names::kFilterCommand) << " --depth 2"; |
| 95 | |
| 96 | // Replace the command attribute in the XML |
| 97 | CPPUNIT_ASSERT(pXML->AddAttribute(sml::sml_Names::kFilterCommand, commandLine.str().c_str())); |
| 98 | |
| 99 | // Convert the XML back to a string and put it into a std::string ready to return |
| 100 | char* pXMLString = pXML->GenerateXMLString(true) ; |
| 101 | CPPUNIT_ASSERT(pXMLString); |
| 102 | std::string res(pXMLString); |
| 103 | |
| 104 | pXML->DeleteString(pXMLString); |
| 105 | delete pXML ; |
| 106 | |
| 107 | CPPUNIT_ASSERT(pUserData); |
| 108 | bool* pHandlerReceived = static_cast< bool* >(pUserData); |
| 109 | *pHandlerReceived = true; |
| 110 | |
| 111 | return res ; |
| 112 | } |
| 113 | |
| 114 | void Handlers::MyRunEventHandler(sml::smlRunEventId, void* pUserData, sml::Agent*, sml::smlPhase) |
| 115 | { |
nothing calls this directly
no test coverage detected