void AVL_tree::ForEach(Node& node, ExternalFunction externalFunc){ if(node != NULL) { ForEach(node->left, externalFunc); ForEach(node->right, externalFunc); externalFunc(node); } }
// /// Intercepts the WM_MDIDESTROY message. /// /// Destroy an MDI child window. Must temporarily unhide any hidden children, /// and then rehide them after the destruction. Otherwise Window's MDI client /// gets confused // void TMDIClient::EvMDIDestroy(THandle THandle) { ForEach(sUnHide, (void*)THandle); DefaultProcessing(); ForEach(sReHide); HandleMessage(WM_MDIREFRESHMENU); }
void ReversiSaveState::Release() { titleLabel_.reset(nullptr); exitLabel_.reset(nullptr); ForEach(savesLabels_, [] (std::unique_ptr<SimpleLabel> & victim) { victim.reset(nullptr); }); ForEach(savesButtons_, [] (std::unique_ptr<TexturedButton> & victim) { victim.reset(nullptr); }); savesLabels_.clear(); savesButtons_.clear(); }
void ReversiSaveState::Draw(const sf::Time & timeDelta) { titleLabel_->Draw(); exitLabel_->Draw(); ForEach(savesButtons_, [] (std::unique_ptr<TexturedButton> & victim) { victim->Draw(); }); ForEach(savesLabels_, [] (std::unique_ptr<SimpleLabel> & victim) { victim->Draw(); }); ReversiManager::Instance()->DrawMouseCursor(); }
void appendManifestSchemas(IPropertyTree &manifest, ILoadedDllEntry &loadedDll) { assertex(!finalized); Owned<IPropertyTreeIterator> iter = manifest.getElements("Resource[@type='RESULT_XSD']"); ForEach(*iter) appendSchemaResource(iter->query(), loadedDll); }
void ReversiEnterNameState::Update(const sf::Time & timeDelta) { auto * core = CoreManager::Instance(); auto * manager = ReversiManager::Instance(); if (Keyboard::IsKeyUp(Keyboard::Escape)) { manager->KeyboardSound().Play(); core->SetNextState(MakeSharedState<ReversiSaveState>()); } else if (Keyboard::IsKeyUp(Keyboard::Return)) { manager->KeyboardSound().Play(); std::string name = nameLabel_->Text().substr(0, nameLabel_->Text().length() - 1); manager->SaveCurrentGame(ReversiSaveState::LastSelecteIndex(), name); } else { const int MAX_CHARS = 16; std::string name = ""; std::string text = core->KeyboardText().substr(0, MAX_CHARS); ForEach(text, [&] (char item) { if (item != '\n') { name += item; } }); core->KeyboardText(name); nameLabel_->Text(name + "_"); GUIUtil::CenterLabel(nameLabel_, CoreManager::HALF_LOW_WIDTH); } }
bool CWsDfuXRefEx::onDFUXRefUnusedFiles(IEspContext &context, IEspDFUXRefUnusedFilesRequest &req, IEspDFUXRefUnusedFilesResponse &resp) { const char *process = req.getProcessCluster(); if (!process || !*process) throw MakeStringExceptionDirect(ECLWATCH_INVALID_INPUT, "process cluster, not specified."); SocketEndpointArray servers; getRoxieProcessServers(process, servers); if (!servers.length()) throw MakeStringExceptionDirect(ECLWATCH_INVALID_CLUSTER_INFO, "process cluster, not found."); Owned<ISocket> sock = ISocket::connect_timeout(servers.item(0), 5000); Owned<IPropertyTree> controlXrefInfo = sendRoxieControlQuery(sock, "<control:getQueryXrefInfo/>", 5000); if (!controlXrefInfo) throw MakeStringExceptionDirect(ECLWATCH_INTERNAL_ERROR, "roxie cluster, not responding."); MapStringTo<bool> usedFileMap; Owned<IPropertyTreeIterator> roxieFiles = controlXrefInfo->getElements("//File"); ForEach(*roxieFiles) addLfnToUsedFileMap(usedFileMap, roxieFiles->query().queryProp("@name")); if (req.getCheckPackageMaps()) addUsedFilesFromActivePackageMaps(usedFileMap, process); StringArray unusedFiles; findUnusedFilesInDFS(unusedFiles, process, usedFileMap); resp.setUnusedFileCount(unusedFiles.length()); resp.setUnusedFiles(unusedFiles); return true; }
void SnakeEnterNameState::Update(const sf::Time & timeDelta) { auto * core = CoreManager::Instance(); if (Keyboard::IsKeyUp(Keyboard::Return)) { auto * manager = SnakeManager::Instance(); manager->MenuNextSound().Play(); std::string name = nameLabel_->Text().substr(0, nameLabel_->Text().length() - 1); if (substate_ == 0) { manager->AddScore(name, manager->Players()[0].Score()); if (manager->NumberOfPlayers() > 1) { core->ClearKeyboardTextInput(); nameLabel_->Text("_"); substate_ = 1; } else { core->SetNextState(MakeSharedState<SnakeMenuState>()); } } else { manager->AddScore(name, manager->Players()[1].Score()); core->SetNextState(MakeSharedState<SnakeMenuState>()); } } else { const int MAX_CHARS = 8; std::string name = ""; std::string text = core->KeyboardText().substr(0, MAX_CHARS); ForEach(text, [&] (char item) { if (item != '\n') { name += item; } }); core->KeyboardText(name); nameLabel_->Text(name + "_"); GUIUtil::CenterLabel(nameLabel_, CoreManager::HALF_LOW_WIDTH); } }
Scene::Node* Scene::ForEach( Node::TYPE _Type, Node* _pPrevious, int _StartAtChild ) { if ( _pPrevious == NULL ) { _pPrevious = m_pROOT; m_pROOT->SetChildIndex(); // Setup child indices to accelerate search } // Search in children first for ( int ChildIndex=_StartAtChild; ChildIndex < _pPrevious->m_ChildrenCount; ChildIndex++ ) { Scene::Node* pChild = _pPrevious->m_ppChildren[ChildIndex]; if ( pChild->m_Type == _Type ) return pChild; if ( pChild->m_ChildrenCount == 0 ) continue; // Look in the child's children... Scene::Node* pMatch = ForEach( _Type, pChild ); if ( pMatch != NULL ) return pMatch; // Found a match in one of the children } // If we couldn't find any match in the children, go back to parent to find this node among its siblings and continue to the next sibling Node* pParent = _pPrevious->m_pParent; while ( pParent != NULL ) { int SiblingIndex = _pPrevious->m_ChildIndex; if ( SiblingIndex < pParent->m_ChildrenCount-1 ) return ForEach( _Type, pParent, SiblingIndex+1 ); // We found the previous node in its parent's children (i.e. among its siblings), continue search from there... // for ( int SiblingIndex=0; SiblingIndex < pParent->m_ChildrenCount; SiblingIndex++ ) // { // Node* pSibling = pParent->m_ppChildren[SiblingIndex]; // if ( pSibling == _pPrevious ) // return ForEach( _Type, pParent, SiblingIndex+1 ); // We found the previous node in its parent's children (i.e. among its siblings), continue search from there... // } // Keep climbing... _pPrevious = pParent; pParent = pParent->m_pParent; } return NULL; }
// /// First calls CanClose on each of the MDI child windows owned by this MDI client. /// Returns true if all MDI children are closed (or there were no children); otherwise returns false. // bool TMDIClient::CloseChildren() { if (!FirstThat(sCannotClose)) { ForEach(sCloseChild); return true; } return false; }
/* Closes each MDI child, after calling the child's CanClose method to ensure that it is Ok to do so. Returns TRUE if all children are closed (or there were no children), FALSE if any child can't be closed */ BOOL TMDIFrame::CloseChildren() { if ( !FirstThat(CannotClose, NULL) ) // All children can be closed { ForEach(CloseChild, NULL); return TRUE; } return FALSE; }
void Scene::ForEach( IVisitor& _Visitor, Node* _pNode ) { _Visitor.HandleNode( *_pNode ); for ( int ChildIndex=0; ChildIndex < _pNode->m_ChildrenCount; ChildIndex++ ) { Node* pChild = _pNode->m_ppChildren[ChildIndex]; ForEach( _Visitor, pChild ); } }
void BlockBufferAllocator::ForEachInUseBlock(BlockBufferProcessFunc func, void * userData) { _int32 index; while(_inUseNotInQueueBlockFifo->Get(index)) { MemBufferBlock * block = GetBlock(index); AddToList(block); } ForEach(func, userData); }
void Dump() const { TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Array size: %lu (ptr: %p)", m_Relations->Count, m_Relations); ULONG Index = 0; ForEach([&Index](PDEVICE_OBJECT PDO) -> bool { TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! #%lu: %p", Index++, PDO); return true; }); }
void ReversiSaveState::Update(const sf::Time & timeDelta) { Mouse::Update(); auto * core = CoreManager::Instance(); if (Keyboard::IsKeyUp(Keyboard::Escape)) { ReversiManager::Instance()->KeyboardSound().Play(); core->SetNextState(MakeSharedState<ReversiGameState>()); } else { ForEach(savesButtons_, [] (std::unique_ptr<TexturedButton> & victim) { victim->Update(); }); } }
void List::DeleteAll() { ListNode *c=NULL; if(m_bContainer) { while(ForEach(&c)!=NULL) { Delete(&c); c=NULL; } } }
void List::Delete(Object *ptr) { ListNode *n=NULL; Object *c=NULL; while((c=ForEach(&n))!=NULL) { if(n->m_pCurrent == ptr) { Delete(&n); return; } } }
// @brief : すべての更新 //-------------------------------------------------------------------- void Object::UpdateAll( void ) { if(!m_IsUpdate) return; Update(); ForEach( [](Node *_node){ assert(dynamic_cast<Object *>(_node)); ((Object *)_node)->UpdateAll(); } ); }
bool CWSESPControlEx::onSetSessionTimeout(IEspContext& context, IEspSetSessionTimeoutRequest& req, IEspSetSessionTimeoutResponse& resp) { try { #ifdef _USE_OPENLDAP CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager()); if(secmgr && !secmgr->isSuperUser(context.queryUser())) { context.setAuthStatus(AUTH_STATUS_NOACCESS); throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to set session timeout. Permission denied."); } #endif StringBuffer id, userID, fromIP; bool allSessions = req.getAllSessions(); if (!allSessions) { id.set(req.getID()); userID.set(req.getUserID()); fromIP.set(req.getFromIP()); if ((id.trim().isEmpty()) && (userID.trim().isEmpty()) && (fromIP.trim().isEmpty())) throw MakeStringException(ECLWATCH_INVALID_INPUT, "ID, userID or FromIP has to be specified."); } int timeoutMinutes = req.getTimeoutMinutes_isNull() ? 0 : req.getTimeoutMinutes(); if (timeoutMinutes <= 0) cleanSessions(allSessions, id.str(), userID.str(), fromIP.str()); else { StringBuffer searchPath; setSessionXPath(allSessions, id.str(), userID.str(), fromIP.str(), searchPath); Owned<IRemoteConnection> globalLock = querySDSConnectionForESPSession(RTM_LOCK_WRITE, SESSION_SDS_LOCK_TIMEOUT); Owned<IPropertyTreeIterator> iter = globalLock->queryRoot()->getElements("*"); ForEach(*iter) { Owned<IPropertyTreeIterator> iter1 = iter->query().getElements(searchPath.str()); ForEach(*iter1) setSessionTimeout(timeoutMinutes, iter1->query()); } } resp.setStatus(0); resp.setMessage("Session timeout is updated."); } catch(IException* e) { FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); } return true; }
void ResourceManager::addManifestFromArchive(IPropertyTree *archive) { if (!archive) return; if (finalized) throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST"); ensureManifestInfo(); Owned<IPropertyTreeIterator> manifests = archive->getElements("AdditionalFiles/Manifest"); ForEach(*manifests) { const char *xml = manifests->query().queryProp(NULL); Owned<IPropertyTree> manifestSrc = createPTreeFromXMLString(xml); Owned<IAttributeIterator> aiter = manifestSrc->getAttributes(); ForEach (*aiter) manifest->setProp(aiter->queryName(), aiter->queryValue()); StringBuffer manifestDir; if (manifestSrc->hasProp("@originalFilename")) splitDirTail(manifestSrc->queryProp("@originalFilename"), manifestDir); Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*"); ForEach(*iter) { IPropertyTree &item = iter->query(); if (streq(item.queryName(), "Resource") && item.hasProp("@filename")) { if (!item.hasProp("@type")) item.setProp("@type", "UNKNOWN"); const char *filename; if (item.hasProp("@originalFilename")) filename = item.queryProp("@originalFilename"); else filename = item.queryProp("@filename"); int id; if (getDuplicateResourceId(item.queryProp("@type"), NULL, filename, id)) { item.setPropInt("@id", (int)id); manifest->addPropTree("Resource", LINK(&item)); } else { VStringBuffer xpath("AdditionalFiles/Resource[@originalFilename=\"%s\"]", filename); MemoryBuffer content; archive->getPropBin(xpath.str(), content); addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item); } } else manifest->addPropTree(item.queryName(), LINK(&item)); } } }
int main() { //std::get<0>(protocol)(1); #if 0 ForEach( protocol, 0, 2 ); ForEach( protocol, 1, 3 ); #endif #if 1 One one; Two two; Three three; Delegate<int, One, &One::DoAnotherThing> oneDoAnotherThing(one); Delegate<int, Two, &Two::DoAnotherThing> twoDoAnotherThing(two); Delegate<int, Three, &Three::DoAnotherThing> threeDoAnotherThing(three); Container<int, Delegate<int, One, &One::DoAnotherThing>, Delegate<int, Two, &Two::DoAnotherThing>, Delegate<int, Three, &Three::DoAnotherThing> > anotherDelegateContainer( oneDoAnotherThing, twoDoAnotherThing, threeDoAnotherThing ); printf("<%d>\n", anotherDelegateContainer.Call(0) ); printf("<%d>\n", anotherDelegateContainer.Call(1) ); printf("<%d>\n", anotherDelegateContainer.Call(2) ); //IndexedDispatch(0, one,two,three); #endif #if 0 volatile ObjectType order[] = {eThree, eTwo, eOne}; for(int i=0; i<NUMBER_OF_ELEMENTS(order); i++) { EnumeratedDispatch(order[i], eOne, one, eTwo, two, eThree, three); } #endif return 0; }
static struct KeyInfo* FindKeyInfoByStrArg(struct KeyInfoCache *pa_pInfoChache,char *pa_pStrArg) { struct FindKeyInfoByNumPa fkipa; int i; sscanf(pa_pStrArg,"%d",&i); fkipa.found = NULL; fkipa.NumToFind = i; ForEach( &pa_pInfoChache->IKeyInfo , &FindKeyInfoByNum , &fkipa ); return fkipa.found; }
void ResourceManifest::expand() { manifest->setProp("@manifestDir", dir.str()); Owned<IPropertyTreeIterator> resources = manifest->getElements("Resource[@filename]"); ForEach(*resources) updateResourcePaths(resources->query(), dir.str()); Owned<IPropertyTreeIterator> includes = manifest->getElements("Include[@filename]"); ForEach(*includes) loadInclude(includes->query(), dir.str()); resources.setown(manifest->getElements("Resource[@filename]")); ForEach(*resources) { IPropertyTree &res = resources->query(); const char *name = res.queryProp("@originalFilename"); if (containsFileWildcard(name)) { StringBuffer wildpath; const char *tail = splitDirTail(name, wildpath); expandDirectory(res, wildpath, tail, res.getPropBool("@recursive")); manifest->removeTree(&res); } } }
void MediaInfo::on_bus_message(const Glib::RefPtr<Gst::Message>& msg) { //log_info("MediaInfo::on_bus_message"); if (msg->get_message_type() & Gst::MESSAGE_ERROR) { Glib::RefPtr<Gst::MessageError> error_msg = Glib::RefPtr<Gst::MessageError>::cast_dynamic(msg); log_info("Error: " << msg->get_source()->get_name() << ": " << error_msg->parse().what()); //assert(!"Failure"); Glib::signal_idle().connect(sigc::mem_fun(this, &MediaInfo::shutdown)); } else if (msg->get_message_type() & Gst::MESSAGE_STATE_CHANGED) { Glib::RefPtr<Gst::MessageStateChanged> state_msg = Glib::RefPtr<Gst::MessageStateChanged>::cast_dynamic(msg); Gst::State oldstate; Gst::State newstate; Gst::State pending; state_msg->parse(oldstate, newstate, pending); //log_info("-- message: " << msg->get_source()->get_name() << " " << oldstate << " " << newstate); if (msg->get_source() == m_pipeline && newstate == Gst::STATE_PAUSED) { get_information(); Glib::signal_idle().connect(sigc::mem_fun(this, &MediaInfo::shutdown)); } } else if (msg->get_message_type() & Gst::MESSAGE_TAG) { if (true) { log_info("TAG: "); auto tag_msg = Glib::RefPtr<Gst::MessageTag>::cast_dynamic(msg); log_info("<<<<<<<<<<<<<<: " << tag_msg); Gst::TagList tag_list = tag_msg->parse(); log_info(" is_empty: " << tag_list.is_empty()); tag_list.foreach(ForEach(tag_list)); log_info(">>>>>>>>>>>>>>"); if (false) // does not work { Glib::RefPtr<Gst::Pad> pad = tag_msg->parse_pad(); log_info(" PAD: " << pad); } } } }
void TextGroup::SetIsVisible(bool visible) { ForEach([visible](TextPageWeakPtr page) { if (auto p = page.lock()) { p->SetIsVisible(visible); } }); if (mRenderer->GetActiveTextGroup().lock().get() == this) { mRenderer->InvalidateShaderBuffer(); } }
void CheckersLoadState::Update(const sf::Time & timeDelta) { Mouse::Update(); auto * core = CoreManager::Instance(); if (Keyboard::IsKeyUp(Keyboard::Escape)) { CheckersManager::Instance()->KeyboardSound().Play(); if (calledFrom_ == FROM_GAME) { core->SetNextState(MakeSharedState<CheckersGameState>()); } else { core->SetNextState(MakeSharedState<CheckersMenuState>()); } } else { ForEach(savesButtons_, [] (std::unique_ptr<TexturedButton> & victim) { victim->Update(); }); } }
TEST(ForAllPositionsTest, ShortRun) { auto pos_list = std::list<pos> { {0}, {1}, {2} }; auto expected_pos_list = std::list< std::list<pos> > { { { 0}, { 1}, {2} }, { {-1}, { 0}, {1} }, { {-2}, {-1}, {0} } }; List list_proxy {pos_list}; auto command = Command::TestRelPosCommand {pos_list, expected_pos_list}; auto for_all_macro = Manipulator::ForAllPositions {&command}; for_all_macro.ForEach(list_proxy.begin(), list_proxy.end()); }
void CheckString(std::string & text){ ForEach([&](const std::regex & r){ std::smatch sm; if( std::regex_match (text,sm,r) ) { // Matched std::ostringstream ost; // Pre-define : all regex should be (.*)(XXX)(.*) format // XXX is the real key word regex // std::cout<<sm.size()<<std::endl; // for(int i = 0 ; i < sm.size() ; i++ ){ // std::cout<<sm[i]<<std::endl; // } ost<<sm[1] << std::string(sm[2].length(),'*') <<sm[sm.size()-1]; text = ost.str(); } }); }
TEST(ForAllPositionsTest, LongerRun) { auto pos_list = std::list<pos> { {1,-2,4}, {1,2,0}, {0,4,1}, {-1,0,-1} }; auto expected_pos_list = std::list< std::list<pos> > { { { 0, 0, 0}, { 0, 4,-4}, {-1, 6,-3}, {-2, 2,-5} }, { { 0,-4, 4}, { 0, 0, 0}, {-1, 2, 1}, {-2,-2,-1} }, { { 1,-6, 3}, { 1,-2,-1}, { 0, 0, 0}, {-1,-4,-2} }, { { 2,-2, 5}, { 2, 2, 1}, { 1, 4, 2}, { 0, 0, 0} } }; List list_proxy {pos_list}; auto command = Command::TestRelPosCommand {pos_list, expected_pos_list}; auto for_all_macro = Manipulator::ForAllPositions {&command}; for_all_macro.ForEach(list_proxy.begin(), list_proxy.end()); }
void CWSESPControlEx::cleanSessions(bool allSessions, const char* _id, const char* _userID, const char* _fromIP) { StringBuffer searchPath; setSessionXPath(allSessions, _id, _userID, _fromIP, searchPath); Owned<IRemoteConnection> globalLock = querySDSConnectionForESPSession(RTM_LOCK_WRITE, SESSION_SDS_LOCK_TIMEOUT); Owned<IPropertyTreeIterator> iter = globalLock->queryRoot()->getElements("*"); ForEach(*iter) { IArrayOf<IPropertyTree> toRemove; Owned<IPropertyTreeIterator> iter1 = iter->query().getElements(searchPath.str()); ForEach(*iter1) toRemove.append(*LINK(&iter1->query())); ForEachItemIn(i, toRemove) iter->query().removeTree(&toRemove.item(i)); } }