void Matrix::init() { initRules(); initField(); initStats(); initTetrominoes(); initState(); initTimer(); }
bool GesturePipeline::init() { _pxcSenseManager = PXCSenseManager::CreateInstance(); /* Set Mode & Source */ pxcCHAR * deviceName = retrieveDeviceName(); _pxcSenseManager->QueryCaptureManager()->FilterByDeviceInfo(deviceName, 0, 0); pxcStatus status = _pxcSenseManager->EnableHand(); _pxcHandModule = _pxcSenseManager->QueryHand(); if (_pxcHandModule == NULL || status != pxcStatus::PXC_STATUS_NO_ERROR) { cocos2d::log("Failed to pair the gesture module with I/O"); return 0; } /* Init */ if (_pxcSenseManager->Init() >= PXC_STATUS_NO_ERROR) { _pxcHandData = _pxcHandModule->CreateOutput(); initRules(_pxcHandData); // IF IVCAM Set the following properties PXCCapture::Device *device = _pxcSenseManager->QueryCaptureManager()->QueryDevice(); PXCCapture::DeviceInfo dinfo; device->QueryDeviceInfo(&dinfo); if (dinfo.model == PXCCapture::DEVICE_MODEL_IVCAM) { device->SetDepthConfidenceThreshold(1); device->SetMirrorMode(PXCCapture::Device::MIRROR_MODE_DISABLED); device->SetIVCAMFilterOption(6); } // Hand Module Configuration PXCHandConfiguration* config = _pxcHandModule->CreateActiveConfiguration(); config->SetTrackingMode(PXCHandData::TrackingModeType::TRACKING_MODE_FULL_HAND); config->EnableSegmentationImage(true); config->ApplyChanges(); config->Update(); config->Release(); return 1; } else { cocos2d::log("Init Failed"); return 0; } }
int main(int argc, char * argv[]) { clock_t startTime, endTime; startTime = clock(); Rule rules[NUM_RULES]; initRules(rules); Contradiction contradictions[NUM_CONTRADICTIONS]; initContradictions(contradictions); int selectedRules[NUM_RULES - NUM_CONST_RULES]; for (int i = 0; i < NUM_RULES - NUM_CONST_RULES; i++) { selectedRules[i] = i; } for (int i = 1; i < argc; i++) { char * filename = argv[i]; std::cout << "Puzzle: " << filename << std::endl; Grid grid; Import importer = Import(grid, filename); Export exporter = Export(grid); Solver solver = Solver(grid, rules, contradictions, selectedRules, NUM_RULES - NUM_CONST_RULES, 100); exporter.print(); if (grid.isSolved()) { std::cout << "Solved" << std::endl; } else { if (solver.testContradictions()) { std::cout << "Invalid puzzle" << std::endl; } else if (solver.hasMultipleSolutions()) { std::cout << "Puzzle has multiple solutions" << std::endl; } else { std::cout << "Not solved" << std::endl; } } } endTime = clock(); float diff = ((float)endTime - (float)startTime) / CLOCKS_PER_SEC; std::cout << "Total time:\t" << diff << " seconds" << std::endl; return EXIT_SUCCESS; }
//start method bool com_objective_see_firewall::start(IOService *provider) { //return var bool result = false; //dbg msg IOLog("LULU: in %s\n", __FUNCTION__); //super if(TRUE != super::start(provider)) { //bail goto bail; } //alloc memory tag allocTag = OSMalloc_Tagalloc(BUNDLE_ID, OSMT_DEFAULT); if(NULL == allocTag) { //err msg IOLog("LULU ERROR: OSMalloc_Tagalloc() failed\n"); //bail goto bail; } //alloc // ->rule locks, etc if(true != initRules()) { //err msg IOLog("LULU ERROR: failed to init rules/locks\n"); //bail goto bail; } //init shared data queue sharedDataQueue = IOSharedDataQueue::withCapacity(sizeof(firewallEvent) * (MAX_FIREWALL_EVENTS + DATA_QUEUE_ENTRY_HEADER_SIZE)); if(NULL == sharedDataQueue) { //bail goto bail; } //get memory descriptor sharedMemoryDescriptor = sharedDataQueue->getMemoryDescriptor(); if(NULL == sharedMemoryDescriptor) { //bail goto bail; } //register service // allows clients to connect registerService(); //dbg msg IOLog("LULU: registered service %s\n", LULU_SERVICE_NAME); //set user class setProperty("IOUserClientClass", LULU_USER_CLIENT_CLASS); //init broadcast if(true != initBroadcast()) { //err msg IOLog("LULU ERROR: initBroadcast() failed\n"); //bail goto bail; } //all happy result = true; bail: return result; }