std::ostream& operator<<(std::ostream& out, const EquationSection &es) { if (es.equations().size()) { if (es.initial()) out << "initial "; out << "equation\n"; } foreach_(Equation e, es.equations()) out << INDENT << e << ";\n"; return out; }
void SearchDialog::RefreshList() { if (!IsWindow()) return; // Hide and clear the list list_.Hide(); list_.DeleteAllItems(); // Add anime items to list foreach_(it, anime_ids_) AddAnimeToList(*it); // Show the list again list_.Show(SW_SHOW); }
void SearchDialog::RefreshList() { if (!IsWindow()) return; // Disable drawing list_.SetRedraw(FALSE); // Clear list list_.DeleteAllItems(); // Add anime items to list foreach_(it, anime_ids_) AddAnimeToList(*it); // Redraw list_.SetRedraw(TRUE); list_.RedrawWindow(nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); }
void process_for_equations(Modelica::MMO_Class &mmo_class) { EquationList &equations = mmo_class.equations_ref().equations_ref(); EquationList new_equations; foreach_ (Equation &e, equations) { if (is<ForEq>(e)) { ForEq feq = boost::get<ForEq>(e); IndexList il = feq.range().indexes(); ERROR_UNLESS(il.size() == 1, "process_for_equations:\n" "forIndexList with more than 1 forIndex are not supported yet\n"); Index in = il.front(); Name variable = in.name(); OptExp ind = in.exp(); ERROR_UNLESS(ind, "for-equation's index with implicit range not supported yet\n"); Expression exp = ind.get(); ForIndexIterator *forIndexIter = NULL; if (is<Range>(exp)) { forIndexIter = new RangeIterator(get<Range>(exp),mmo_class.syms_ref()); } else if (is<Brace>(exp)) { forIndexIter = new BraceIterator(get<Brace>(exp),mmo_class.syms_ref()); } else { ERROR("For Iterator not supported"); } while (forIndexIter->hasNext()) { Real index_val = forIndexIter->next(); foreach_ (Equation eq, feq.elements()) new_equations.push_back(instantiate_equation(eq, variable, index_val, mmo_class.syms_ref())); } delete forIndexIter; } else { // Not a for eq new_equations.push_back(e); } } mmo_class.equations_ref().equations_ref()=new_equations; }
int main(int argc, char* argv[]) { aug_mpool* mpool; aug_chan* chan1; aug_chan* chan2; aug_chan* chan3; aug_chans_t chans; aug_check(aug_autotlx()); aug_setloglevel(aug_tlx, AUG_LOGDEBUG0 + 3); mpool = aug_getmpool(aug_tlx); aug_check(mpool); chan1 = create_(mpool, 1); aug_check(chan1); chan2 = create_(mpool, 2); aug_check(chan2); chan3 = create_(mpool, 3); aug_check(chan3); chans = aug_createchans(mpool, &chandler_); aug_check(chans); aug_check(0 <= aug_insertchan(chans, chan1)); aug_check(0 <= aug_insertchan(chans, chan2)); aug_check(0 <= aug_insertchan(chans, chan3)); aug_check(6 == refs_); aug_release(chan1); aug_release(chan2); aug_release(chan3); aug_check(3 == refs_); /* 3 2 1 */ foreach_(chans); /* 2 1 3 */ aug_check(3 == aug_getchans(chans)); aug_check(3 == count_); aug_check(3 == last_); /* Fairness rotation. */ /* 2 1 3 */ foreach_(chans); /* 1 3 2 */ aug_check(3 == aug_getchans(chans)); aug_check(3 == count_); aug_check(2 == last_); /* Fairness rotation. */ /* 1 3 2 */ foreach_(chans); /* 3 2 1 */ aug_check(3 == aug_getchans(chans)); aug_check(3 == count_); aug_check(1 == last_); /* Remove middle. */ aug_check(0 <= aug_removechan(chans, 2)); /* 3 1 */ foreach_(chans); /* 1 3 */ aug_check(2 == aug_getchans(chans)); aug_check(2 == count_); aug_check(3 == last_); /* No longer exists. */ aug_check(aug_removechan(chans, 2) < 0); aug_check(AUG_EXNONE == aug_getexcept(aug_tlx)); /* Remove during loop. */ cb_ = rm1_; aug_processchans(chans); /* No longer exists. */ aug_check(aug_removechan(chans, 1) < 0); /* 3 */ foreach_(chans); /* 3 */ aug_check(1 == aug_getchans(chans)); aug_check(1 == count_); aug_check(3 == last_); aug_dumpchans(chans); aug_destroychans(chans); /* Objects released. */ aug_check(0 == aug_getchans(chans)); aug_check(0 == refs_); aug_release(mpool); return 0; }
void FeedConditionDialog::ChooseElement(int element_index) { // Operator LPARAM op_data = operator_combo_.GetItemData(operator_combo_.GetCurSel()); operator_combo_.ResetContent(); #define ADD_OPERATOR(op) \ operator_combo_.AddItem(Aggregator.filter_manager.TranslateOperator(op).c_str(), op); switch (element_index) { case kFeedFilterElement_Meta_Id: case kFeedFilterElement_Episode_Number: case kFeedFilterElement_Meta_DateStart: case kFeedFilterElement_Meta_DateEnd: case kFeedFilterElement_Meta_Episodes: ADD_OPERATOR(kFeedFilterOperator_Equals); ADD_OPERATOR(kFeedFilterOperator_NotEquals); ADD_OPERATOR(kFeedFilterOperator_IsGreaterThan); ADD_OPERATOR(kFeedFilterOperator_IsGreaterThanOrEqualTo); ADD_OPERATOR(kFeedFilterOperator_IsLessThan); ADD_OPERATOR(kFeedFilterOperator_IsLessThanOrEqualTo); break; case kFeedFilterElement_Local_EpisodeAvailable: case kFeedFilterElement_Meta_Status: case kFeedFilterElement_Meta_Type: case kFeedFilterElement_User_Status: ADD_OPERATOR(kFeedFilterOperator_Equals); ADD_OPERATOR(kFeedFilterOperator_NotEquals); break; case kFeedFilterElement_Episode_Title: case kFeedFilterElement_Episode_Group: case kFeedFilterElement_Episode_VideoType: case kFeedFilterElement_File_Title: case kFeedFilterElement_File_Category: case kFeedFilterElement_File_Description: case kFeedFilterElement_File_Link: ADD_OPERATOR(kFeedFilterOperator_Equals); ADD_OPERATOR(kFeedFilterOperator_NotEquals); ADD_OPERATOR(kFeedFilterOperator_BeginsWith); ADD_OPERATOR(kFeedFilterOperator_EndsWith); ADD_OPERATOR(kFeedFilterOperator_Contains); ADD_OPERATOR(kFeedFilterOperator_NotContains); break; default: for (int i = 0; i < kFeedFilterOperator_Count; i++) { ADD_OPERATOR(i); } } #undef ADD_OPERATOR int op_index = operator_combo_.FindItemData(op_data); if (op_index == CB_ERR) op_index = 0; operator_combo_.SetCurSel(op_index); ////////////////////////////////////////////////////////////////////////////// // Value value_combo_.ResetContent(); RECT rect; value_combo_.GetWindowRect(&rect); int width = rect.right - rect.left; int height = rect.bottom - rect.top; ::ScreenToClient(GetWindowHandle(), reinterpret_cast<LPPOINT>(&rect)); #define RECREATE_COMBO(style) \ value_combo_.Create(0, WC_COMBOBOX, nullptr, \ style | CBS_AUTOHSCROLL | WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_VSCROLL, \ rect.left, rect.top, width, height * 2, \ GetWindowHandle(), nullptr, nullptr); switch (element_index) { case kFeedFilterElement_File_Category: RECREATE_COMBO(CBS_DROPDOWN); value_combo_.AddString(L"Anime"); value_combo_.AddString(L"Batch"); value_combo_.AddString(L"Hentai"); value_combo_.AddString(L"Non-English"); value_combo_.AddString(L"Other"); value_combo_.AddString(L"Raws"); break; case kFeedFilterElement_Meta_Id: case kFeedFilterElement_Episode_Title: { RECREATE_COMBO((element_index == kFeedFilterElement_Meta_Id ? CBS_DROPDOWNLIST : CBS_DROPDOWN)); typedef std::pair<int, std::wstring> anime_pair; std::vector<anime_pair> title_list; for (auto it = AnimeDatabase.items.begin(); it != AnimeDatabase.items.end(); ++it) { switch (it->second.GetMyStatus()) { case anime::kNotInList: case anime::kCompleted: case anime::kDropped: continue; default: title_list.push_back(std::make_pair( it->second.GetId(), AnimeDatabase.FindItem(it->second.GetId())->GetTitle())); } } std::sort(title_list.begin(), title_list.end(), [](const anime_pair& a1, const anime_pair& a2) { return CompareStrings(a1.second, a2.second) < 0; }); if (element_index == kFeedFilterElement_Meta_Id) value_combo_.AddString(L"(Unknown)"); foreach_(it, title_list) value_combo_.AddItem(it->second.c_str(), it->first); break; } case kFeedFilterElement_Meta_DateStart: case kFeedFilterElement_Meta_DateEnd: RECREATE_COMBO(CBS_DROPDOWN); value_combo_.AddString(static_cast<std::wstring>(GetDate()).c_str()); value_combo_.SetCueBannerText(L"YYYY-MM-DD"); break; case kFeedFilterElement_Meta_Status: RECREATE_COMBO(CBS_DROPDOWNLIST); value_combo_.AddItem(anime::TranslateStatus(anime::kAiring).c_str(), anime::kAiring); value_combo_.AddItem(anime::TranslateStatus(anime::kFinishedAiring).c_str(), anime::kFinishedAiring); value_combo_.AddItem(anime::TranslateStatus(anime::kNotYetAired).c_str(), anime::kNotYetAired); break; case kFeedFilterElement_Meta_Type: RECREATE_COMBO(CBS_DROPDOWNLIST); value_combo_.AddItem(anime::TranslateType(anime::kTv).c_str(), anime::kTv); value_combo_.AddItem(anime::TranslateType(anime::kOva).c_str(), anime::kOva); value_combo_.AddItem(anime::TranslateType(anime::kMovie).c_str(), anime::kMovie); value_combo_.AddItem(anime::TranslateType(anime::kSpecial).c_str(), anime::kSpecial); value_combo_.AddItem(anime::TranslateType(anime::kOna).c_str(), anime::kOna); value_combo_.AddItem(anime::TranslateType(anime::kMusic).c_str(), anime::kMusic); break; case kFeedFilterElement_User_Status: RECREATE_COMBO(CBS_DROPDOWNLIST); value_combo_.AddItem(anime::TranslateMyStatus(anime::kNotInList, false).c_str(), anime::kNotInList); value_combo_.AddItem(anime::TranslateMyStatus(anime::kWatching, false).c_str(), anime::kWatching); value_combo_.AddItem(anime::TranslateMyStatus(anime::kCompleted, false).c_str(), anime::kCompleted); value_combo_.AddItem(anime::TranslateMyStatus(anime::kOnHold, false).c_str(), anime::kOnHold); value_combo_.AddItem(anime::TranslateMyStatus(anime::kDropped, false).c_str(), anime::kDropped); value_combo_.AddItem(anime::TranslateMyStatus(anime::kPlanToWatch, false).c_str(), anime::kPlanToWatch); break; case kFeedFilterElement_Episode_Number: case kFeedFilterElement_Meta_Episodes: RECREATE_COMBO(CBS_DROPDOWN); value_combo_.AddString(L"%watched%"); value_combo_.AddString(L"%total%"); break; case kFeedFilterElement_Episode_Version: RECREATE_COMBO(CBS_DROPDOWN); value_combo_.AddString(L"2"); value_combo_.AddString(L"3"); value_combo_.AddString(L"4"); value_combo_.AddString(L"0"); break; case kFeedFilterElement_Local_EpisodeAvailable: RECREATE_COMBO(CBS_DROPDOWNLIST); value_combo_.AddString(L"False"); value_combo_.AddString(L"True"); break; case kFeedFilterElement_Episode_VideoResolution: RECREATE_COMBO(CBS_DROPDOWN); value_combo_.AddString(L"1080p"); value_combo_.AddString(L"720p"); value_combo_.AddString(L"480p"); value_combo_.AddString(L"400p"); break; case kFeedFilterElement_Episode_VideoType: RECREATE_COMBO(CBS_DROPDOWN); value_combo_.AddString(L"h264"); value_combo_.AddString(L"x264"); value_combo_.AddString(L"XviD"); break; default: RECREATE_COMBO(CBS_DROPDOWN); break; } #undef RECREATE_COMBO value_combo_.SetCurSel(0); }