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

Method MyFilterHandler

Tests/UnitTests/src/handlers.cpp:87–112  ·  view source on GitHub ↗

This is a very dumb filter--it adds "--depth 2" to all commands passed to it.

Source from the content-addressed store, hash-verified

85
86// This is a very dumb filter--it adds "--depth 2" to all commands passed to it.
87std::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
114void Handlers::MyRunEventHandler(sml::smlRunEventId, void* pUserData, sml::Agent*, sml::smlPhase)
115{

Callers

nothing calls this directly

Calls 5

ParseXMLFromStringFunction · 0.50
GetAttributeMethod · 0.45
AddAttributeMethod · 0.45
GenerateXMLStringMethod · 0.45
DeleteStringMethod · 0.45

Tested by

no test coverage detected