Foam::Istream& Foam::ITstream::rewind() { tokenIndex_ = 0; if (size()) { lineNumber_ = tokenList::first().lineNumber(); } setGood(); return *this; }
// Rewind the token stream so that it may be read again Istream& ITstream::rewind() { tokenIndex_ = 0; if (size()) { lineNumber_ = operator[](0).lineNumber(); } setGood(); return *this; }
Foam::UOPstream::UOPstream(const int toProcNo, PstreamBuffers& buffers) : UPstream(buffers.commsType_), Ostream(buffers.format_, buffers.version_), toProcNo_(toProcNo), sendBuf_(buffers.sendBuf_[toProcNo]), tag_(buffers.tag_), comm_(buffers.comm_), sendAtDestruct_(buffers.commsType_ != UPstream::nonBlocking) { setOpened(); setGood(); }
IPstream::IPstream ( const commsTypes commsType, const int fromProcNo, const label bufSize, streamFormat format, versionNumber version ) : Pstream(commsType, bufSize), Istream(format, version), fromProcNo_(fromProcNo), messageSize_(0) { // Blocking read. setOpened(); setGood(); if (Pstream::debug) { Pout<< "IPstream::IPstream : Starting receive from " << fromProcNo_ << " recvIndex:" << PstreamGlobals::recvIndex[fromProcNo_] << Foam::endl; } PstreamGlobals::gammaWait(fromProcNo_); label ready = PstreamGlobals::consumeIndex[fromProcNo_]; messageSize_ = PstreamGlobals::recvBufLen[ready][fromProcNo_]; if (!bufSize) { if (Pstream::debug) { Pout<< "IPstream::IPstream : sizing buffer to " << messageSize_ << endl; } buf_.setSize(messageSize_); } PstreamGlobals::copyReceive(fromProcNo_, buf_.begin(), buf_.size()); if (Pstream::debug) { Pout<< "IPstream::IPstream : Received " << messageSize_ << " from " << fromProcNo_ << Foam::endl; } }
bool KeyboardButton::init(const Config &config) { uninit(); if (config.key == EventKeyboard::KeyCode::KEY_NONE) { return false; } m_key = config.key; m_is_pressed = false; setGood(initListener()); return *this; }
Foam::IPstream::IPstream ( const commsTypes commsType, const int fromProcNo, const label bufSize, streamFormat format, versionNumber version ) : Pstream(commsType, bufSize), Istream(format, version), fromProcNo_(fromProcNo), messageSize_(0) { setOpened(); setGood(); MPI_Status status; // If the buffer size is not specified, probe the incomming message // and set it if (!bufSize) { MPI_Probe(procID(fromProcNo_), msgType(), MPI_COMM_WORLD, &status); MPI_Get_count(&status, MPI_BYTE, &messageSize_); buf_.setSize(messageSize_); } messageSize_ = read(commsType, fromProcNo_, buf_.begin(), buf_.size()); if (!messageSize_) { FatalErrorIn ( "IPstream::IPstream(const int fromProcNo, " "const label bufSize, streamFormat format, versionNumber version)" ) << "read failed" << Foam::abort(FatalError); } }
Foam::OPstream::OPstream ( const commsTypes commsType, const int toProcNo, const label bufSize, streamFormat format, versionNumber version ) : Pstream(commsType, bufSize), Ostream(format, version), toProcNo_(toProcNo) { setOpened(); setGood(); if (!bufSize) { buf_.setSize(1000); } }
Foam::UOPstream::UOPstream ( const commsTypes commsType, const int toProcNo, DynamicList<char>& sendBuf, const int tag, const label comm, const bool sendAtDestruct, streamFormat format, versionNumber version ) : UPstream(commsType), Ostream(format, version), toProcNo_(toProcNo), sendBuf_(sendBuf), tag_(tag), comm_(comm), sendAtDestruct_(sendAtDestruct) { setOpened(); setGood(); }
void KeyboardButton::uninit() { getContext().getKeyboardManager()->removeListener(m_key); setGood(false); }
Foam::UIPstream::UIPstream ( const commsTypes commsType, const int fromProcNo, DynamicList<char>& externalBuf, label& externalBufPosition, const int tag, const bool clearAtEnd, streamFormat format, versionNumber version ) : UPstream(commsType), Istream(format, version), fromProcNo_(fromProcNo), externalBuf_(externalBuf), externalBufPosition_(externalBufPosition), tag_(tag), clearAtEnd_(clearAtEnd), messageSize_(0) { setOpened(); setGood(); if (commsType == UPstream::nonBlocking) { // Message is already received into externalBuf } else { MPI_Status status; label wantedSize = externalBuf_.capacity(); if (debug) { Pout<< "UIPstream::UIPstream : read from:" << fromProcNo << " tag:" << tag << " wanted size:" << wantedSize << Foam::endl; } // If the buffer size is not specified, probe the incomming message // and set it if (!wantedSize) { MPI_Probe(procID(fromProcNo_), tag_, MPI_COMM_WORLD, &status); MPI_Get_count(&status, MPI_BYTE, &messageSize_); externalBuf_.setCapacity(messageSize_); wantedSize = messageSize_; if (debug) { Pout<< "UIPstream::UIPstream : probed size:" << wantedSize << Foam::endl; } } messageSize_ = UIPstream::read ( commsType, fromProcNo_, externalBuf_.begin(), wantedSize, tag_ ); // Set addressed size. Leave actual allocated memory intact. externalBuf_.setSize(messageSize_); if (!messageSize_) { FatalErrorIn ( "UIPstream::UIPstream(const commsTypes, const int, " "DynamicList<char>&, streamFormat, versionNumber)" ) << "read failed" << Foam::abort(FatalError); } } }
Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers) : UPstream(buffers.commsType_), Istream(buffers.format_, buffers.version_), fromProcNo_(fromProcNo), externalBuf_(buffers.recvBuf_[fromProcNo]), externalBufPosition_(buffers.recvBufPos_[fromProcNo]), tag_(buffers.tag_), clearAtEnd_(true), messageSize_(0) { if (commsType() != UPstream::scheduled && !buffers.finishedSendsCalled_) { FatalErrorIn("UIPstream::UIPstream(const int, PstreamBuffers&)") << "PstreamBuffers::finishedSends() never called." << endl << "Please call PstreamBuffers::finishedSends() after doing" << " all your sends (using UOPstream) and before doing any" << " receives (using UIPstream)" << Foam::exit(FatalError); } setOpened(); setGood(); if (commsType() == UPstream::nonBlocking) { // Message is already received into externalBuf messageSize_ = buffers.recvBuf_[fromProcNo].size(); } else { MPI_Status status; label wantedSize = externalBuf_.capacity(); if (debug) { Pout<< "UIPstream::UIPstream PstreamBuffers :" << " read from:" << fromProcNo << " tag:" << tag_ << " wanted size:" << wantedSize << Foam::endl; } // If the buffer size is not specified, probe the incomming message // and set it if (!wantedSize) { MPI_Probe(procID(fromProcNo_), tag_, MPI_COMM_WORLD, &status); MPI_Get_count(&status, MPI_BYTE, &messageSize_); externalBuf_.setCapacity(messageSize_); wantedSize = messageSize_; if (debug) { Pout<< "UIPstream::UIPstream PstreamBuffers : probed size:" << wantedSize << Foam::endl; } } messageSize_ = UIPstream::read ( commsType(), fromProcNo_, externalBuf_.begin(), wantedSize, tag_ ); // Set addressed size. Leave actual allocated memory intact. externalBuf_.setSize(messageSize_); if (!messageSize_) { FatalErrorIn ( "UIPstream::UIPstream(const int, PstreamBuffers&)" ) << "read failed" << Foam::abort(FatalError); } } }
bool ShopPanel::init() { /*for(auto node:_buttons->getChildren()) { auto button = static_cast<Button*>(node); button->addTouchEventListener(CC_CALLBACK_2(ShopPanel::onButtonClicked, this)); }*/ //_container->setTouchEnabled(true); _container->setAnchorPoint(Vec2(0,0)); _listView = static_cast<ListView*>(Helper::seekWidgetByName(_root, "ListView_content")); _goodPan = static_cast<Layout*>(Helper::seekWidgetByName(_root, "Panel_good")); _goodPan->retain(); _goodPan->removeFromParent(); _listView->addEventListener((ui::ListView::ccListViewCallback)CC_CALLBACK_2(ShopPanel::selectedItemEvent, this)); _listView->addEventListener((ui::ListView::ccScrollViewCallback)CC_CALLBACK_2(ShopPanel::selectedItemEventScrollView,this)); //_title = Label::create("","Arial",20); //_title->setColor(Color3B::BLACK); //_title->setPosition(0, _container->getSize().height / 2 - 30); //_container->addChild(_title); //_label = Label::create("","Arial",17); //_label->setColor(Color3B::BLACK); //_label->setLineBreakWithoutSpace(true); //_label->setAnchorPoint(Vec2(0,0)); //_label->setDimensions(_scrollView->getSize().width,0); ////_label->setPositionY(_scrollView->getSize().height / 2); ////_label->setPositionX(_scrollView->getSize().width / 2); //_scrollView->addChild(_label); //auto clipper = ClippingNode::create(); //clipper->setContentSize(_scrollView->getSize()); ////clipper->setPositionY(_scrollView->getSize().height / 2 + _scrollView->getPosition().y); ////clipper->setAnchorPoint(Vec2(0.5, 0.5)); //_container->addChild(clipper); //auto stencil = DrawNode::create(); //Vec2 rectangle[4]; //rectangle[0] = Vec2(-clipper->getContentSize().width / 2, -clipper->getContentSize().height / 2); //rectangle[1] = Vec2(-clipper->getContentSize().width / 2, clipper->getContentSize().height / 2); //rectangle[2] = Vec2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2); //rectangle[3] = Vec2(clipper->getContentSize().width / 2, -clipper->getContentSize().height / 2); //Color4F white(1, 1, 1, 1); //stencil->drawPolygon(rectangle, 4, white, 1, white); //clipper->setStencil(stencil); //_scrollView->retain(); //_scrollView->removeFromParent(); //clipper->addChild(_scrollView); //_scrollView->release(); auto goodNum = cocos2d::Value(PlotScript::sharedHD()->getLuaVarString("script/Test.lua", "goodsNum")).asInt(); for(int i = 1; i <= goodNum; i++) { auto goodName = "good" + cocos2d::Value(i).asString(); auto content = PlotScript::sharedHD()->getLuaVarString("script/Test.lua", goodName.c_str()); ValueMap valueMap; stringToValueMap(std::string(content), valueMap); int lock = valueMap["lock"].asInt(); if(conditions[goodName+"_unlock"].intValue() == 1) lock = 0; if(lock == 0) { auto goodPan = _goodPan->clone(); auto goodUnit = GoodUnit::create(i); ValueMap model; model["typeId"] = valueMap["typeId"]; auto good = CellFactory::getInstance()->createCell(model); goodUnit->setGood(good); goodUnit->setPrice(valueMap["price"].asInt()); goodUnit->setNum(valueMap["num"].asInt()); goodUnit->setView(goodPan); _goodsUnit.pushBack(goodUnit); goodPan->setTag(i); _listView->pushBackCustomItem(goodPan); } } _container->setScale(0.85f); _container->setOpacity(200); _container->runAction(FadeIn::create(0.2)); _container->runAction(ScaleTo::create(0.2,1.0f,1.0f,1.0f)); _root->setTouchEnabled(true); _container->setTouchEnabled(false); _root->addTouchEventListener(CC_CALLBACK_2(ShopPanel::onButtonClicked, this)); setKeyboardEnabled(true); return true; }
IPstream::IPstream ( const int fromProcNo, const label bufSize, streamFormat format, versionNumber version ) : Pstream(bufSize), Istream(format, version), fromProcNo_(fromProcNo), messageSize_(0) { setOpened(); setGood(); int bufid, tag, tid; // If the buffer size is not specified then probe the incomming message if (!bufSize) { // Probe read buffer until message arrives. while (!(bufid = pvm_probe(procID(fromProcNo_), msgType()))); // When the message arrives find its size pvm_bufinfo(bufid, &messageSize_, &tag, &tid); // Resize buffer to message size buf_.setSize(messageSize_); } // Read message into buffer if ( pvm_precv ( procID(fromProcNo_), msgType(), buf_.begin(), buf_.size(), PVM_BYTE, &tid, &tag, &messageSize_ ) != PvmOk ) { FatalErrorIn("IPstream::IPstream(const int fromProcNo)") << "pvm_precv cannot receive incomming message" << ::abort; } // Check size of message read if (messageSize_ > buf_.size()) { FatalErrorIn("IPstream::IPstream(const int fromProcNo)") << "buffer (" << buf_.size() << ") not large enough for incomming message (" << messageSize_ << ')' << ::abort; } }