/****************************************************************************** * This function blocks until the scene has become ready. ******************************************************************************/ bool DataSet::waitUntilSceneIsReady(const QString& message, QProgressDialog* progressDialog) { std::atomic_flag keepWaiting; keepWaiting.test_and_set(); runWhenSceneIsReady( [&keepWaiting]() { keepWaiting.clear(); } ); return container()->waitUntil([&keepWaiting]() { return !keepWaiting.test_and_set(); }, message, progressDialog); }
Option::Option() : mainCon(350, 200), speedCon(350, 50), speedLabel("Speed (ms)"), speedTF(80, this), togglesCon(350, 50), anim("Anim"), query("Query"), ms("MS Seed"), play("Auto"), replyCon(300, 100), okButton(" OK ", this), cancelButton("Cancel", this) { speedCon.add(&speedLabel); speedCon.add(&speedTF); speedCon.reallocate(); togglesCon.add(&anim); togglesCon.add(&query); togglesCon.add(&ms); togglesCon.add (&play); togglesCon.reallocate(); replyCon.add(&okButton); replyCon.add(&cancelButton); replyCon.reallocate(); mainCon.add(&speedCon); mainCon.add(&togglesCon); mainCon.add(&replyCon); mainCon.reallocate(); container(&mainCon); char* home = getenv("HOME"); if (home == NULL) { fprintf(stderr, "Cannot get $HOME. Assuming I am at home directory now.\n"); saveFile = ".xfreecell"; } else { saveFile = home; saveFile += "/.xfreecell"; } DIR* dir = opendir(saveFile.c_str()); if (dir == NULL) { switch (errno) { case ENOENT: fprintf(stderr, "Directory %s not found. Creating.\n", saveFile.c_str()); mkdir(saveFile.c_str(), 0755); break; case ENOTDIR: fprintf(stderr, "%s must be directory.\n", saveFile.c_str()); exit(1); break; default: perror("ScoreWindow::ScoreWindow()"); exit(1); } } else closedir(dir); saveFile += "/prefs"; readPrefs(); }
void Visualisation::initContainer() { Container container(Dimensions(10, 4, 5), 1); IPackageGenerator* generator = new PackageGenerator(container.getDimensions(), 10, 5); if(loader != nullptr) delete loader; loader = new ContainerLoader(container, generator); delete generator; }
int main(int argc, char* argv[]) { if(argc != 2) { std::cout << "Usage : " << argv[0] << " <movie | pic>" << std::endl; return 0; } bool movie = std::string(argv[1])=="movie"; // random seed initialization std::srand(std::time(0)); // Let us create a dictionary... auto dict = gaml::span::dictionary<Point>(NU,gaussian_kernel); // ... and adjust it so that it spans the distribution. for(unsigned int nb = 0; nb < NB_SAMPLES; ++nb) dict.submit(get_sample()); std::cout << dict.container().size() << " samples added."<< std::endl; Graph som; Similarity distance; UnitSimilarity unit_distance(distance); Learn learning_rule; UnitLearn unit_learning_rule(learning_rule); WinnerTakeMost competition; std::cout << "Processing SOM..." << std::endl; auto line = vq2::algo::make::line(som,K, [&dict](unsigned int w) -> Feature {return dict(Point(0,0));}, [](unsigned int w, unsigned int ww) -> char {return ' ';}); unsigned int k = 0; for(auto& ref_vertex : line) (*ref_vertex).stuff.label = k++; competition.coef = WIDE_COEF; for(unsigned int nb = 0; nb < NB_EPOCHS; ++nb) { if(nb == START_NARROW_EPOCH) competition.coef = NARROW_COEF; for(unsigned int e = 0; e < EPOCH_SIZE; ++e) vq2::algo::som::step(som,unit_distance,competition, unit_learning_rule, LEARNING_RATE, dict(get_sample())); if(movie) { std::ostringstream filename; filename << "som-" << std::setw(6) << std::setfill('0') << nb << ".ppm"; plot(som,unit_distance,dict,filename.str()); } } if(!movie) plot(som,unit_distance,dict,"som.ppm"); return 0; }
void KAction::updateShortcut( int i ) { int id = itemId( i ); QWidget* w = container( i ); if ( ::qt_cast<QPopupMenu *>( w ) ) { QPopupMenu* menu = static_cast<QPopupMenu*>(w); updateShortcut( menu, id ); } else if ( ::qt_cast<QMenuBar *>( w ) ) static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); }
int main (int argc, const char * argv[]) { int port = DEFAULT_PORT; int bufferSize = DEFAULT_BUFFER_SIZE; bool isQuiet = DEFAULT_QUIET; bool isDebug = DEFAULT_DEBUG; int maxClient = DEFAULT_MAXCLIENT; signal(SIGINT, signalHandler); signal(SIGTERM, signalHandler); readArgs(argc,argv,&port,&bufferSize,&isQuiet,&isDebug,&maxClient); logger.setQuiet(isQuiet); logger.setDebug(isDebug); if(!isQuiet) { printInfo(port,bufferSize,isDebug,maxClient); } List<Client*> list; sf::Mutex listMutex; sf::SocketSelector selector; Buffer exchangeBuffer; setupExchangeBuffer(&exchangeBuffer, bufferSize); logger.printLog("Init'ed ..."); ClientsContainer container(&list,&listMutex,&selector); sf::Thread answerThread(&answerToClient,AnswerDataSet(&container,port,maxClient)); answerThread.launch(); sf::Thread checkThread(&checkForInputs,CheckDataSet(&container,&exchangeBuffer)); checkThread.launch(); while(1) //TODO graphic stats { if(checkStopThreads()) { break; } sf::sleep(sf::milliseconds(5)); } return 0; }
void test_table(void) { catdb::DBase::Database database("Billy_database"); catdb::DBase::Database database1("Johnny_database"); catdb::Column* temp = database.find_column("Cool"); std::cout << temp->display_list() << std::endl; delete temp; temp = NULL; catdb::Container* container(new catdb::Container("Alex")); catdb::Container container1("Billy"); catdb::Container container2("Fred"); catdb::Container container3("Zen"); container->insert_new_element("12.2", "Cool"); container1.insert_new_element("14.3", "Cool"); container2.insert_new_element("99.9", "Cool"); container3.insert_new_element("80.2", "Cool"); std::cout << container->obtain_element("12.2")->get_attribute() << std::endl; // not implemented yet!! database.add_container(container); database.add_container(&container1); database.add_container(&container2); database.add_container(&container3); std::cout << database.get_container("Alex")->get_container_name() << std::endl; std::cout << "Here is a list of stuff in this column" << std::endl; catdb::Column* column = database.find_column("Cool"); catdb::Element* element = column->inspect_element("12.2", "Cool"); column->sort_column(tools::sorting::quick_sort, tools::sorting::SORT_LITTLE_ENDIAN); std::cout << column->display_list() << std::endl; database.remove_container("Alex"); database.remove_container("Billy"); database.remove_container("Fred"); database.remove_container("Zen"); delete column; column = NULL; database1 = database; catdb::GreaterComparator<catdb::Element> _g; catdb::Comparator<catdb::Element>& _comp = catdb::LesserComparator<catdb::Element>(); catdb::Element el1("Cooler", "Bool", "Mang"); catdb::Element el2("Alex", "Benson", "Kol"); std::cout << _comp(el1, el2) << std::endl; tools::data_structures::hash_map<int, int> mapping; // if (database.get_container("Alex") == NULL) // std::cout << "Alex is deleted!" << std::endl; // database.folder_create(); // catdb::DBase::display_db_error_msg(); }
OCStackApplicationResult listenCallback(void* ctx, OCDoHandle handle, OCClientResponse* clientResponse) { ClientCallbackContext::ListenContext* context = static_cast<ClientCallbackContext::ListenContext*>(ctx); if(clientResponse->result != OC_STACK_OK) { oclog() << "listenCallback(): failed to create resource. clientResponse: " << clientResponse->result << std::flush; return OC_STACK_KEEP_TRANSACTION; } auto clientWrapper = context->clientWrapper.lock(); if(!clientWrapper) { oclog() << "listenCallback(): failed to get a shared_ptr to the client wrapper" << std::flush; return OC_STACK_KEEP_TRANSACTION; } std::stringstream requestStream; requestStream << clientResponse->resJSONPayload; try { ListenOCContainer container(clientWrapper, *clientResponse->addr, requestStream); // loop to ensure valid construction of all resources for(auto resource : container.Resources()) { std::thread exec(context->callback, resource); exec.detach(); } } catch(const std::exception& e) { oclog() << "listenCallback failed to parse a malformed message: " << e.what() << std::endl <<std::endl << clientResponse->result << std::flush; return OC_STACK_KEEP_TRANSACTION; } return OC_STACK_KEEP_TRANSACTION; }
bool StateMachine::callState(const unsigned short newState, Object* const arg) { bool ok = false; StateMachine* parent = dynamic_cast<StateMachine*>( container() ); if (parent != nullptr && sp > 0) { ok = parent->call(newState,arg); if (ok) { stateStack[--sp] = state; substateStack[sp] = substate; } } return ok; }
void TKAction::updateLayout() { int len = containerCount(); for( int id = 0; id < len; ++id ) { QWidget* w = container( id ); if (w->inherits("KToolBar")) { QWidget* r = static_cast<KToolBar*>(w)->getWidget(itemId(id)); if (qstrcmp(r->name(),"KTToolBarLayout")==0) { updateLayout(r); } } } }
void menu_dats_view::get_data() { std::vector<int> xstart, xend; std::string buffer(mame_machine_manager::instance()->lua()->call_plugin(util::string_format("%d", m_items_list[m_actual].option).c_str(), "data")); auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend); for (int x = 0; x < lines; ++x) { std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x])); item_append(tempbuf, "", (FLAG_UI_DATS | FLAG_DISABLE), (void *)(uintptr_t)(x + 1)); } }
OCStackApplicationResult listenCallback(void* ctx, OCDoHandle /*handle*/, OCClientResponse* clientResponse) { ClientCallbackContext::ListenContext* context = static_cast<ClientCallbackContext::ListenContext*>(ctx); if(clientResponse->result != OC_STACK_OK) { /* oclog() << "listenCallback(): failed to create resource. clientResponse: " << clientResponse->result << std::flush;*/ return OC_STACK_KEEP_TRANSACTION; } if(!clientResponse->payload) { oclog() << "listenCallback(): clientResponse payload was null" << std::flush; return OC_STACK_KEEP_TRANSACTION; } if(clientResponse->payload->type != PAYLOAD_TYPE_DISCOVERY) { oclog() << "listenCallback(): clientResponse payload was the wrong type" << std::flush; oclog() << "Type is: %i" << clientResponse->payload->type << std::flush; return OC_STACK_KEEP_TRANSACTION; } auto clientWrapper = context->clientWrapper.lock(); if(!clientWrapper) { oclog() << "listenCallback(): failed to get a shared_ptr to the client wrapper" << std::flush; return OC_STACK_KEEP_TRANSACTION; } ListenOCContainer container(clientWrapper, clientResponse->devAddr, reinterpret_cast<OCDiscoveryPayload*>(clientResponse->payload)); // loop to ensure valid construction of all resources for(auto resource : container.Resources()) { std::thread exec(context->callback, resource); exec.detach(); } return OC_STACK_KEEP_TRANSACTION; }
STDMETHODIMP HippoExplorerBar::SetSite(IUnknown *site) { site_ = NULL; if (site) { // Get the window from the parent HippoQIPtr<IOleWindow> oleWindow(site); if (!oleWindow) return E_FAIL; HWND parentWindow = NULL; HRESULT hr = oleWindow->GetWindow(&parentWindow); if (FAILED (hr)) return hr; if (!parentWindow) return E_FAIL; if (FAILED(site->QueryInterface<IInputObjectSite>(&site_))) return E_FAIL; HippoQIPtr<IServiceProvider> serviceProvider = site_; if (serviceProvider) serviceProvider->QueryService<IWebBrowser2>(SID_SWebBrowserApp, &browser_); if (browser_) { HippoQIPtr<IConnectionPointContainer> container(browser_); if (container) { if (SUCCEEDED(container->FindConnectionPoint(DIID_DWebBrowserEvents2, &connectionPoint_))) { // The COM-safe downcast here is a little overkill ... // we actually just need to disambiguate HippoQIPtr<IUnknown> unknown(static_cast<IDispatch *>(this)); connectionPoint_->Advise(unknown, &connectionCookie_); } } } if (!createWindow(parentWindow)) { site_ = NULL; return E_FAIL; } createIE(); } return S_OK; }
void menu_display_actual::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width, maxwidth = origx2 - origx1; float lineh = ui().get_line_height(); for (auto & elem : m_folders) { ui().draw_text_full(container(), elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); width += (2.0f * UI_BOX_LR_BORDER) + 0.01f; maxwidth = std::max(maxwidth, width); } // get the size of the text ui().draw_text_full(container(), m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); width += (2.0f * UI_BOX_LR_BORDER) + 0.01f; maxwidth = std::max(width, maxwidth); // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; float y2 = y1 + lineh + 2.0f * UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), m_tempbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; y1 = y2 + 2.0f * UI_BOX_TB_BORDER; y2 = origy1 - UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it for (auto & elem : m_folders) { ui().draw_text_full(container(), elem.c_str(), x1, y1, x2 - x1, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); y1 += lineh; } }
void submenu::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; ui().draw_text_full(container(), _(m_options[0].description), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; float maxwidth = std::max(origx2 - origx1, width); // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; float y2 = origy1 - UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), _(m_options[0].description), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); if (selectedref != nullptr) { option &selected_sm_option = *reinterpret_cast<option *>(selectedref); if (selected_sm_option.entry != nullptr) { ui().draw_text_full(container(), selected_sm_option.entry->description(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(origx2 - origx1, width); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; y1 = origy2 + UI_BOX_TB_BORDER; y2 = origy2 + bottom; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_RED_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), selected_sm_option.entry->description(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); } } }
OCStackApplicationResult listenErrorCallback(void* ctx, OCDoHandle /*handle*/, OCClientResponse* clientResponse) { if (!ctx || !clientResponse) { return OC_STACK_KEEP_TRANSACTION; } ClientCallbackContext::ListenErrorContext* context = static_cast<ClientCallbackContext::ListenErrorContext*>(ctx); if (!context) { return OC_STACK_KEEP_TRANSACTION; } OCStackResult result = clientResponse->result; if (result == OC_STACK_OK) { if (!clientResponse->payload || clientResponse->payload->type != PAYLOAD_TYPE_DISCOVERY) { oclog() << "listenCallback(): clientResponse payload was null or the wrong type" << std::flush; return OC_STACK_KEEP_TRANSACTION; } auto clientWrapper = context->clientWrapper.lock(); if (!clientWrapper) { oclog() << "listenCallback(): failed to get a shared_ptr to the client wrapper" << std::flush; return OC_STACK_KEEP_TRANSACTION; } ListenOCContainer container(clientWrapper, clientResponse->devAddr, reinterpret_cast<OCDiscoveryPayload*>(clientResponse->payload)); // loop to ensure valid construction of all resources for (auto resource : container.Resources()) { std::thread exec(context->callback, resource); exec.detach(); } return OC_STACK_KEEP_TRANSACTION; } std::string resourceURI = clientResponse->resourceUri; std::thread exec(context->errorCallback, resourceURI, result); exec.detach(); return OC_STACK_DELETE_TRANSACTION; }
void menu_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { float width; std::string tempbuf = std::string(_("Selection List - Search: ")).append(m_search).append("_"); // get the size of the text ui().draw_text_full(container(), tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += (2.0f * UI_BOX_LR_BORDER) + 0.01f; float maxwidth = std::max(width, origx2 - origx1); // compute our bounds float x1 = 0.5f - 0.5f * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; float y2 = origy1 - UI_BOX_TB_BORDER; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), tempbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); // bottom text // get the text for 'UI Select' std::string ui_select_text = machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD)); tempbuf = string_format(_("Double click or press %1$s to select"), ui_select_text); ui().draw_text_full(container(), tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); width += 2 * UI_BOX_LR_BORDER; maxwidth = std::max(maxwidth, width); // compute our bounds x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; y1 = origy2 + UI_BOX_TB_BORDER; y2 = origy2 + bottom; // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_RED_COLOR); // take off the borders x1 += UI_BOX_LR_BORDER; x2 -= UI_BOX_LR_BORDER; y1 += UI_BOX_TB_BORDER; // draw the text within it ui().draw_text_full(container(), tempbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); }
void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data) { if ((node.isRootNode() && (name == "width" || name == "height")) || name.endsWith(PropertyName("@NodeInstance"))) { if (hasInstanceForModelNode(node)) { NodeInstance instance = instanceForModelNode(node); QVariant value = data; if (value.isValid()) { PropertyValueContainer container(instance.instanceId(), name, value, TypeName()); ChangeAuxiliaryCommand changeAuxiliaryCommand(QVector<PropertyValueContainer>() << container); nodeInstanceServer()->changeAuxiliaryValues(changeAuxiliaryCommand); } else { if (node.hasVariantProperty(name)) { PropertyValueContainer container(instance.instanceId(), name, node.variantProperty(name).value(), TypeName()); ChangeValuesCommand changeValueCommand(QVector<PropertyValueContainer>() << container); nodeInstanceServer()->changePropertyValues(changeValueCommand); } else if (node.hasBindingProperty(name)) { PropertyBindingContainer container(instance.instanceId(), name, node.bindingProperty(name).expression(), TypeName()); ChangeBindingsCommand changeValueCommand(QVector<PropertyBindingContainer>() << container); nodeInstanceServer()->changePropertyBindings(changeValueCommand); } } } } }
int main() { std::vector<int> v; v.push_back(5); v.push_back(2); v.push_back(9); Circulator c( v.begin(), v.end()); Container container( c); std::sort( container.begin(), container.end()); Iterator i = container.begin(); assert( *i == 2); i++; assert( *i == 5); i++; assert( *i == 9); i++; assert( i == container.end()); return 0; }
static void draw_density ( void ) { static Float x, y, d00, d01, d10, d11; glBegin ( GL_QUADS ); for (int i=1 ; i<=NX ; i++ ) { x = (i-0.5)*HH; for (int j=1 ; j<=NY ; j++ ) { y = (j-0.5)*HH; d00 = container(i,j) > 0. ? 0. : 200; d01 = container(i,j+1) > 0. ? 0. : 200; d10 = container(i+1,j) > 0. ? 0. : 200; d11 = container(i+1,j+1) > 0. ? 0. : 200; glColor3f ( d00, d00, d00 ); glVertex2f ( x, y ); glColor3f ( d10, d10, d10 ); glVertex2f ( x+HH, y ); glColor3f ( d11, d11, d11 ); glVertex2f ( x+HH, y+HH ); glColor3f ( d01, d01, d01 ); glVertex2f ( x, y+HH ); } } glEnd (); }
// Is the iterator positioned at the last element? UtlBoolean UtlListIterator::atLast() const { UtlBoolean isAtLast = false; UtlContainer::acquireIteratorConnectionLock(); OsLock take(const_cast<OsBSem&>(mContainerRefLock)); UtlList* myList = static_cast<UtlList*>(mpMyContainer); OsLock container(myList->mContainerLock); UtlContainer::releaseIteratorConnectionLock(); isAtLast = (mpCurrentNode && mpCurrentNode == myList->tail()); return isAtLast; }
// return the current data UtlContainable* UtlListIterator::item() const { UtlContainable* currentItem = NULL; UtlContainer::acquireIteratorConnectionLock(); OsLock take(const_cast<OsBSem&>(mContainerRefLock)); UtlList* myList = static_cast<UtlList*>(mpMyContainer); OsLock container(myList->mContainerLock); UtlContainer::releaseIteratorConnectionLock(); currentItem = static_cast<UtlContainable*>(mpCurrentNode->data); return currentItem; }
UtlContainable* UtlListIterator::toLast() { UtlContainable* last = NULL; UtlContainer::acquireIteratorConnectionLock(); OsLock take(mContainerRefLock); UtlList* myList = static_cast<UtlList*>(mpMyContainer); OsLock container(myList->mContainerLock); UtlContainer::releaseIteratorConnectionLock(); mpCurrentNode = myList->tail(); last = static_cast<UtlContainable*>(mpCurrentNode ? mpCurrentNode->data : NULL); return last; }
partContainer HgammaHandler<partType, partContainer, auxContainer>::getStoreContainer(std::string name) { // Get shallow copy from TStore partContainer *storeContainer = NULL; if (m_store->retrieve(storeContainer, name).isFailure()) { fatal("Cannot access container"); } // Make the container from the TStore'd shallow copy partContainer container(storeContainer->begin(), storeContainer->end(), SG::VIEW_ELEMENTS); return container; }
//************************************************************************* // main - Application entry point * //************************************************************************* int main() { ICoordinateSystem::setApplicationOrientation( ICoordinateSystem::kOriginLowerLeft ); IResourceLibrary reslib; IFrameWindow frame(reslib.loadString(WND_MAIN), WND_MAIN); // Create the details view container with columns that // displays the Department name and address. IContainerControl container(0x8008, &frame, &frame); IContainerColumn name(IContainerColumn::isIconViewText); IContainerColumn address( Department::offsetOfAddress()); name.setHeadingText( STR_HEAD_1 ); address.setHeadingText( STR_HEAD_2 ); container.addColumn(&name); container.addColumn(&address); // Create the Department objects and add them to // the container. Department* department; department = new Department(reslib.loadString(STR_ITEM_1_1), reslib.loadString(STR_ITEM_1_2)); container.addObject(department); department = new Department(reslib.loadString(STR_ITEM_2_1), reslib.loadString(STR_ITEM_2_2)); container.addObject(department); // Create the cut and paste handler (the handlers are // added in the constructor). ContainerCutPasteHandler handler(container); // Enable extended selection, switch to details view, and // give the container the focus. container.setExtendedSelection(); container.showDetailsView(); container.setFocus(); // Add an icon to the frame, put the container in the // client, and show the frame window. frame.setIcon( frame.id() ); frame.setClient(&container); frame.show(); // Start processing events. IApplication::current().run(); return 0; }
int QMessage::size() const { int size = 0; if (d_ptr->_size != 0) { size = d_ptr->_size; } else { QMessageContentContainerPrivate *container(((QMessageContentContainer *)(this))->d_ptr); if (container->_size != 0) { size += container->_size; } foreach (const QMessageContentContainer &attachment, container->_attachments) { size += attachment.size(); } } return size; }
static void draw_points ( void ) { static Float x, y, d00; glBegin ( GL_POINTS ); for (int i=1 ; i<=NX ; i++ ) { x = (i-0.5)*HH; for (int j=1 ; j<=NY ; j++ ) { y = (j-0.5)*HH; d00 = container(i,j) > 0. ? 0. : 1.0; glColor3f ( d00, d00, d00 ); glVertex2f ( x, y ); } } glEnd (); }
void PicturePile::appendToPile(const IntRect& inval, const IntRect& originalInval) { ALOGV("Adding inval " INT_RECT_FORMAT " for original inval " INT_RECT_FORMAT, INT_RECT_ARGS(inval), INT_RECT_ARGS(originalInval)); // Remove any entries this obscures for (int i = (int) m_pile.size() - 1; i >= 0; i--) { if (inval.contains(m_pile[i].area)) m_pile.remove(i); } PictureContainer container(inval); if (ENABLE_PRERENDERED_INVALS) { container.prerendered = PrerenderedInval::create(originalInval.isEmpty() ? inval : originalInval); } m_pile.append(container); }
TEST_FIXTURE(container_test_base, container_get_reference) { auto block_blob = m_container.get_block_blob_reference(_XPLATSTR("blob1")); CHECK_UTF8_EQUAL(m_container.uri().primary_uri().to_string(), block_blob.container().uri().primary_uri().to_string()); CHECK_UTF8_EQUAL(m_container.uri().secondary_uri().to_string(), block_blob.container().uri().secondary_uri().to_string()); auto page_blob = m_container.get_page_blob_reference(_XPLATSTR("blob2")); CHECK_UTF8_EQUAL(m_container.uri().primary_uri().to_string(), page_blob.container().uri().primary_uri().to_string()); CHECK_UTF8_EQUAL(m_container.uri().secondary_uri().to_string(), page_blob.container().uri().secondary_uri().to_string()); auto append_blob = m_container.get_append_blob_reference(_XPLATSTR("blob3")); CHECK_UTF8_EQUAL(m_container.uri().primary_uri().to_string(), append_blob.container().uri().primary_uri().to_string()); CHECK_UTF8_EQUAL(m_container.uri().secondary_uri().to_string(), append_blob.container().uri().secondary_uri().to_string()); auto directory = m_container.get_directory_reference(_XPLATSTR("dir")); CHECK_UTF8_EQUAL(m_container.uri().primary_uri().to_string(), directory.container().uri().primary_uri().to_string()); CHECK_UTF8_EQUAL(m_container.uri().secondary_uri().to_string(), directory.container().uri().secondary_uri().to_string()); }
OCStackApplicationResult listenMQCallback(void* ctx, OCDoHandle /*handle*/, OCClientResponse* clientResponse) { ClientCallbackContext::ListenContext* context = static_cast<ClientCallbackContext::ListenContext*>(ctx); if (!clientResponse) { return OC_STACK_KEEP_TRANSACTION; } if (clientResponse->result != OC_STACK_OK) { oclog() << "listenMQCallback(): failed to create resource. clientResponse: " << clientResponse->result << std::flush; return OC_STACK_KEEP_TRANSACTION; } auto clientWrapper = context->clientWrapper.lock(); if (!clientWrapper) { oclog() << "listenMQCallback(): failed to get a shared_ptr to the client wrapper" << std::flush; return OC_STACK_KEEP_TRANSACTION; } try{ ListenOCContainer container(clientWrapper, clientResponse->devAddr, (OCRepPayload *) clientResponse->payload); // loop to ensure valid construction of all resources for (auto resource : container.Resources()) { std::thread exec(context->callback, resource); exec.detach(); } } catch (std::exception &e){ oclog() << "Exception in listCallback, ignoring response: " << e.what() << std::flush; } return OC_STACK_KEEP_TRANSACTION; }