void Work::complete(CompleteResult result) { CLOG(DEBUG, "Work") << "completed " << getUniqueName(); auto& succ = mApp.getMetrics().NewMeter({"work", "unit", "success"}, "unit"); auto& fail = mApp.getMetrics().NewMeter({"work", "unit", "failure"}, "unit"); switch (result) { case WORK_COMPLETE_OK: setState(onSuccess()); break; case WORK_COMPLETE_FAILURE: setState(WORK_FAILURE_RETRY); break; case WORK_COMPLETE_FATAL: setState(WORK_FAILURE_FATAL); break; } switch (getState()) { case WORK_SUCCESS: succ.Mark(); CLOG(DEBUG, "Work") << "notifying parent of successful " << getUniqueName(); notifyParent(); break; case WORK_FAILURE_RETRY: fail.Mark(); onFailureRetry(); scheduleRetry(); break; case WORK_FAILURE_RAISE: case WORK_FAILURE_FATAL: fail.Mark(); onFailureRaise(); CLOG(DEBUG, "Work") << "notifying parent of failed " << getUniqueName(); notifyParent(); break; case WORK_PENDING: succ.Mark(); advance(); break; case WORK_RUNNING: succ.Mark(); scheduleRun(); break; default: assert(false); break; } }
void WriterNodeVisitor::apply3DSMatrixNode(osg::Node &node, const osg::Matrix * m, const char * const prefix) { // Note: Creating a mesh instance with no transform and then copying the matrix doesn't work (matrix seems to be a temporary/computed value) Lib3dsMeshInstanceNode * parent = _cur3dsNode; Lib3dsMeshInstanceNode * node3ds = NULL; if (m) { osg::Vec3 osgScl, osgPos; osg::Quat osgRot, osgSo; m->decompose(osgPos, osgRot, osgScl, osgSo); float pos[3]; float scl[3]; float rot[4]; copyOsgVectorToLib3dsVector(pos, osgPos); copyOsgVectorToLib3dsVector(scl, osgScl); copyOsgQuatToLib3dsQuat(rot, osgRot); node3ds = lib3ds_node_new_mesh_instance(NULL, getUniqueName(node.getName().empty() ? node.className() : node.getName(), true, prefix).c_str(), pos, scl, rot); } else { node3ds = lib3ds_node_new_mesh_instance(NULL, getUniqueName(node.getName().empty() ? node.className() : node.getName(), true, prefix).c_str(), NULL, NULL, NULL); } lib3ds_file_append_node(_file3ds, reinterpret_cast<Lib3dsNode*>(node3ds), reinterpret_cast<Lib3dsNode*>(parent)); _cur3dsNode = node3ds; }
void Work::advance() { if (getState() != WORK_PENDING) { return; } CLOG(DEBUG, "Work") << "advancing " << getUniqueName(); advanceChildren(); if (allChildrenSuccessful()) { CLOG(DEBUG, "Work") << "all " << mChildren.size() << " children of " << getUniqueName() << " successful, scheduling run"; scheduleRun(); } else if (anyChildFatalFailure()) { CLOG(DEBUG, "Work") << "some of " << mChildren.size() << " children of " << getUniqueName() << " fatally failed, scheduling " << "fatal failure"; scheduleFatalFailure(); } else if (anyChildRaiseFailure()) { CLOG(DEBUG, "Work") << "some of " << mChildren.size() << " children of " << getUniqueName() << " failed, scheduling failure"; scheduleFailure(); } }
void Work::notify(std::string const& child) { auto i = mChildren.find(child); if (i == mChildren.end()) { CLOG(ERROR, "Work") << "work " << getUniqueName() << " notified by unknown child " << child; } CLOG(DEBUG, "Work") << "notified " << getUniqueName() << " of completed child " << child; advance(); }
void Work::run() { if (getState() == WORK_PENDING) { CLOG(DEBUG, "Work") << "starting " << getUniqueName(); mApp.getMetrics().NewMeter({"work", "unit", "start"}, "unit").Mark(); onStart(); } CLOG(DEBUG, "Work") << "running " << getUniqueName(); mApp.getMetrics().NewMeter({"work", "unit", "run"}, "unit").Mark(); setState(WORK_RUNNING); onRun(); }
IrrlichtTexture::IrrlichtTexture(Renderer* r, irr::IrrlichtDevice* dr, float size) :Texture(r), device(dr),tex(0) { driver=device->getVideoDriver(); irr::core::dimension2d<irr::s32> texSz(size, size); tex = driver->addTexture(texSz, getUniqueName().c_str(), irr::video::ECF_A8R8G8B8); }
void Project::addMesh(std::unique_ptr<MeshLib::Mesh> mesh) { std::string name = mesh->getName(); getUniqueName(name); mesh->setName(name); _mesh_vec.push_back(std::move(mesh)); }
void MatLabUdmState::setupState( void ) { State udmState = getUdmState(); udmState.name() = getUniqueName().c_str(); udmState.RefId() = getRefId(); udmState.Description() = MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Description" ); // GET LABEL STRING, PERFORM SUBSTITUTIONS FOR READABILITY std::string labelString = RegexCommon::eliminateContinuations( MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".LabelString" ) ); labelString = boost::regex_replace( labelString, MatLabEngine::matLabComment(), "" ); std::string stateType = MatLabEngine::globalEngine().getMxStringValue( std::string( "class( " + getMatLabObject() + " )" ) ); if ( stateType == "Stateflow.Box" ) { udmState.Decomposition() = "GROUP_STATE"; return; } // REGISTER THIS STATE SO TRANSITIONS CAN LOCATE IT AND USE IT AS AN ENDPOINT registerForTransitions(); std::string stateOrder = boost::lexical_cast< std::string >( MatLabEngine::globalEngine().getMxIntValue( getMatLabObject() + ".ExecutionOrder" ) ); udmState.Order() = stateOrder.empty() ? "0" : stateOrder; static boost::regex nameRegex( std::string( "\\A\\s*(\\w*)\\s*/?\\s*" ), boost::regex_constants::perl ); static boost::regex actionRegex( std::string( "((\\w+)\\s*:\\s*(.*?\\S?)\\s*)(?:\\w+\\s*:|\\z)" ), boost::regex_constants::perl ); static boost::regex defaultActionRegex( std::string( "\\A\\s*(.*\\S?)\\s*\\Z" ), boost::regex_constants::perl ); boost::match_results< std::string::const_iterator > results; if ( regex_search( labelString, results, nameRegex ) ) { udmState.Name() = std::string( results[1].first, results[1].second ).c_str(); labelString = std::string( results[0].second, static_cast< std::string::const_iterator >( labelString.end() ) ); } while ( regex_search( labelString, results, actionRegex ) ) { std::string actionName( results[2].first, results[2].second ); std::transform( actionName.begin(), actionName.end(), actionName.begin(), ToLower() ); std::string actionValue( results[3].first, results[3].second ); if ( actionName.substr(0, 2) == "en" ) udmState.EnterAction() = actionValue.c_str(); else if ( actionName.substr(0, 1) == "d" ) udmState.DuringAction() = actionValue.c_str(); else if ( actionName.substr(0, 2) == "ex" ) udmState.ExitAction() = actionValue.c_str(); labelString.replace( results[1].first - labelString.begin(), results[1].second - results[1].first, "" ); } regex_search( labelString, results, defaultActionRegex ); std::string defaultEnterAction( results[1].first, results[1].second ); if ( defaultEnterAction != "" && std::string( udmState.EnterAction() ) == "" ) { udmState.EnterAction() = defaultEnterAction; } udmState.Decomposition() = MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Type" ) + "_STATE"; }
void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) { _fout << std::endl; _fout << "o " << getUniqueName( geo->getName().empty() ? geo->className() : geo->getName() ) << std::endl; if (geo->containsDeprecatedData()) geo->fixDeprecatedData(); processStateSet(_currentStateSet.get()); processArray("v", geo->getVertexArray(), m, false); processArray("vn", geo->getNormalArray(), m, true); processArray("vt", geo->getTexCoordArray(0)); // we support only tex-unit 0 unsigned int normalIndex = 0; for(unsigned int i = 0; i < geo->getNumPrimitiveSets(); ++i) { osg::PrimitiveSet* ps = geo->getPrimitiveSet(i); ObjPrimitiveIndexWriter pif(_fout, geo, normalIndex, _lastVertexIndex, _lastNormalIndex, _lastTexIndex); ps->accept(pif); if(geo->getNormalArray() && geo->getNormalArray()->getBinding() == osg::Array::BIND_PER_PRIMITIVE_SET) ++normalIndex; } if (geo->getVertexArray()) _lastVertexIndex += geo->getVertexArray()->getNumElements(); if (geo->getNormalArray()) _lastNormalIndex += geo->getNormalArray()->getNumElements(); if(geo->getTexCoordArray(0)) _lastTexIndex += geo->getTexCoordArray(0)->getNumElements(); }
void LTreeViewItem::paintItem( Graphics& g, int width, int height ) { if (hasCallback("paintItem")) { LGraphics lg(LUA::Get(), g); if ( callback("paintItem", 1, { new LRefBase("Graphics", &lg), width, height }) ) { if ( ! lua_isnoneornil(LUA::Get(), -1) ) { String name = LUA::checkAndGetString(-1, String::empty); if (TreeViewItem::isSelected()) g.fillAll( Colours::blue.withAlpha( 0.3f )); g.setColour(Colours::black); g.setFont(height * 0.7f); g.drawText( name, 4, 0, width - 4, height, Justification::centredLeft, true ); } else if(lua_isnil(LUA::Get(), -1)) lua_pop(LUA::Get(), 1); } else { std::cout << "failed to execute painItem callback: " << LUA::getError() << std::endl; } } else if ( ! hasCallback("paintItem") && ! hasCallback("createItemComponent") ) { if (TreeViewItem::isSelected()) g.fillAll( Colours::blue.withAlpha( 0.3f )); g.setColour(Colours::black); g.setFont(height * 0.7f); g.drawText( getUniqueName(), 4, 0, width - 4, height, Justification::centredLeft, true ); } }
void Work::reset() { CLOG(DEBUG, "Work") << "resetting " << getUniqueName(); setState(WORK_PENDING); onReset(); }
string CLUserDefMethod::getDeserialMethod(CLAbstractType * v_elementType ,string base_ptr ) { string t_strOff = to_string((long long )v_elementType->getOff()); CLUserDefType * t_ud = dynamic_cast<CLUserDefType *>(v_elementType); string uniqueName = getUniqueName(); string ret = t_ud->getUserDefName()+"deserializer "+uniqueName+";\n\t"; if(v_elementType->getPtrFlag()&&v_elementType->getArrFlag()) { } else if(v_elementType->getArrFlag() ) { } else if(v_elementType->getPtrFlag()) { ret += "*((long *)(&"+base_ptr+"["+t_strOff+"])) = (long )new "+t_ud->getUserDefName()+";"; ret += uniqueName+".paddingObj(&in[m_buf_pos],(char *)*(long *)&("+base_ptr+"["+t_strOff+"]),&m_buf_pos);\n\t"; } else { ret += uniqueName+".paddingObj(&in[m_buf_pos],(char *)&("+base_ptr+"["+t_strOff+"]),&m_buf_pos);\n\t"; } return ret; }
string CLUserDefMethod::getSize(CLAbstractType * v_elementType ,string base_ptr ) { string t_strOff = to_string((long long )v_elementType->getOff()); CLUserDefType * t_ud = dynamic_cast<CLUserDefType *>(v_elementType); string uniqueName = getUniqueName(); string ret = t_ud->getUserDefName()+"serializer "+uniqueName+"(NULL);\n\t"; if(v_elementType->getPtrFlag()&&v_elementType->getArrFlag()) { } else if(v_elementType->getArrFlag() ) { } else if(v_elementType->getPtrFlag()) { ret += "bufsize +="+uniqueName+".countBufSize((char *)*((long *)(&"+base_ptr+"["+t_strOff+"])));\n\t"; } else { ret += "bufsize +="+uniqueName+".countBufSize((char *)(&"+base_ptr+"["+t_strOff+"]));\n\t"; } return ret; }
BufferQueueCoreBF::BufferQueueCoreBF(const sp<IGraphicBufferAlloc>& allocator) : mAllocator(allocator), mMutex(), mIsAbandoned(false), mConsumerControlledByApp(false), mConsumerName(getUniqueName()), mConsumerListener(), mConsumerUsageBits(0), mConnectedApi(NO_CONNECTED_API), mConnectedProducerListener(), mSlots(), mQueue(), mOverrideMaxBufferCount(0), mDequeueCondition(), mUseAsyncBuffer(true), mDequeueBufferCannotBlock(false), mDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888), mDefaultWidth(1), mDefaultHeight(1), mDefaultMaxBufferCount(2), mMaxAcquiredBufferCount(1), mBufferHasBeenQueued(false), mFrameCounter(0), mTransformHint(0), mIsAllocating(false), mIsAllocatingCondition() { if (allocator == NULL) { sp<ISurfaceComposer> composer(ComposerService::getComposerService()); mAllocator = composer->createGraphicBufferAlloc(); if (mAllocator == NULL) { BQ_LOGE("createGraphicBufferAlloc failed"); } } }
void MatLabUdmEvent::setupEvent( void ) { Event event = getUdmEvent(); event.Description() = MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Description" ).c_str(); event.Name() = event.name() = getUniqueName().c_str(); event.RefId() = getRefId(); std::string eventScope = MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Scope" ); std::transform( eventScope.begin(), eventScope.end(), eventScope.begin(), ToUpper() ); event.Scope() = ( eventScope + "_EVENT" ).c_str(); int port = MatLabEngine::globalEngine().getMxIntValue( getMatLabObject() + ".Port" ); event.Port() = port > 0 ? port : -1; static std::string funcTestString( "FUNCTION" ); std::string eventTrigger = MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Trigger" ); std::transform( eventTrigger.begin(), eventTrigger.end(), eventTrigger.begin(), ToUpper() ); event.Trigger() = eventTrigger.compare( 0, funcTestString.size(), funcTestString ) == 0 ? "FUNCTION_CALL_EVENT" : ( eventTrigger + "_EDGE_EVENT" ).c_str(); SLSF::TypeBaseRef typeBaseRef = SLSF::TypeBaseRef::Create( event ); SLSF::Matrix ESMoLMatrix = SLSF::Matrix::Create( UdmEngine::getUdmTypesRoot() ); ESMoLMatrix.Type() = "boolean"; ESMoLMatrix.rows() = 1; ESMoLMatrix.columns() = 1; UdmEngine::integrateTypeBase( ESMoLMatrix ); typeBaseRef.ref() = ESMoLMatrix; typeBaseRef.name() = ESMoLMatrix.name(); }
void PageItem_NoteFrame::insertNote(TextNote *note) { Mark* mrk = note->noteMark(); if (mrk == NULL) { mrk = m_Doc->newMark(); mrk->setType(MARKNoteFrameType); QString label = "NoteFrameMark_" + notesStyle()->name(); if (notesStyle()->range() == NSRsection) label += " in section " + m_Doc->getSectionNameForPageIndex(note->masterMark()->OwnPage) + " page " + QString::number(note->masterMark()->OwnPage +1); else if (notesStyle()->range() == NSRpage) label += " on page " + QString::number(note->masterMark()->OwnPage +1); else if (notesStyle()->range() == NSRstory) label += " in " + note->masterMark()->getItemPtr()->firstInChain()->itemName(); else if (notesStyle()->range() == NSRframe) label += " in frame " + note->masterMark()->getItemName(); mrk->label = label + "_" + note->numString(); mrk->setNotePtr(note); getUniqueName(mrk->label, m_Doc->marksLabelsList(MARKNoteFrameType), "_"); note->setNoteMark(mrk); } mrk->setItemPtr(this); mrk->setString(notesStyle()->prefix() + note->numString() + note->notesStyle()->suffix()); StoryText story; if (!note->saxedText().isEmpty()) story = desaxeString(m_Doc, note->saxedText()); story.insertMark(mrk, 0); story.setDefaultStyle(itemText.defaultStyle()); // story.applyCharStyle(0, story.length(), itemText.charStyle()); if (itemText.length() > 0) itemText.insertChars(itemText.length(), SpecialChars::PARSEP); itemText.insert(itemText.length(), story); }
EGS_Object::EGS_Object(const string &Name, EGS_ObjectFactory *f) : name(Name), otype("EGS_Object"), nref(0), factory(f) { object_count++; if (!name.size()) { name = getUniqueName(this); } //if( factory ) factory->addObject(this); }
int LTreeViewItem::getUniqueName ( lua_State* L ) { if ( lua_type(L, 2) == LUA_TFUNCTION ) { set("getUniqueName"); return 0; } else return LUA::returnString( getUniqueName() ); }
void Work::notifyParent() { auto parent = mParent.lock(); if (parent) { parent->notify(getUniqueName()); } }
void Work::setState(Work::State st) { auto maxR = getMaxRetries(); if (st == WORK_FAILURE_RETRY && (mRetries >= maxR)) { CLOG(WARNING, "Work") << "Reached retry limit " << maxR << " for " << getUniqueName(); st = WORK_FAILURE_RAISE; } if (st != mState) { CLOG(DEBUG, "Work") << "work " << getUniqueName() << " : " << stateName(mState) << " -> " << stateName(st); mState = st; } }
void EGS_Object::setName(EGS_Input *input) { int err = 1; if (input) { err = input->getInput("name",name); } if (err) { name = getUniqueName(this); } }
const String TreeViewItem::getItemIdentifierString() const { String s; if (parentItem != 0) s = parentItem->getItemIdentifierString(); return s + "/" + getUniqueName().replaceCharacter ('/', '\\'); }
void Work::scheduleRetry() { if (mScheduled) { return; } if (getState() != WORK_FAILURE_RETRY) { std::string msg = fmt::format("retrying {} in state {}", getUniqueName(), stateName(getState())); CLOG(ERROR, "Work") << msg; throw std::runtime_error(msg); } if (!mRetryTimer) { mRetryTimer = std::make_unique<VirtualTimer>(mApp.getClock()); } std::weak_ptr<Work> weak( std::static_pointer_cast<Work>(shared_from_this())); auto t = getRetryDelay(); mRetryTimer->expires_from_now(t); CLOG(WARNING, "Work") << "Scheduling retry #" << (mRetries + 1) << "/" << mMaxRetries << " in " << std::chrono::duration_cast<std::chrono::seconds>(t).count() << " sec, for " << getUniqueName(); mScheduled = true; mRetryTimer->async_wait( [weak]() { auto self = weak.lock(); if (!self) { return; } self->mScheduled = false; self->mRetries++; self->reset(); self->advance(); }, VirtualTimer::onFailureNoop); }
void MatLabUdmFunction::setupFunction( void ) { State udmFunction = getUdmFunction(); udmFunction.Name() = udmFunction.name() = getUniqueName().c_str(); udmFunction.Decomposition() = "FUNC_STATE"; udmFunction.Order() = "-1"; udmFunction.RefId() = getRefId(); udmFunction.EnterAction() = RegexCommon::eliminateContinuations( MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".LabelString" ) ); }
BucketDownloadWork::BucketDownloadWork(Application& app, WorkParent& parent, std::string const& uniqueName, HistoryArchiveState const& localState, size_t maxRetries) : Work(app, parent, uniqueName, maxRetries) , mLocalState(localState) , mDownloadDir( make_unique<TmpDir>(mApp.getTmpDirManager().tmpDir(getUniqueName()))) { }
void ProxyDlg::proxy_new() { ProxyItem s; s.id = ""; // id of "" means 'new' s.name = getUniqueName(); d->list += s; lbx_proxy->insertItem(s.name); lbx_proxy->setCurrentItem(lbx_proxy->count()-1); selectCurrent(); }
Fixture::Fixture(string name, int startAddress): mName(getUniqueName(name)), mFixedAddress(startAddress != 0) { mDmxGroup.setup("DMX"); mDmxGroup.add(mDmxStartAddress.set("Start addr", startAddress, 0, 512)); mDmxGroup.add(mNumChannels.set("Num chans", 0, 1, 32)); mDmxGroup.add(mDmxUniverse.set("U", "-")); auto panel = getPanel(); mPanel->add(&mDmxGroup); }
BufferQueueCore::BufferQueueCore() : mMutex(), mIsAbandoned(false), mConsumerControlledByApp(false), mConsumerName(getUniqueName()), mConsumerListener(), mConsumerUsageBits(0), mConsumerIsProtected(false), mConnectedApi(NO_CONNECTED_API), mLinkedToDeath(), mConnectedProducerListener(), mSlots(), mQueue(), mFreeSlots(), mFreeBuffers(), mUnusedSlots(), mActiveBuffers(), mDequeueCondition(), mDequeueBufferCannotBlock(false), mDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888), mDefaultWidth(1), mDefaultHeight(1), mDefaultBufferDataSpace(HAL_DATASPACE_UNKNOWN), mMaxBufferCount(BufferQueueDefs::NUM_BUFFER_SLOTS), mMaxAcquiredBufferCount(1), mMaxDequeuedBufferCount(1), mBufferHasBeenQueued(false), mFrameCounter(0), mTransformHint(0), mIsAllocating(false), mIsAllocatingCondition(), mAllowAllocation(true), mBufferAge(0), mGenerationNumber(0), mAsyncMode(false), mSharedBufferMode(false), mAutoRefresh(false), mSharedBufferSlot(INVALID_BUFFER_SLOT), mSharedBufferCache(Rect::INVALID_RECT, 0, NATIVE_WINDOW_SCALING_MODE_FREEZE, HAL_DATASPACE_UNKNOWN), mLastQueuedSlot(INVALID_BUFFER_SLOT), mUniqueId(getUniqueId()) { int numStartingBuffers = getMaxBufferCountLocked(); for (int s = 0; s < numStartingBuffers; s++) { mFreeSlots.insert(s); } for (int s = numStartingBuffers; s < BufferQueueDefs::NUM_BUFFER_SLOTS; s++) { mUnusedSlots.push_front(s); } }
std::string Work::getStatus() const { switch (mState) { case WORK_PENDING: { size_t i = 0; for (auto const& c : mChildren) { if (c.second->isDone()) { ++i; } } auto total = mChildren.size(); return fmt::format("Awaiting {:d}/{:d} prerequisites of: {:s}", total - i, total, getUniqueName()); } case WORK_RUNNING: return fmt::format("Running: {:s}", getUniqueName()); case WORK_SUCCESS: return fmt::format("Succeded: {:s}", getUniqueName()); case WORK_FAILURE_RETRY: { auto eta = getRetryETA(); return fmt::format("Retrying in {:d} sec: {:s}", eta, getUniqueName()); } case WORK_FAILURE_RAISE: case WORK_FAILURE_FATAL: return fmt::format("Failed: {:s}", getUniqueName()); default: assert(false); return ""; } }
void MatLabUdmEMFunction::setupEMFunction( void ) { State udmEMFunction = getUdmEMFunction(); udmEMFunction.Name() = udmEMFunction.name() = getUniqueName().c_str(); udmEMFunction.RefId() = getRefId(); udmEMFunction.Decomposition() = "FUNC_STATE"; udmEMFunction.Order() = "-2"; udmEMFunction.EnterAction() = RegexCommon::eliminateContinuations( MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".LabelString" ) ); std::string functionBody = RegexCommon::eliminateContinuations( MatLabEngine::globalEngine().getMxStringValue( getMatLabObject() + ".Script" ) ); functionBody = boost::regex_replace( functionBody, RegexCommon::getFunctionHeaderRegex(), "" ); udmEMFunction.DuringAction() = functionBody; }