bool RestrictionCollector::IsValid() const { return find_if(begin(m_restrictions), end(m_restrictions), [](Restriction const & r) { return !r.IsValid(); }) == end(m_restrictions); }
int Battle::process_situation() { // Checking whether party is dead: auto iterator1 = find_if((party_in_battle->creatures).begin(), (party_in_battle->creatures).end(), [](Unit x){ return x.is_dead() == false;}); if(iterator1 == (party_in_battle->creatures).end()) return 0; // Checking whether enemies are dead: auto iterator2 = find_if((opponents_in_battle->creatures).begin(), (opponents_in_battle->creatures).end(), [](Unit x){ return x.is_dead() == false;}); if(iterator2 == (opponents_in_battle->creatures).end()) return 2; // Still fighting: while(battle_queue.empty()) { // Increasing current initiative for every unit: for_each((party_in_battle->creatures).begin(), (party_in_battle->creatures).end(), [](Unit x){ x.modify_current_initiative(x.initiative); }); for_each((opponents_in_battle->creatures).begin(), (opponents_in_battle->creatures).end(), [](Unit x){ x.modify_current_initiative(x.initiative); }); vector <Hero> temp_heroes; // List of heroes that are ready to act in combat vector <Unit> temp_enemies; // List of enemies that are ready to act in combat // Making lists of units that are ready to act in combat: copy_if((party_in_battle->creatures).begin(), (party_in_battle->creatures).end(), temp_heroes.begin(), [](Unit x) { if(x.get_current_initiative() >= INITIATIVE_CONSTANT) { x.modify_current_initiative((-1)*x.initiative); return true; } return false; }); copy_if((opponents_in_battle->creatures).begin(), (opponents_in_battle->creatures).end(), temp_enemies.begin(), [](Unit x) { if(x.get_current_initiative() >= INITIATIVE_CONSTANT) { x.modify_current_initiative((-1)*x.initiative); return true; } return false; }); // Sorting lists of units that are ready to act in combat: sort(temp_heroes.begin(), temp_heroes.end(), [](Unit x, Unit y){return x.get_current_initiative() < y.get_current_initiative();}); sort(temp_enemies.begin(), temp_enemies.end(), [](Unit x, Unit y){return x.get_current_initiative() < y.get_current_initiative();}); auto iterator3 = temp_heroes.begin(); auto iterator4 = temp_enemies.begin(); // Merging two sorted lists into one battle queue: while(iterator3 != temp_heroes.end() || iterator4 != temp_enemies.end()) { if(iterator3->get_current_initiative() > iterator4->get_current_initiative()) { battle_queue.push(&(*iterator3)); ++iterator3; } else { battle_queue.push(&(*iterator4)); ++iterator4; } } if(iterator3 == temp_heroes.end()) while(iterator4 != temp_enemies.end()) { battle_queue.push(&(*iterator4)); ++iterator4; } else while(iterator3 != temp_heroes.end()) { battle_queue.push(&(*iterator3)); ++iterator3; } } return 1; }
const char* _Delimiter::_M_scan_for_delim(const char* __first, const char* __last) const { return find_if(__first, __last, bind1st(mem_fun(&_Delimiter::_M_is_delim), this)); }
bool NameServerManager::isExistingNameServer(NameServerInfo source) { vector<NameServerInfo>::iterator serverItr = find_if(serverList.begin(), serverList.end(), ServerComparator(source.hostAddress, source.portNo)); if (serverItr != serverList.end()) return true; return false; }
/// \brief get stack list iterator by stack name /// \param pName - pointer to IHashString with name of the stack /// \return iterator in m_Stacks container CUndoRedoComponent::StackList::iterator CUndoRedoComponent::FindStack(IHashString *pName) { return find_if(m_Stacks.begin(), m_Stacks.end(), bind2nd(mem_fun(&CUndoStack::operator ==), pName)); }
bool ClassWithObjects::HasObjectNamed(const gd::String & name) const { return ( find_if(initialObjects.begin(), initialObjects.end(), bind2nd(gd::ObjectHasName(), name)) != initialObjects.end() ); }
const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const wchar_t* low, const wchar_t* high) const { return find_if(low, high, not1(_Ctype_w_is_mask(m, ctype<char>::classic_table()))); }
bool Player::eatPoint(const BricksVec bricks) const { return find_if(bricks.begin(), bricks.end(), [this](Brick* brick){ return brick->tryToEat(this->bounds_); }) != bricks.end(); }
bool FavoritesMenu::AddNextItem() { // run the next chunk of code for a given item adding state if (fState == kStart) { fState = kAddingFavorites; fSectionItemCount = 0; fAddedSeparatorForSection = false; // set up adding the GoTo menu items try { BPath path; ThrowOnError(find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)); path.Append(kGoDirectory); mkdir(path.Path(), 0777); BEntry entry(path.Path()); Model startModel(&entry, true); ThrowOnInitCheckError(&startModel); if (!startModel.IsContainer()) throw B_ERROR; if (startModel.IsQuery()) fContainer = new QueryEntryListCollection(&startModel); else if (startModel.IsVirtualDirectory()) fContainer = new VirtualDirectoryEntryList(&startModel); else fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory*> (startModel.Node())); ThrowOnInitCheckError(fContainer); ThrowOnError( fContainer->Rewind() ); } catch (...) { delete fContainer; fContainer = NULL; } } if (fState == kAddingFavorites) { entry_ref ref; if (fContainer && fContainer->GetNextRef(&ref) == B_OK) { Model model(&ref, true); if (model.InitCheck() != B_OK) return true; if (!ShouldShowModel(&model)) return true; BMenuItem* item = BNavMenu::NewModelItem(&model, model.IsDirectory() ? fOpenFolderMessage : fOpenFileMessage, fTarget); if (item == NULL) return true; item->SetLabel(ref.name); // this is the name of the link in the Go dir if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; AddItem(new TitledSeparatorItem(B_TRANSLATE("Favorites"))); } fUniqueRefCheck.push_back(*model.EntryRef()); AddItem(item); fSectionItemCount++; return true; } // done with favorites, set up for adding recent files fState = kAddingFiles; fAddedSeparatorForSection = false; app_info info; be_app->GetAppInfo(&info); fItems.MakeEmpty(); int32 apps, docs, folders; TrackerSettings().RecentCounts(&apps, &docs, &folders); BRoster().GetRecentDocuments(&fItems, docs, NULL, info.signature); fIndex = 0; fSectionItemCount = 0; } if (fState == kAddingFiles) { // if this is a Save panel, not an Open panel // then don't add the recent documents if (!fIsSavePanel) { for (;;) { entry_ref ref; if (fItems.FindRef("refs", fIndex++, &ref) != B_OK) break; Model model(&ref, true); if (model.InitCheck() != B_OK) return true; if (!ShouldShowModel(&model)) return true; BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget); if (item) { if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; AddItem(new TitledSeparatorItem( B_TRANSLATE("Recent documents"))); } AddItem(item); fSectionItemCount++; return true; } } } // done with recent files, set up for adding recent folders fState = kAddingFolders; fAddedSeparatorForSection = false; app_info info; be_app->GetAppInfo(&info); fItems.MakeEmpty(); int32 apps, docs, folders; TrackerSettings().RecentCounts(&apps, &docs, &folders); BRoster().GetRecentFolders(&fItems, folders, info.signature); fIndex = 0; } if (fState == kAddingFolders) { for (;;) { entry_ref ref; if (fItems.FindRef("refs", fIndex++, &ref) != B_OK) break; // don't add folders that are already in the GoTo section if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(), bind2nd(std::equal_to<entry_ref>(), ref)) != fUniqueRefCheck.end()) { continue; } Model model(&ref, true); if (model.InitCheck() != B_OK) return true; if (!ShouldShowModel(&model)) return true; BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFolderMessage, fTarget, true); if (item) { if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; AddItem(new TitledSeparatorItem( B_TRANSLATE("Recent folders"))); } AddItem(item); item->SetEnabled(true); // BNavMenu::NewModelItem returns a disabled item here - // need to fix this in BNavMenu::NewModelItem return true; } } } return false; }
Element* Model::GetElement(FEint n) const { Predicate<Element,FEint> elempred; return *find_if(_elements->begin(),_elements->end(),elempred,n); }
Material* Model::GetMaterial(FEint n) const { Predicate<Material,FEint> matpred; return *find_if(_materials->begin(),_materials->end(),matpred,n); }
Node* Model::GetNode(FEint n) const { Predicate<Node,FEint> nodepred; return *find_if(_nodes->begin(),_nodes->end(),nodepred,n); }
long CMUSHclientDoc::ReloadPlugin(LPCTSTR PluginID) { // first, find plugin by ID CPlugin * pPlugin = GetPlugin (PluginID); // if not found, try to find by name if (pPlugin == NULL && strlen (PluginID) > 0) { PluginListIterator pit = find_if (m_PluginList.begin (), m_PluginList.end (), bind2nd (compare_plugin_name (), PluginID)); if (pit != m_PluginList.end ()) pPlugin = *pit; } if (pPlugin == NULL) return eNoSuchPlugin; // cannot reload ourselves if (pPlugin == m_CurrentPlugin) return eBadParameter; PluginListIterator pit = find (m_PluginList.begin (), m_PluginList.end (), pPlugin); if (pit == m_PluginList.end () ) return eNoSuchPlugin; CString strName = pPlugin->m_strSource; m_PluginList.erase (pit); // remove from list delete pPlugin; // delete the plugin CPlugin * pCurrentPlugin = m_CurrentPlugin; m_CurrentPlugin = NULL; // otherwise plugin won't load if done from another one try { // now reload it InternalLoadPlugin (strName); } // end of try block catch (CFileException * e) { e->Delete (); m_CurrentPlugin = pCurrentPlugin; return ePluginFileNotFound; } // end of catching a file exception catch (CArchiveException* e) { e->Delete (); m_CurrentPlugin = pCurrentPlugin; return eProblemsLoadingPlugin; } m_CurrentPlugin = pCurrentPlugin; PluginListChanged (); return eOK; } // end of CMUSHclientDoc::ReloadPlugin
const wchar_t* ctype_byname<wchar_t> ::do_scan_not(ctype_base::mask m, const wchar_t* low, const wchar_t* high) const { return find_if(low, high, not1(_Ctype_byname_w_is_mask(m, _M_ctype))); }
void ASPNavwoExt::run(void* msg) { /*PROTECTED REGION ID(run1477229760910) ENABLED START*/ //Add additional options here if (this->isSuccess()) { return; } std::chrono::_V2::system_clock::time_point start = std::chrono::high_resolution_clock::now(); query->getSolution(SolverType::ASPSOLVER, runningPlan, result); std::chrono::_V2::system_clock::time_point end = std::chrono::high_resolution_clock::now(); cout << "ASPNavigation: Measured Solving and Grounding Time: " << std::chrono::duration_cast < chrono::nanoseconds > (end - start).count() / 1000000.0 << " ms" << endl; resultfile << (end - start).count() / 1000000.0 << " "; if (result.size() > 0) { auto it = result.end(); if (this->doorConfig.compare("config1") == 0) { it = find_if(result.begin(), result.end(), [](::reasoner::AnnotatedValVec element) { return element.id == 1477229706852;}); } else if (this->doorConfig.compare("config2") == 0) { it = find_if(result.begin(), result.end(), [](::reasoner::AnnotatedValVec element) { return element.id == 1477229712321;}); } else { cout << "ASPNavwoExt: wrong config" << endl; } if (it != result.end()) { if (it->variableQueryValues.size() > 0) { cout << "ASPNavwoExt: ASP result found!" << endl; cout << "\tResult contains the predicates: " << endl; cout << "\t\t"; for (int i = 0; i < result.size(); i++) { for (int j = 0; j < result.at(i).variableQueryValues.size(); j++) { for (int k = 0; k < result.at(i).variableQueryValues.at(j).size(); k++) { cout << result.at(i).variableQueryValues.at(j).at(k) << " "; } } } cout << endl; // cout << "\tThe model contains the predicates: " << endl; // cout << "\t\t"; // for (int i = 0; i < it->query->getCurrentModels()->at(0).size(); i++) // { // cout << it->query->getCurrentModels()->at(0).at(i) << " "; // } // cout << endl; } else { cout << "ASPNavwoExt: no result found!" << endl; // cout << "\tThe model contains the predicates: " << endl; // cout << "\t\t"; // for (int i = 0; i < it->query->getCurrentModels()->at(0).size(); i++) // { // cout << it->query->getCurrentModels()->at(0).at(i) << " "; // } // cout << endl; } } else { cout << "ASPNavwoExt: no result found!" << endl; } } else { cout << "ASPNavwoExt: no result found!" << endl; } if (iterationCounter == 1) { this->setSuccess(true); if (this->doorConfig.compare("config2") == 0) { resultfile << endl; } else { resultfile << flush; } } this->iterationCounter++; /*PROTECTED REGION END*/ }
double Genome::allele(const std::wstring& name) { ALLELE::iterator it=find_if(m_Alleles.begin(),m_Alleles.end(), bind1st(pair_equal_to<std::wstring,double>(),name)); return (it==m_Alleles.end()?double(0.0):it->second); }
void GTicketInternalClient::PreProcessMessage(int message, GNetTarget & target) { if(target.number==0) return; last_connection_activity = GSERVER->GetClock().Get(); list<GTicketPtr>::iterator pos; pos=find_if(wait.begin(),wait.end(),isTarget(target.number)); if(pos!=wait.end()) { if (target.timestamp > 0) { last_latency = GSERVER->GetClock().Get() - target.timestamp; if (last_latency >= GSECOND_1) { SNetMsgDesc * format; format = msg_base.Get((*pos)->message, ENetCmdInternal); string m; if (format) { m = format->name; } RAPORT("Long Ticket acknowledgment latency: %5lld ms. %s:%s%s", last_latency, GetServiceName(client_service_type), m.c_str(), pos == wait.begin() ? "" : " (not in order)"); } } if(pos!=wait.begin()) { string stable_sequence_identifier = (*pos)->stable_sequence_identifier; wait.erase(pos); list<GTicketPtr>::iterator it; for (it = wait.begin(); it != wait.end(); ) { if ((*it)->OldLoop()) { if (dropped_ticket_callback) { dropped_ticket_callback(**it, ETDR_TooManyRetries); } it = wait.erase(it); } else { it++; } } wait.erase(wait.begin(),find_if(wait.begin(),wait.end(),boost::bind(>icketInternalClient::RollbackTicket,this,_1,target.number,stable_sequence_identifier))); SRAP(WARNING_LOGIC_ROLLBACK); } else { wait.erase(pos); } } else { list<GTicketPtr>::iterator pos; pos=find_if(out.begin(),out.end(),isTarget(target.number)); if(pos!=out.end()) { out.erase(pos); SRAP(WARNING_LOGIC_OUT_ERASE); } } }
// trim from start (in place) void ltrim(string &s) { s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))); }
const gd::Object & ClassWithObjects::GetObject(const gd::String & name) const { return *(*find_if(initialObjects.begin(), initialObjects.end(), bind2nd(gd::ObjectHasName(), name))); }
// trim from end (in place) void rtrim(string &s) { s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end()); }
void OptionsCont::printHelp(std::ostream& os) { std::vector<std::string>::const_iterator i, j; // print application description splitLines(os, myAppDescription, 0, 0); os << std::endl; // print usage BNF os << "Usage: " << myAppName << " [OPTION]*" << std::endl; // print additional text if any if (myAdditionalMessage.length() > 0) { os << myAdditionalMessage << std::endl << ' ' << std::endl; } // print the options // check their sizes first // we want to know how large the largest not-too-large-entry will be size_t tooLarge = 40; size_t maxSize = 0; for (i = mySubTopics.begin(); i != mySubTopics.end(); ++i) { const std::vector<std::string>& entries = mySubTopicEntries[*i]; for (j = entries.begin(); j != entries.end(); ++j) { Option* o = getSecure(*j); // name, two leading spaces and "--" size_t csize = (*j).length() + 2 + 4; // abbreviation length ("-X, "->4chars) if any std::vector<std::string> synonymes = getSynonymes(*j); if (find_if(synonymes.begin(), synonymes.end(), abbreviation_finder()) != synonymes.end()) { csize += 4; } // the type name if (!o->isBool()) { csize += 1 + o->getTypeName().length(); } // divider csize += 2; if (csize < tooLarge && maxSize < csize) { maxSize = csize; } } } for (i = mySubTopics.begin(); i != mySubTopics.end(); ++i) { os << *i << " Options:" << std::endl; const std::vector<std::string>& entries = mySubTopicEntries[*i]; for (j = entries.begin(); j != entries.end(); ++j) { // start length computation size_t csize = (*j).length() + 2; Option* o = getSecure(*j); os << " "; // write abbreviation if given std::vector<std::string> synonymes = getSynonymes(*j); std::vector<std::string>::iterator a = find_if(synonymes.begin(), synonymes.end(), abbreviation_finder()); if (a != synonymes.end()) { os << '-' << (*a) << ", "; csize += 4; } // write leading '-'/"--" os << "--"; csize += 2; // write the name os << *j; // write the type if not a bool option if (!o->isBool()) { os << ' ' << o->getTypeName(); csize += 1 + o->getTypeName().length(); } csize += 2; // write the description formatting it os << " "; for (size_t r = maxSize; r > csize; --r) { os << ' '; } size_t offset = csize > tooLarge ? csize : maxSize; splitLines(os, o->getDescription(), offset, maxSize); } os << std::endl; } os << std::endl; // print usage examples, calc size first if (myCallExamples.size() != 0) { os << "Examples:" << std::endl; for (std::vector<std::pair<std::string, std::string> >::const_iterator e = myCallExamples.begin(); e != myCallExamples.end(); ++e) { os << " " << myAppName << ' ' << e->first << std::endl; os << " " << e->second << std::endl; } } os << std::endl; os << "Report bugs at <http://sumo-sim.org/trac/>." << std::endl; os << "Get in contact via <*****@*****.**>." << std::endl; }
bool Layout::HasLayerNamed(const gd::String & name) const { return ( find_if(initialLayers.begin(), initialLayers.end(), bind2nd(gd::LayerHasName(), name)) != initialLayers.end() ); }
///////////////////////////////////////////////////////////////////////////// // CRadioSetView message handlers void CRadioSetView::LoadData() { LoadComboString(); CString str = GetIDStr(1,SETTING_MSID);//((CPCSWDoc*)GetDocument())->GetMSID(SETTING_MSID); m_editID.SetWindowText(str); str.Empty(); str = GetIDStr(0,SETTING_ALARM_EMEID);//(CPCSWDoc*)GetDocument())->GetAlarmID(SETTING_ALARM_EMEID); m_editALARMID.SetWindowText(str); str.Empty(); str = GetAlarmName(SETTING_ALARM_NAME,SETTING_NAME_LEN); //((CPCSWDoc*)GetDocument())->GetAlarmName(SETTING_ALARM_NAME,SETTING_DBDBDWORD_LEN); m_editALARMName.SetWindowText(str); str.Empty(); int num = sizeof(CheckIDArray); int nRet=-1; CString strInput; //对于单选类型 int i=0; for (;i<18;i++) { nRet = GetSettingValue(CheckIDArray.nOffset[i]); //(CPCSWDoc*)GetDocument())->GetSettingCheckValue(CheckIDArray.nOffset[i]); if(nRet!=0) nRet = 1; ((CButton*)GetDlgItem(CheckIDArray.nCtrlID[i]))->SetCheck(nRet); } for(i=18;i<26;i++) { nRet = GetSettingValue(CheckIDArray.nOffset[i]); //((CPCSWDoc*)GetDocument())->GetSettingCheckValue(CheckIDArray.nOffset[i]); if(CheckIDArray.nCtrlID[i] == IDC_COMBO_MAINFRAME_STYLE) nRet--; ((CComboBox*)GetDlgItem(CheckIDArray.nCtrlID[i]))->SetCurSel(nRet); } for (i=26;i<28;i++) { nRet = GetEmerSettingValues(CheckIDArray.nOffset[i]); ((CComboBox*)GetDlgItem(CheckIDArray.nCtrlID[i]))->SetCurSel(nRet); } if (i == 28)//报警跳转信道 { int nCh = GetEmerSettingValues(CheckIDArray.nOffset[i]); int nZone = GetEmerSettingValues(CheckIDArray.nOffset[i]+1); if (nCh == 0xff)//当前信道 { ((CComboBox*)GetDlgItem(CheckIDArray.nCtrlID[i]))->SetCurSel(0); } else if(nCh <=16 && nZone <=16) { DWORD nInfo = (WORD)nCh&0x00ff |((WORD)(nZone<<8)&0xff00); it = find_if(mapChannel.begin(),mapChannel.end(),map_value_finder(nInfo)); if (it!=mapChannel.end()) { int nSel = (int)it->first; ((CComboBox*)GetDlgItem(CheckIDArray.nCtrlID[i]))->SetCurSel(nSel+1); } } } for (i=0;i<SPINEDIT_SUM_SETTING;i++) { nRet = GetSettingValue(SpinIDArray.nOffset[i]); //((CPCSWDoc*)GetDocument())->GetSettingCheckValue(SpinIDArray.nOffset[i]); if (nRet > SpinIDArray.nOverleap[i]||nRet <1)//若是大于规定的最大值 { switch(SpinIDArray.nCtrlID[i]) { case IDC_EDIT_TCOMM://TOT超时 0:无限制 1-60,步进10秒 { if(nRet == 0) { strInput ="无限制"; m_editTcomm.SetSpecialValue(0,strInput); } else nRet = 60; m_editTcomm.SetInteger(nRet); } break; case IDC_EDIT_TPRETOT://TOT预警 0:不预警 1-60,步进1秒 case IDC_EDIT_TREKEY://TOT再按键 0:不预警 1-60,步进1秒 { if(nRet == 0) { strInput ="不预警"; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetSpecialValue(0,strInput); }else nRet = 60; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } break; case IDC_EDIT_TRESET: //TOT复位 0:不预警 1-30,步进1秒 { if(nRet == 0) { strInput ="不预警"; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetSpecialValue(0,strInput); }else nRet = 30; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } break; case IDC_EDIT_VOX_DELAY://VOX声控延迟 0:不延迟关闭 1-30,步进100毫秒 { if(nRet == 0) { strInput ="不延迟关闭"; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetSpecialValue(0,strInput); } else nRet = 30; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } break; case IDC_EDIT_KEYLOCK_DELAY://键盘锁 0:关 1-6,步进5秒 { if(nRet == 0) { strInput ="关闭"; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetSpecialValue(0,strInput); }else nRet = 6; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } break; case IDC_EDIT_BGLIGHT_DELAY://背光延迟时间 5-60,步进1秒 { nRet = 60; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } break; case IDC_EDIT_PRE_TX_DELAY: //发射预载波时间 0-250,步进10毫秒 { nRet = 250; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } break; case IDC_EDIT_GROUPCALL_HOLD_TIME: //组呼保持时间 0-20,步进500毫秒 case IDC_EDIT_SIGNALCALL_HOLD_TIME: //个呼保持时间 0-20,步进500毫秒 { nRet = 20; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } break; case IDC_EDIT_ALARM_CALL_TIME: //紧急警报次数 1-254, 255:无限次 case IDC_EDIT_ALAMR_TIME: //紧急呼叫次数 1-254, 255:无限次 { if(nRet == 255 || nRet == 0) { nRet = 0; strInput ="无限次"; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetSpecialValue(0,strInput); } else { nRet = 254; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet); } } break; case IDC_EDIT_MIC_HOLD_TIME: //热麦克持续时间 1-12,单位10秒 case IDC_EDIT_RCV_HOLE_TIME: //接收持续时间 1-12,单位10秒 { if(nRet <1) nRet = 10; else nRet = 12; ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet*10); } break; }//end switch }//end if else { ((CSpanEdit*)GetDlgItem(SpinIDArray.nCtrlID[i]))->SetInteger(nRet*SpinIDArray.nStep[i]); } } for (i=0;i<4;i++) { nRet = GetEmerSettingValues(SETTING_ALARM_TIME+i); ((CComboBox*)GetDlgItem(IDC_COMBO_EMER_1+i))->SetCurSel(nRet); } for (i=0;i<4;i++) { nRet = GetSettingValue(SETTING_TCOMM_TIME+i); ((CComboBox*)GetDlgItem(IDC_COMBO_TOT_1+i))->SetCurSel(nRet); } EnableComboBoxes(); }
bool ModelRenderProcessor::hasObjectWithModel(string path) { auto& it = find_if(cbegin(idToObject), cend(idToObject), [&path](pair<uint32_t, View> i)->bool { return i.second.getPath() == path; }); return it != cend(idToObject); }
int CDevMgr::SetAlarmInfo(LONG lLoginID, LONG lCommand, char *pchDVRIP, LONG nDVRPort, char *pBuf, DWORD dwBufLen) { int nRet = 0; ::EnterCriticalSection(&m_csAlarm); list<DeviceNode*>::iterator it = find_if(m_lstDevice.begin(), m_lstDevice.end(), CDevMgr::SearchDevByHandle(lLoginID)); AlarmNode *thisNode = new AlarmNode; if (!thisNode) { return -1; } memset(thisNode, 0, sizeof(AlarmNode)); thisNode->timeStamp = CTime::GetCurrentTime(); if (it != m_lstDevice.end()) { thisNode->alarmType = lCommand; switch(lCommand) { case COMM_ALARM: { if (dwBufLen != sizeof(NET_CLIENT_STATE)) { nRet = -1; break; } NET_CLIENT_STATE *State = (NET_CLIENT_STATE *)pBuf; if(!State) { nRet = -1; break; } //设备列表中信息刷新 (*it)->State.cState.channelcount = State->channelcount; (*it)->State.cState.alarminputcount = State->alarminputcount; memcpy((*it)->State.cState.alarm, State->alarm, 16); memcpy((*it)->State.cState.motiondection, State->motiondection, 16); memcpy((*it)->State.cState.videolost, State->videolost, 16); thisNode->alarmType = COMM_ALARM; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; break; } case SHELTER_ALARM: { if (dwBufLen != 16) { nRet = -1; break; } memcpy((*it)->State.shelter, pBuf, 16); thisNode->alarmType = SHELTER_ALARM; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; break; } case DISK_FULL_ALARM: { if (dwBufLen != sizeof(DWORD)) { nRet = -1; break; } (*it)->State.dFull = *(DWORD*)pBuf; thisNode->alarmType = DISK_FULL_ALARM; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; break; } case DISK_ERROR_ALARM: { if (dwBufLen != sizeof(DWORD)) { nRet = -1; break; } (*it)->State.dError = *(DWORD*)pBuf; thisNode->alarmType = DISK_ERROR_ALARM; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; break; } case SOUND_DETECT_ALARM: { if (dwBufLen != 16) { nRet = -1; break; } memcpy((*it)->State.soundalarm, pBuf, 16); thisNode->alarmType = SOUND_DETECT_ALARM; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; break; } case ALARM_DECODER_ALARM_EX: { if (dwBufLen != 16) { nRet = -1; break; } memcpy((*it)->State.almDecoder, pBuf, 16); thisNode->alarmType = ALARM_DECODER_ALARM_EX; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; } break; case POS_TICKET_ALARM: { memcpy((*it)->State.PosTicket, pBuf, 1024); thisNode->alarmType = POS_TICKET_ALARM; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; } break; case POS_TICKET_RAWDATA: { memcpy((*it)->State.PosTicketRawData, pBuf, 1024); thisNode->alarmType = POS_TICKET_RAWDATA; memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); nRet = 0; } break; case REBOOT_EVENT_EX: { AfxMessageBox(ConvertString("Reboot?(y/n)")); } break; /* //以下针对新的报警接口 case ALARM_ALARM_EX: if (dwBufLen != 16) { break; } memcpy((*it)->State.alarmout, pBuf, 16); break; case MOTION_ALARM_EX: if (dwBufLen != 16) { break; } memcpy((*it)->State.motion, pBuf, 16); break; case VIDEOLOST_ALARM_EX: if (dwBufLen != 16) { break; } memcpy((*it)->State.videolost, pBuf, 16); break; case SHELTER_ALARM_EX: if (dwBufLen != 16) { break; } memcpy((*it)->State.shelter, pBuf, 16); break; case SOUND_DETECT_ALARM_EX: if (dwBufLen != 16) { break; } memcpy((*it)->State.soundalarm, pBuf, 16); break; case DISKFULL_ALARM_EX: if (dwBufLen != 1) { break; } (*it)->State.diskfull = *pBuf; break; case DISKERROR_ALARM_EX: if (dwBufLen != 32) { break; } memcpy((*it)->State.diskerror, pBuf, 32); break; */ default: nRet = -1; break; } memcpy(&thisNode->state, &(*it)->State, sizeof(DEV_STATE)); } ::LeaveCriticalSection(&m_csAlarm); if (nRet >= 0) { ::EnterCriticalSection(&m_csAlmList); m_lstAlarm.push_back(thisNode); ::LeaveCriticalSection(&m_csAlmList); } else { delete thisNode; } return nRet; }
Agent * get_agent_by_name(const char * name) { agent_iter iter; iter = find_if(agents.begin(), agents.end(), bind2nd(name_equal<Agent*>(), name)); if(iter == agents.end()) return (Agent*)0; return *iter; }
string string_ltrim( const string &str ) { string s = str; s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))); return s; }
Agent * get_agent_by_port(int port) { agent_iter iter; iter = find_if(agents.begin(), agents.end(), bind2nd(port_equal<Agent*>(), port)); if(iter == agents.end()) return (Agent*)0; return *iter; }
/** Load plugin. * The loading is interrupted if any of the plugins does not load properly. * The already loaded plugins are *not* unloaded, but kept. * @param plugin_list string containing a comma-separated list of plugins * to load. The plugin list can contain meta plugins. */ void PluginManager::load(const std::list<std::string> &plugin_list) { for (std::list<std::string>::const_iterator i = plugin_list.begin(); i != plugin_list.end(); ++i) { if ( i->length() == 0 ) continue; bool try_real_plugin = true; if ( __meta_plugins.find(*i) == __meta_plugins.end() ) { std::string meta_plugin = __meta_plugin_prefix + *i; bool found_meta = false; std::list<std::string> pset; try { if (__config->is_list(meta_plugin.c_str())) { std::vector<std::string> tmp = __config->get_strings(meta_plugin.c_str()); pset.insert(pset.end(), tmp.begin(), tmp.end()); } else pset = parse_plugin_list(__config->get_string(meta_plugin.c_str()).c_str()); found_meta = true; } catch (ConfigEntryNotFoundException &e) { // no meta plugin defined by that name //printf("No meta plugin defined with the name %s\n", i->c_str()); try_real_plugin = true; } if (found_meta) { if (pset.size() == 0) { throw Exception("Refusing to load an empty meta plugin"); } //printf("Going to load meta plugin %s (%s)\n", i->c_str(), pset.c_str()); __meta_plugins.lock(); // Setting has to happen here, so that a meta plugin will not cause an // endless loop if it references itself! __meta_plugins[*i] = pset; __meta_plugins.unlock(); try { LibLogger::log_info("PluginManager", "Loading plugins %s for meta plugin %s", str_join(pset.begin(), pset.end(), ",").c_str(), i->c_str()); load(pset); LibLogger::log_debug("PluginManager", "Loaded meta plugin %s", i->c_str()); notify_loaded(i->c_str()); } catch (Exception &e) { e.append("Could not initialize meta plugin %s, aborting loading.", i->c_str()); __meta_plugins.erase_locked(*i); throw; } try_real_plugin = false; } } if (try_real_plugin && (find_if(plugins.begin(), plugins.end(), plname_eq(*i)) == plugins.end())) { try { //printf("Going to load real plugin %s\n", i->c_str()); Plugin *plugin = plugin_loader->load(i->c_str()); plugins.lock(); try { thread_collector->add(plugin->threads()); plugins.push_back(plugin); plugin_ids[*i] = next_plugin_id++; LibLogger::log_debug("PluginManager", "Loaded plugin %s", i->c_str()); notify_loaded(i->c_str()); } catch (CannotInitializeThreadException &e) { e.append("Plugin >>> %s <<< could not be initialized, unloading", i->c_str()); plugins.unlock(); plugin_loader->unload(plugin); throw; } plugins.unlock(); } catch (Exception &e) { MutexLocker lock(__meta_plugins.mutex()); if ( __meta_plugins.find(*i) == __meta_plugins.end() ) { // only throw exception if no meta plugin with that name has // already been loaded throw; } } } } }
bool none_of(InputIt first, InputIt last, UnaryPredicate p) { return find_if(first, last, p) == last; }