void EntityManager::addComponent(Entity &e, Component * c) { ComponentType type = ComponentTypeManager::getTypeFor(typeid(*c)); if (type.getId() >= componentsByType.getCapacity()) { //Resize componentsByType.set(type.getId(), NULL); } Bag<Component*> * components = componentsByType.get(type.getId()); if (components == NULL) { components = new Bag<Component*>(); componentsByType.set(type.getId(), components); } else { if (components->get(e.getId()) != NULL) { // Entity already had this component, need to perform component removal first removeComponent(e, type); refresh(e); } } components->set(e.getId(), c); e.addTypeBit(type.getBit()); components = NULL; }
/* Purpose: To clear all components from the current layer * Pre: Current layer exists * List of starting positions * Stringstream from user input * Post: Displays grid on the screen * Author: Matthew James Harrison ******************************************************************************/ void clear(Layer &layer, StartingList &startingList, stringstream &ss) { int currentLayer = 0; int height = 0; int width = 0; currentLayer = layer.getCurrentLayer(); height = layer.get(currentLayer)->getHeight(); width = layer.get(currentLayer)->getWidth(); /* If no junk data */ if (!hasJunk(ss)) { /* Traverse each row */ for (int i = 0; i < height; i++) { /* Traverse each column of current row */ for (int j = 0; j < width; j++) { removeComponent(layer, startingList, j, i); } } } else { displayMessage(MSG_INV_COMMAND); } }
void MediaStreamDescriptor::removeRemoteTrack(MediaStreamComponent* component) { if (m_client) m_client->removeRemoteTrack(component); else removeComponent(component); }
Entity *Entity::addComponent(Component *component) { removeComponent(component->componentName()); component->setEntity(this); components.insert(component->componentName(), component); return this; }
/* Purpose: To remove a component according to user input * Pre: Current layer exists, * stringstream with x position and y position * Post: Removes component at given position * Author: Matthew James Harrison ******************************************************************************/ void removeComponent(Layer &layer, StartingList &startingList, stringstream &ss) { string data = ""; int xPos = -1; int yPos = -1; /* Get command data */ xPos = readNumber(ss); yPos = readNumber(ss); /* If no junk data */ if (!hasJunk(ss)) { /* If type and position are valid */ if (isPosition(layer, xPos, yPos)) { removeComponent(layer, startingList, xPos, yPos); } else { displayMessage(MSG_INV_REMOVE); } } else { displayMessage(MSG_INV_REMOVE); } }
void CtrlrPanelCanvas::deleteWithChildren(CtrlrComponent *c) { if (c) { if (getOwner().getSelection()) getOwner().getSelection()->deselectAll(); Array<CtrlrComponent*> children = c->getOwnedChildren(); for (int i=0; i<children.size(); i++) { removeComponent (children[i], false); } removeComponent (c, false); sendChangeMessage(); } }
bool DataPool::removeComponentByName(const std::string& name) { TaskContext *comp = Application::Instance()->getTask(name); if (!comp) { log(Error) << "Unknown component: " << name << endlog(); return false; } return removeComponent(comp); }
void Entity::addComponent(ComponentBase* comp) { if (this->hasComponent(comp->getId())) { removeComponent(comp->getId()); } this->hasComponentVector[(int)comp->getId()] = true; this->componentVector[(int)comp->getId()] = comp; }
GameObject::~GameObject() { pantheios::log(pantheios::debug, "GameObject ", GameObjectInserter(*(this)), " destructor"); std::set<ComponentId> keys; make_key_set(components, keys); for (std::set<ComponentId>::iterator it=keys.begin() ; it != keys.end(); it++ ) { removeComponent(*it); } }
void LoadingView::setNeedPassword(bool need_password) { if ( this->need_password != need_password ) { this->need_password = need_password; if ( need_password ) { password_field = addInputField(iXY(175+88, 80), &password_str, "", true, 31); add(okButton); add(passwordLabel); } else { removeInputField(password_field); removeComponent(okButton); removeComponent(passwordLabel); password_field = 0; } } }
void Node::deinitialize() { onDeinitialize(); // clear all children while(mChildren.size() > 0) { removeChildNode(mChildren.begin()->first); } // clear all components while(mComponents.size() > 0) { removeComponent(mComponents.begin()->second->getName()); } }
void MaterialNode::setAutoLightLevel(bool value) { if (value && !_lightLevelListener) { _lightLevelListener = construct<EventListener>(); _lightLevelListener->onEvent(ResourceManager::onLightLevel, std::bind(&MaterialNode::onLightLevel, this)); addComponent(_lightLevelListener); if (isRunning()) { onLightLevel(); } } else if (!value && _lightLevelListener) { removeComponent(_lightLevelListener); _lightLevelListener = nullptr; } }
void Transport::eventLoop(SocketEvent *socketEvent) { IOEvent events[MAX_SOCKET_EVENTS]; while (!_stop) { // 检查是否有事件发生 int cnt = socketEvent->getEvents(1000, events, MAX_SOCKET_EVENTS); if (cnt < 0) { if(errno == EINTR)continue; SYS_LOG(INFO, "得到events出错了: %s(%d)\n", strerror(errno), errno); } for (int i = 0; i < cnt; i++) { IOComponent *ioc = events[i]._ioc; if (ioc == NULL) { continue; } if (events[i]._errorOccurred) { // 错误发生了 removeComponent(ioc); continue; } ioc->addRef(); // 读写 bool rc = true; if (events[i]._readOccurred) { rc = ioc->handleReadEvent(); } if (rc && events[i]._writeOccurred) { rc = ioc->handleWriteEvent(); } ioc->subRef(); if (!rc) { removeComponent(ioc); } } } }
// TODO: remove asserts void metricInstance::dataDisable() { assert(!users.size()); assert(!global_users.size()); pdvector<component *>::iterator iter = components.end(); while(iter != components.begin()) { iter--; removeComponent(*iter); components.erase(iter); } enabled = false; assert(components.size()==0); }
void ComponentDock::actRemove(Kite::KHandle CHandle) { //auto obj = (Expander *)sender(); auto ent = eman->getEntity(currEntity); auto cptr = ent->getComponentByHandle(CHandle); if (cptr->getDepCounter() > 0) { QMessageBox msg; msg.setWindowTitle("Message"); msg.setText("some components required this component. remove them first!"); msg.exec(); return; } ent->removeComponent((Kite::CTypes) CHandle.type, cptr->getName()); eman->postWork(); }
bool GameObject::deleteComponent(const std::string &componentName) { bool wasDeleted = false; GameObjectComponent *comp = removeComponent(componentName); if (comp) { comp->onDelete(); delete comp; wasDeleted = true; } return wasDeleted; }
// remove the component correspondent to daemon // If there are no more components, flush aggregate samples, // and notify clients. void metricInstance::removeComponent(paradynDaemon *daemon) { int lastIndex = static_cast<int>(components.size())-1; sampleVal_cerr << "metricInstance::removeComponent(dmn)- daemon: " << daemon << " num of components: " << lastIndex+1 << "\n"; pdvector<component *>::iterator iter = components.end(); while(iter != components.begin()) { iter--; if ((*iter)->getDaemon() == daemon) { removeComponent(*iter); components.erase(iter); } } }
void MonsterDevil::dead() { //화살표 컴포넌트 지우고 if (m_ArrowAniComponent) { removeComponent(m_ArrowAniComponent); } //시체 만들고 auto corpse = GET_COMPONENT_MANAGER()->createComponent<Corpse>(); int roomNum = GET_STAGE_MANAGER()->getRoomNum(); GET_STAGE_MANAGER()->addObject(corpse, roomNum, getPosition(), RoomZOrder::GAME_OBJECT); //자신 없애고 removeFromParent(); }
// remove component (canvas request) bool model::Network::removeComponent(model::Component *component) { auto project = dataControl->project(); if (component) { auto name = component->name().toStdString(); bool result = project->removeComponent(name); if (!result) { auto c = project->getRootNetwork()->getComponent(name); if (!c) { return true; } else { return false; } } } return true; }
void PageFrame::componentSwitch(VariableExtendedListFrame* aComponent) { removeComponent(aComponent); disconnect(aComponent, SIGNAL(switchPressed(VariableExtendedListFrame*)), this, SLOT(componentSwitch(VariableExtendedListFrame*))); disconnect(aComponent, SIGNAL(upPressed(PageComponent*)), this, SLOT(componentUp(PageComponent*))); disconnect(aComponent, SIGNAL(downPressed(PageComponent*)), this, SLOT(componentDown(PageComponent*))); disconnect(aComponent, SIGNAL(copyPressed(PageComponent*)), this, SLOT(componentCopy(PageComponent*))); disconnect(aComponent, SIGNAL(deletePressed(PageComponent*)), this, SLOT(componentDelete(PageComponent*))); aComponent->mIsTable=false; aComponent->ui->useCheckBox->setChecked(true); aComponent->ui->useCheckBox->setVisible(false); aComponent->ui->titleLabel->setVisible(true); addVariable(aComponent); }
void Transport::processCommands() { lock(); for (vector<TransportCommand>::iterator i = _commands.begin(); i != _commands.end(); i++) { switch (i->type) { case TC_ADD_IOC: addComponent(i->ioc); break; case TC_REMOVE_IOC: removeComponent(i->ioc); break; default: break; } i->ioc->subRef(); } _commands.clear(); unlock(); }
void GameObject::fixedUpdate(float deltaTimestep) { pantheios::log(pantheios::debug, "Fixed updating Game Object ", GameObjectInserter(*(this))); std::set<ComponentId> keys; make_key_set(components, keys); for (std::set<ComponentId>::iterator it=keys.begin() ; it != keys.end(); it++ ) { IComponent* component = getComponent(*it); if(component != NULL) { FixedPhysicsUpdateComponent* fixedUpdateComponent = dynamic_cast<FixedPhysicsUpdateComponent*>(component); if(fixedUpdateComponent != NULL) { currentUpdateComponent = component; fixedUpdateComponent->fixedPhysicsUpdate(deltaTimestep); currentUpdateComponent = NULL; if(deleteAfterUpdateFinishes) { removeComponent(*it); deleteAfterUpdateFinishes = false; } } } } }
void GameObject::update() { assert(layer != NULL); pantheios::log(pantheios::debug, "Updating Game Object ", GameObjectInserter(*(this))); std::set<ComponentId> keys; make_key_set(components, keys); for (std::set<ComponentId>::iterator it=keys.begin() ; it != keys.end(); it++ ) { IComponent* component = getComponent(*it); if(component != NULL) { // if a component decides to delete itself, need to wait until it's done executing to do so currentUpdateComponent = component; component->update(); currentUpdateComponent = NULL; if(deleteAfterUpdateFinishes) { removeComponent(*it); deleteAfterUpdateFinishes = false; } } } currentUpdateComponent = NULL; }
void RenderEntity::sceneChangeEvent(const QSceneChangePtr &e) { QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e); switch (e->type()) { case ComponentAdded: { QNodePtr nodePtr = propertyChange->value().value<QNodePtr>(); QComponent *component = qobject_cast<QComponent *>(nodePtr.data()); qCDebug(Render::RenderNodes) << Q_FUNC_INFO << "Component Added" << m_objectName << component->objectName(); addComponent(component); break; } case ComponentRemoved: { QNodeId nodeId = propertyChange->value().value<QNodeId>(); qCDebug(Render::RenderNodes) << Q_FUNC_INFO << "Component Removed"; removeComponent(nodeId); break; } default: break; } }
void FilePath::popComponent() { removeComponent(-1); }
bool UrlParser::removeQueryParam( const UrlComponent::Matcher &matcher, const UrlComponent::Validator &validator ) { return removeComponent( matchQueryParam( matcher ), validator ); }
bool UrlParser::removeQueryParam( const std::vector<UrlComponent*> &urlComponents, const UrlComponent::Validator &validator ) { return removeComponent( urlComponents, validator ); }
bool UrlParser::removePathParam( const UrlComponent::Matcher &matcher, const UrlComponent::Validator &validator ) { std::vector<UrlComponent*> matches = matchPathParam( matcher ); return removeComponent( matches, validator ); }
OMX_ERRORTYPE Exynos_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent) { OMX_ERRORTYPE ret = OMX_ErrorNone; EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; EXYNOS_OMX_RM_COMPONENT_LIST *pRMComponentList = NULL; EXYNOS_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL; EXYNOS_OMX_RM_COMPONENT_LIST *pComponentCandidate = NULL; int numElem = 0; int lowCompDetect = 0; int maxResource = 0; FunctionIn(); Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex); pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; pRMComponentList = getRMList(pExynosComponent, gpRMList, &maxResource); pComponentTemp = pRMComponentList; if (pComponentTemp != NULL) { while (pComponentTemp) { numElem++; pComponentTemp = pComponentTemp->pNext; } } else { numElem = 0; } if (numElem >= maxResource) { lowCompDetect = searchLowPriority(pRMComponentList, pExynosComponent->compPriority.nGroupPriority, &pComponentCandidate); if (lowCompDetect <= 0) { ret = OMX_ErrorInsufficientResources; goto EXIT; } else { ret = removeComponent(pComponentCandidate->pOMXStandComp); if (ret != OMX_ErrorNone) { ret = OMX_ErrorInsufficientResources; goto EXIT; } else { ret = removeElementList(&pRMComponentList, pComponentCandidate->pOMXStandComp); if (ret != OMX_ErrorNone) goto EXIT; ret = addElementList(&pRMComponentList, pOMXComponent); if (ret != OMX_ErrorNone) goto EXIT; } } } else { ret = addElementList(&pRMComponentList, pOMXComponent); if (ret != OMX_ErrorNone) goto EXIT; } ret = setRMList(pExynosComponent, gpRMList, pRMComponentList); if (ret != OMX_ErrorNone) goto EXIT; ret = OMX_ErrorNone; EXIT: Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex); FunctionOut(); return ret; }
void ComponentContainer::bringComponentToFront(std::shared_ptr<GUIComponent> component) { removeComponent(component); addComponent(component); }