void ui_menu_audit::handle() { process(UI_MENU_PROCESS_CUSTOM_ONLY); if (m_x == m_size) { process(UI_MENU_PROCESS_CUSTOM_ONLY); machine().ui().draw_text_box(container, "Audit in progress...", JUSTIFY_CENTER, 0.5f, 0.5f, UI_GREEN_COLOR); m_x = m_size - 1; return; } if (m_audit_mode == 1) { for (; m_x >= 0; --m_x) { driver_enumerator enumerator(machine().options(), m_unavailable[m_x]->name); enumerator.next(); media_auditor auditor(enumerator); media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); // if everything looks good, include the driver if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) { m_available.push_back(m_unavailable[m_x]); m_unavailable.erase(m_unavailable.begin() + m_x); } } } else { for (; m_x >= 0; --m_x) { const game_driver *driver = &driver_list::driver(m_x); if (!strcmp("___empty", driver->name)) continue; driver_enumerator enumerator(machine().options(), driver->name); enumerator.next(); media_auditor auditor(enumerator); media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); // if everything looks good, include the driver if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) m_available.push_back(driver); else m_unavailable.push_back(driver); } } // sort m_availablesorted = m_available; std::stable_sort(m_availablesorted.begin(), m_availablesorted.end(), sorted_game_list); m_unavailablesorted = m_unavailable; std::stable_sort(m_unavailablesorted.begin(), m_unavailablesorted.end(), sorted_game_list); save_available_machines(); ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); ui_menu::stack_pop(machine()); }
void ui_menu_audit::handle() { process(UI_MENU_PROCESS_CUSTOM_ONLY); if (m_first) { machine().ui().draw_text_box(container, "Audit in progress...", JUSTIFY_CENTER, 0.5f, 0.5f, UI_GREEN_COLOR); m_first = false; return; } if (m_audit_mode == 1) { std::vector<const game_driver *>::iterator iter = m_unavailablesorted.begin(); while (iter != m_unavailablesorted.end()) { driver_enumerator enumerator(machine().options(), (*iter)->name); enumerator.next(); media_auditor auditor(enumerator); media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); // if everything looks good, include the driver if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) { m_availablesorted.push_back((*iter)); iter = m_unavailablesorted.erase(iter); } else ++iter; } } else { driver_enumerator enumerator(machine().options()); media_auditor auditor(enumerator); while (enumerator.next()) { media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); // if everything looks good, include the driver if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) m_availablesorted.push_back(&enumerator.driver()); else m_unavailablesorted.push_back(&enumerator.driver()); } } // sort std::stable_sort(m_availablesorted.begin(), m_availablesorted.end(), sorted_game_list); std::stable_sort(m_unavailablesorted.begin(), m_unavailablesorted.end(), sorted_game_list); save_available_machines(); ui_menu::menu_stack->parent->reset(UI_MENU_RESET_SELECT_FIRST); ui_menu::stack_pop(machine()); }
//============================================================================== bool USB_Device::open_by_vid_pid(uint16_t vendor_id, uint16_t product_id) { init_context(); close(); libusb_device_vector devices; USB_Enumerator enumerator(context_, devices); libusb_device_descriptor descriptor; foreach (libusb_device *item, devices) { if (!libusb_get_device_descriptor(item, &descriptor) && descriptor.idVendor == vendor_id && descriptor.idProduct == product_id) { int result = libusb_open(item, &handle_); if (result < 0) on_error("libusb_open", result); device_ = libusb_get_device(handle_); log_info("usb, open device, VID: %04Xh, PID: %04Xh", vendor_id, product_id); return true; } } return false; }
void testMiniProject() { solver.strategies().symTab.reset(new AtomIndex); builder.startProgram(*solver.strategies().symTab, 0, 0) .setAtomName(1, "a").setAtomName(2, "b").setAtomName(3, "_x") .startRule(CHOICERULE).addHead(1).addHead(2).addHead(3).endRule() .startRule().addHead(3).addToBody(1, false).endRule() .startRule().addHead(3).addToBody(2, false).endRule() .startRule(OPTIMIZERULE).addToBody(3, true).endRule() ; CPPUNIT_ASSERT_EQUAL(true, builder.endProgram(solver, true)); MinimizeConstraint* m = builder.createMinimize(solver, false); BacktrackEnumerator enumerator(0); enumerator.setMinimize(m); enumerator.setEnableProjection(true); enumerator.init(solver, 0); AtomIndex& index = *solver.strategies().symTab; solver.assume(index[1].lit); solver.propagate(); solver.assume(index[2].lit); solver.propagate(); solver.assume(index[3].lit); solver.propagate(); CPPUNIT_ASSERT(solver.numVars() == solver.numAssignedVars()); CPPUNIT_ASSERT_EQUAL(false, enumerator.backtrackFromModel(solver)); }
void TForm_Main::AdjustProperty(float fAmount) { if (!m_hSample) return; // Get the current value float fValue = atof(c_Edit_Value->Text.c_str()); // Adjust fValue += fAmount; // Tell Miles AIL_set_filter_sample_preference(m_hSample, c_ComboBox_Property->Text.c_str(), &fValue); // Get it back out in case we hit a max/min fValue = ReadProperty(); // Put it back in the edit AnsiString holdString; holdString.printf("%0.4f", fValue); c_Edit_Value->Text = holdString; // Update the property cache int iCurProperty = 0; RIB_INTERFACE_ENTRY ribAttrib; HINTENUM enumerator(HINTENUM_FIRST); while ((iCurProperty < m_iNumProperties) && AIL_enumerate_filter_sample_attributes(m_hCurFilter, &enumerator, &ribAttrib)) { AIL_filter_sample_attribute(m_hSample, ribAttrib.entry_name, &m_fProperties[iCurProperty]); ++iCurProperty; } }
//--------------------------------------------------------------------------- void __fastcall TForm_Main::c_Button_PlayClick(TObject *Sender) { if (!m_hSample) return; AIL_set_sample_processor(m_hSample, DP_FILTER, m_hCurFilter); // Reset the current property, just in case it got lost.. //AdjustProperty(0.0f); // Play c_TrackBar_PanChange(Sender); AIL_set_sample_ms_position(m_hSample, 0); AIL_start_sample(m_hSample); // Reset the property values based on our cache int iCurProperty = 0; RIB_INTERFACE_ENTRY ribAttrib; HINTENUM enumerator(HINTENUM_FIRST); while ((iCurProperty < m_iNumProperties) && AIL_enumerate_filter_sample_attributes(m_hCurFilter, &enumerator, &ribAttrib)) { AIL_set_filter_sample_preference(m_hSample, ribAttrib.entry_name, &m_fProperties[iCurProperty]); ++iCurProperty; } }
void ui_menu_select_game::inkey_select(const ui_menu_event *menu_event) { const game_driver *driver = (const game_driver *)menu_event->itemref; // special case for configure inputs if ((FPTR)driver == 1) ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_groups(machine(), container))); // anything else is a driver else { // audit the game first to see if we're going to work driver_enumerator enumerator(machine().options(), *driver); enumerator.next(); media_auditor auditor(enumerator); media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); // if everything looks good, schedule the new driver if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) { machine().manager().schedule_new_driver(*driver); machine().schedule_hard_reset(); ui_menu::stack_reset(machine()); } // otherwise, display an error else { reset(UI_MENU_RESET_REMEMBER_REF); m_error = true; } } }
/** * Internal method that may be inside the monitor. */ nsresult sbLocalDatabaseMediaListBase::EnumerateItemsByPropertiesInternal(sbStringArrayHash* aPropertiesHash, sbIMediaListEnumerationListener* aEnumerationListener) { nsCOMPtr<sbILocalDatabaseGUIDArray> guidArray; nsresult rv = mFullArray->Clone(getter_AddRefs(guidArray)); NS_ENSURE_SUCCESS(rv, rv); // Clone copies the filters... which we don't want. rv = guidArray->ClearFilters(); NS_ENSURE_SUCCESS(rv, rv); // Now that our hash table is set up we call AddFilter for each property // id and all its associated values. PRUint32 filterCount = aPropertiesHash->EnumerateRead(AddFilterToGUIDArrayCallback, guidArray); // Make sure we actually added some filters here. Otherwise something went // wrong and the results are not going to be what the caller expects. PRUint32 hashCount = aPropertiesHash->Count(); NS_ENSURE_TRUE(filterCount == hashCount, NS_ERROR_UNEXPECTED); // Finally make an enumerator to return the filtered items. sbGUIDArrayEnumerator enumerator(mLibrary, guidArray); return EnumerateItemsInternal(&enumerator, aEnumerationListener); }
static void test_default_constructor(void) { using enumerator = mtr::forward_enumerator<int>; auto e = enumerator(); SHOULD_BE_TRUE(e.is_empty(), "Default constructor should give 'empty' enumerator"); }
const XMLCh* DOMXPathNSResolverImpl::lookupPrefix(const XMLCh* uri) const { if (uri == 0 || *uri == 0) return 0; if(XMLString::equals(uri, XMLUni::fgXMLURIName)) return XMLUni::fgXMLString; RefHashTableOfEnumerator<KVStringPair> enumerator((RefHashTableOf<KVStringPair>*)fNamespaceBindings); while(enumerator.hasMoreElements()) { KVStringPair &pair = enumerator.nextElement(); if(XMLString::equals(pair.getValue(), uri)) { return pair.getKey(); } } if(fResolverNode) { const XMLCh* r = fResolverNode->lookupPrefix(uri); if (r == 0 && fResolverNode->isDefaultNamespace(uri)) r = XMLUni::fgZeroLenString; return r; } return 0; }
void dump_format_range(size_t ndx, const audio_stream_format_range_t& range) { printf("[%2zu] Sample Format :", ndx); struct { audio_sample_format_t flag; const char* name; } SF_FLAG_LUT[] = { { AUDIO_SAMPLE_FORMAT_FLAG_UNSIGNED, "Unsigned" }, { AUDIO_SAMPLE_FORMAT_FLAG_INVERT_ENDIAN , "Inv Endian" }, }; for (const auto& sf : SF_FLAG_LUT) { if (range.sample_formats & sf.flag) { printf(" %s", sf.name); } } struct { audio_sample_format_t flag; const char* name; } SF_FORMAT_LUT[] = { { AUDIO_SAMPLE_FORMAT_BITSTREAM, "Bitstream" }, { AUDIO_SAMPLE_FORMAT_8BIT, "8" }, { AUDIO_SAMPLE_FORMAT_16BIT, "16" }, { AUDIO_SAMPLE_FORMAT_20BIT_PACKED, "20-packed" }, { AUDIO_SAMPLE_FORMAT_24BIT_PACKED, "24-packed" }, { AUDIO_SAMPLE_FORMAT_20BIT_IN32, "20-in-32" }, { AUDIO_SAMPLE_FORMAT_24BIT_IN32, "24-in-32" }, { AUDIO_SAMPLE_FORMAT_32BIT, "32" }, { AUDIO_SAMPLE_FORMAT_32BIT_FLOAT, "Float 32" }, }; bool first = true; printf(" ["); for (const auto& sf : SF_FORMAT_LUT) { if (range.sample_formats & sf.flag) { printf("%s%s", first ? "" : ", ", sf.name); first = false; } } printf("]\n"); printf(" Channel Count : [%u, %u]\n", range.min_channels, range.max_channels); printf(" Frame Rates :"); if (range.flags & ASF_RANGE_FLAG_FPS_CONTINUOUS) { printf(" [%u, %u] Hz continuous\n", range.min_frames_per_second, range.max_frames_per_second); } else { audio::utils::FrameRateEnumerator enumerator(range); first = true; for (uint32_t rate : enumerator) { printf("%s%u", first ? " " : ", ", rate); first = false; } printf(" Hz\n"); } }
//----------------------------------------------------------------------------- // Lets clients know about all entities in a box //----------------------------------------------------------------------------- void CEngineTrace::EnumerateEntities( const Vector &vecAbsMins, const Vector &vecAbsMaxs, IEntityEnumerator *pEnumerator ) { // FIXME: If we store CBaseHandles directly in the spatial partition, this method // basically becomes obsolete. The spatial partition can be queried directly. CEnumerationFilter enumerator( this, pEnumerator ); SpatialPartition()->EnumerateElementsInBox( SpatialPartitionMask(), vecAbsMins, vecAbsMaxs, false, &enumerator ); }
static void test_enumeration_with_step(void) { using enumerator = mtr::forward_enumerator<int>; auto fn = [](int a, int i)->int { return a + i; }; { auto e = enumerator(3, 99, 2); auto a = e.foreach(0)(fn); SHOULD_BE_EQ(a, 2499, "Sum of the enumeration"); } { auto e = enumerator(3, 100, 2); auto a = e.foreach(0)(fn); SHOULD_BE_EQ(a, 2499, "Sum of the enumeration"); } }
BOOL CLangPage::OnInitDialog() { CPropertyPage::OnInitDialog(); LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); UString temp = NWindows::MyLoadString(IDS_LANG_ENGLISH); NativeLangString(temp, NWindows::MyLoadString(IDS_LANG_NATIVE)); int index = (int)m_cmbLang.AddString(GetSystemString(temp)); m_cmbLang.SetItemData(index, _paths.Size()); _paths.Add(L"-"); m_cmbLang.SetCurSel(0); const FString dirPrefix = GetLangDirPrefix(); NWindows::NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt")); NWindows::NFile::NFind::CFileInfo fi; CLang lang; UString error; while (enumerator.Next(fi)) { if (fi.IsDir()) continue; const int kExtSize = 4; if (fi.Name.Len() < kExtSize) continue; unsigned pos = fi.Name.Len() - kExtSize; if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt")) continue; if (!LangOpen(lang, dirPrefix + fi.Name)) { error.Add_Space_if_NotEmpty(); error += fs2us(fi.Name); continue; } const UString shortName = fs2us(fi.Name.Left(pos)); UString s = shortName; const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH); if (eng) s = eng; const wchar_t *native = lang.Get(IDS_LANG_NATIVE); if (native) NativeLangString(s, native); index = (int)m_cmbLang.AddString(GetSystemString(s)); m_cmbLang.SetItemData(index, _paths.Size()); _paths.Add(shortName); if (g_LangID.IsEqualTo_NoCase(shortName)) m_cmbLang.SetCurSel(index); } if (!error.IsEmpty()) ::MessageBoxW(m_hWnd, error, L"Error in Lang file", MB_ICONERROR); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
size_t RawCompactTrieMinimizeImpl(TOutputStream& os, const TOpaqueTrie& trie, bool verbose, size_t minMergeSize) { if (!trie.Data || !trie.Length) { return 0; } TOffsetMap merger = FindEquivalentSubtries(trie, verbose, minMergeSize); TMergingReverseNodeEnumerator enumerator(trie, merger); return WriteTrieBackwards(os, enumerator, verbose); }
void GameScene::Load() { // Link resources IDs with its resource pointers sht::utility::ResourceManager * resource_manager = sht::utility::ResourceManager::GetInstance(); text_shader_ = dynamic_cast<sht::graphics::Shader *>(resource_manager->GetResource(text_shader_id_)); gui_shader_ = dynamic_cast<sht::graphics::Shader *>(resource_manager->GetResource(gui_shader_id_)); object_shader_ = dynamic_cast<sht::graphics::Shader *>(resource_manager->GetResource(object_shader_id_)); ball_shader_ = dynamic_cast<sht::graphics::Shader *>(resource_manager->GetResource(ball_shader_id_)); ghost_shader_ = dynamic_cast<sht::graphics::Shader *>(resource_manager->GetResource(ghost_shader_id_)); font_ = dynamic_cast<sht::graphics::Font *>(resource_manager->GetResource(font_id_)); ball_mesh_ = dynamic_cast<sht::graphics::ComplexMesh *>(resource_manager->GetResource(ball_mesh_id_)); maze_mesh_ = dynamic_cast<sht::graphics::ComplexMesh *>(resource_manager->GetResource(maze_mesh_id_)); // Create text objects fps_text_ = sht::graphics::DynamicText::Create(renderer_, 30); status_text_ = sht::graphics::DynamicText::Create(renderer_, 64); SetStatus(L"start"); // Create physics physics_ = new sht::physics::Engine(20 /* max sub steps */, 0.002f /* fixed time step */); //physics_->SetGravity(vec3(0.0f, -9800.0f, 0.0f)); // Setup physics objects { ball_ = physics_->AddSphere(vec3(0.0f, 0.0f, 0.0f), 0.150f, ball_size_); ball_->SetFriction(0.28f); ball_->SetRollingFriction(0.2f); ball_->SetSpinningFriction(0.5f); ball_->SetRestitution(0.98f); } { sht::graphics::MeshVerticesEnumerator enumerator(maze_mesh_); sht::physics::Object * object = physics_->AddMesh(vec3(0.0f, 0.0f, 0.0f), 0.0f, &enumerator); object->SetFriction(0.71f); object->SetRestitution(0.5f); } // Create meshes that have been loaded earlier ball_mesh_->AddFormat(sht::graphics::VertexAttribute(sht::graphics::VertexAttribute::kVertex, 3)); ball_mesh_->AddFormat(sht::graphics::VertexAttribute(sht::graphics::VertexAttribute::kNormal, 3)); ball_mesh_->AddFormat(sht::graphics::VertexAttribute(sht::graphics::VertexAttribute::kTexcoord, 2)); ball_mesh_->MakeRenderable(); maze_mesh_->AddFormat(sht::graphics::VertexAttribute(sht::graphics::VertexAttribute::kVertex, 3)); maze_mesh_->AddFormat(sht::graphics::VertexAttribute(sht::graphics::VertexAttribute::kNormal, 3)); maze_mesh_->MakeRenderable(); SetupCamera(); CreateMenu(); PrepareBeginning(); RequestRackRemove(); // later can be moved after table look overview BindShaderConstants(); }
SmartList<ServiceProviderInfo*>* EmailAccountWizardAccountPage::enumerateServiceProviders( const QString& domainName) const { QScopedPointer<AccountEnumerator> enumerator( AccountManagerFactory::createMozillaAccountEnumerator(domainName)); Q_ASSERT(enumerator); if (!enumerator) return 0; return enumerator->enumerateAccounts(); }
bool MorpheusHMD::open() { HMDDeviceEnumerator enumerator(HMDDeviceEnumerator::CommunicationType_HID); bool success = false; if (enumerator.is_valid()) { success = open(&enumerator); } return success; }
bool PSNaviController::open() { ControllerDeviceEnumerator enumerator(CommonControllerState::PSNavi); bool success= false; if (enumerator.is_valid()) { success= open(&enumerator); } return success; }
static void test_enumeration(void) { using enumerator = mtr::forward_enumerator<int>; auto fn = [](int a, int i)->int { return a + i; }; const int start = 111; const int end = 222; auto a = enumerator(start, end).foreach(0)(fn); SHOULD_BE_EQ(a, (end+1-start)*(start+end)/2, "Sum of the enumeration"); }
bool MorpheusHMD::open() { HMDDeviceEnumerator enumerator(CommonDeviceState::Morpheus); bool success = false; if (enumerator.is_valid()) { success = open(&enumerator); } return success; }
// PSMoveTracker bool PS3EyeTracker::open() // Opens the first HID device for the tracker { TrackerDeviceEnumerator enumerator(CommonControllerState::PS3EYE); bool success = false; if (enumerator.is_valid()) { success = open(&enumerator); } return success; }
bool PSDualShock4Controller::open() { ControllerDeviceEnumerator enumerator(ControllerDeviceEnumerator::CommunicationType_HID, CommonControllerState::PSDualShock4); bool success = false; if (enumerator.is_valid()) { success = open(&enumerator); } return success; }
static void test_enumeration_with_chars(void) { using enumerator = mtr::forward_enumerator<char>; using string = mtr::string; using foreach = mtr::foreach<enumerator,string,char>; auto en = enumerator('a', 'z'); auto fe = foreach(en, string()); auto fn = [](string a, char i)->string { return a.append(i); }; auto st = fe(fn); SHOULD_BE_EQ(st, string("abcdefghijklmnopqrstuvwxyz"), "Concatenation of characters"); }
static void test_range_constructor(void) { using enumerator = mtr::forward_enumerator<int>; const int start = 1; const int end = 2; auto e = enumerator(start, end); SHOULD_BE_FALSE(e.is_empty(), "Enumerator should not be empty"); SHOULD_BE_EQ(e(), start, "Value should be equal to start value"); SHOULD_BE_FALSE(e.next().is_empty(), "Next position should not be empty"); SHOULD_BE_EQ(e.next()(), start+1, "Next value should equal start value + 1"); SHOULD_BE_TRUE(e.next().next().is_empty(), "Next, next position should be empty"); }
Device::Device(const Device::DeviceMatcher& deviceMatcher,unsigned int index) :fd(-1) { /* Enumerate all devices on the rawhid subsystem: */ UdevContext context; UdevEnumerator enumerator(context); enumerator.addMatchSubsystem("hidraw"); enumerator.scanDevices(); /* Check all items in the enumerator against the given vendor/product ID: */ for(UdevListIterator dlIt=enumerator.getDevices();dlIt.isValid();++dlIt) { /* Get the udev device for the current list entry: */ UdevDevice rawhid=context.getDeviceFromSyspath(dlIt.getName()); /* Get the raw HID device's HID parent: */ UdevDevice hid=rawhid.getParent("hid"); if(hid.isValid()) { /* Get the bus type and vendor/product ID from the HID device's uevent sysattr value: */ BusType devBusType; unsigned short devVendorId,devProductId; std::string devSerialNumber; const char* uevent=hid.getSysattrValue("uevent"); parseUevent(uevent,devBusType,devVendorId,devProductId,devSerialNumber); /* Check if the device matches the search parameters: */ if(deviceMatcher(devBusType,devVendorId,devProductId)) { /* Check if this is the requested device: */ if(index==0) { /* Initialize the device: */ initDevice(rawhid.getDevnode(),devBusType,devVendorId,devProductId,devSerialNumber); /* Stop searching: */ break; } else { /* Keep looking: */ --index; } } } } /* Check if device was found: */ if(fd<0) Misc::throwStdErr("RawHID::Device::Device: Device not found"); }
//----------------------------------------------------------------------------- // Enumerates over all entities along a ray // If triggers == true, it enumerates all triggers along a ray //----------------------------------------------------------------------------- void CEngineTrace::EnumerateEntities( const Ray_t &ray, bool bTriggers, IEntityEnumerator *pEnumerator ) { // FIXME: If we store CBaseHandles directly in the spatial partition, this method // basically becomes obsolete. The spatial partition can be queried directly. CEnumerationFilter enumerator( this, pEnumerator ); int fMask = !bTriggers ? SpatialPartitionMask() : SpatialPartitionTriggerMask(); // NOTE: Triggers currently don't exist on the client if (fMask) { SpatialPartition()->EnumerateElementsAlongRay( fMask, ray, false, &enumerator ); } }
void testProjectBug() { solver.strategies().symTab.reset(new AtomIndex); builder.startProgram(*solver.strategies().symTab, 0, 0) .setAtomName(1, "x").setAtomName(2, "y").setAtomName(3, "z").setAtomName(4, "_p").setAtomName(5, "_q").setAtomName(6, "_r") .startRule(CHOICERULE).addHead(1).addHead(2).addHead(4).endRule() // {x,y,_p} .startRule().addHead(5).addToBody(1, true).addToBody(4, true).endRule() // _q :- x,_p. .startRule().addHead(6).addToBody(2, true).addToBody(4, true).endRule() // _r :- y,_p. .startRule().addHead(3).addToBody(5, true).addToBody(6, true).endRule() // z :- _q,_r. ; CPPUNIT_ASSERT_EQUAL(true, builder.endProgram(solver, true)); BacktrackEnumerator enumerator(7,0); enumerator.setEnableProjection(true); enumerator.init(solver, 0); AtomIndex& index = *solver.strategies().symTab; solver.assume(index[1].lit); solver.propagate(); solver.assume(index[2].lit); solver.propagate(); solver.assume(index[4].lit); solver.propagate(); CPPUNIT_ASSERT(solver.numVars() == solver.numAssignedVars()); solver.stats.solve.addModel(solver.decisionLevel()); CPPUNIT_ASSERT_EQUAL(true, enumerator.backtrackFromModel(solver)); solver.undoUntil(0); uint32 numT = 0; if (solver.value(index[1].lit.var()) == value_free) { solver.assume(index[1].lit) && solver.propagate(); ++numT; } else if (solver.isTrue(index[1].lit)) { ++numT; } if (solver.value(index[2].lit.var()) == value_free) { solver.assume(index[2].lit) && solver.propagate(); ++numT; } else if (solver.isTrue(index[2].lit)) { ++numT; } if (solver.value(index[4].lit.var()) == value_free) { solver.assume(index[4].lit) && solver.propagate(); } if (solver.isTrue(index[3].lit)) { ++numT; } CPPUNIT_ASSERT(numT < 3); enumerator.endSearch(solver, false); }
bool RemoveDirectoryWithSubItems(const FString &path) { NFind::CFileInfo fileInfo; FString pathPrefix = path + FCHAR_PATH_SEPARATOR; { NFind::CEnumerator enumerator(pathPrefix + FCHAR_ANY_MASK); while (enumerator.Next(fileInfo)) if (!RemoveDirectorySubItems2(pathPrefix, fileInfo)) return false; } if (!MySetFileAttributes(path, 0)) return false; return MyRemoveDirectory(path); }
/** * @fn void Array::filterObjects(const Array *self, ArrayEnumerator enumerator, ident data) * * @memberof Array */ static Array *filterObjects(const Array *self, ArrayEnumerator enumerator, ident data) { assert(enumerator); MutableArray *array = $(alloc(MutableArray), init); for (size_t i = 0; i < self->count; i++) { if (enumerator(self, self->elements[i], data)) { $(array, addObject, self->elements[i]); } } return (Array *) array; }