Identifier* Agent::GetCommand(int index) { // Method is to search all top level output link wmes and see which have // just been added and are identifiers. Identifier* pOutputLink = GetOutputLink() ; if (!pOutputLink) { return NULL ; } for (Identifier::ChildrenIter iter = pOutputLink->GetChildrenBegin() ; iter != pOutputLink->GetChildrenEnd() ; iter++) { WMElement* pWME = *iter ; if (pWME->IsIdentifier() && pWME->IsJustAdded()) { if (index == 0) { return static_cast<Identifier*>(pWME) ; } index-- ; } } return NULL ; }
int Agent::GetNumberCommands() { // Method is to search all top level output link wmes and see which have // just been added and are identifiers. int count = 0 ; Identifier* pOutputLink = GetOutputLink() ; if (!pOutputLink) { return 0 ; } for (Identifier::ChildrenIter iter = pOutputLink->GetChildrenBegin() ; iter != pOutputLink->GetChildrenEnd() ; iter++) { WMElement* pWME = *iter ; if (pWME->IsIdentifier() && pWME->IsJustAdded()) { count++ ; } } return count ; }