long Light::update (void) { if (!getFlag(OBJECT_FLAG_DONE)) { //---------------------------------- //-- Always force position altitude 'cause set every frame. position.z += ((LightTypePtr)getObjectType())->altitudeOffset; setPosition(position); if (getFlag(OBJECT_FLAG_JUSTCREATED)) { setFlag(OBJECT_FLAG_JUSTCREATED, false); setFlag(OBJECT_FLAG_TANGIBLE, false); } #ifdef USE_LIGHT_APPEARANCE //----------------------------------------- // Light is NEVER Done. Unless its done! bool inView = onScreen(); lightAppearance->setInView(inView); long result = lightAppearance->update(); if (!result && ((LightTypePtr)getObjectType())->oneShotFlag) setFlag(OBJECT_FLAG_DONE, true); #endif } return (true); }
void TableWidget::removeObject(int row) { Table *table=nullptr; BaseObject *object=nullptr; ObjectType obj_type=BASE_OBJECT; try { table=dynamic_cast<Table *>(this->object); obj_type=getObjectType(sender()); object=table->getObject(row, obj_type); if(!object->isProtected() && !dynamic_cast<TableObject *>(object)->isAddedByRelationship()) { op_list->registerObject(object, Operation::OBJECT_REMOVED, row, this->object); table->removeObject(object); } else throw Exception(Exception::getErrorMessage(ERR_REM_PROTECTED_OBJECT) .arg(Utf8String::create(object->getName())) .arg(object->getTypeName()), ERR_REM_PROTECTED_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__); } catch(Exception &e) { listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void TableWidget::TableWidget::swapObjects(int idx1, int idx2) { ObjectType obj_type=BASE_OBJECT; Table *table=nullptr; int count; try { obj_type=getObjectType(sender()); table=dynamic_cast<Table *>(this->object); count=table->getObjectCount(obj_type); if(idx1 >= count) //Special case 1: the object was moved to the first row, its index is swapped with index 0 op_list->updateObjectIndex(table->getObject(idx2, obj_type), 0); else if(idx2 >= count) //Special case 2: the object was moved to the last row, its index is swapped with index count-1 op_list->updateObjectIndex(table->getObject(idx1, obj_type), count-1); else { op_list->updateObjectIndex(table->getObject(idx1, obj_type), idx2); op_list->updateObjectIndex(table->getObject(idx2, obj_type), idx1); } table->swapObjectsIndexes(obj_type, idx1, idx2); } catch(Exception &e) { listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
QSharedPointer<SyncObject> DatabaseSync<SO>::syncEntries() { qDebug() << "Running sync for type: " + getType(); // make sure root groups are the same.It has to be if we are syncing the same // database Q_ASSERT(db1->rootGroup()->uuid() == db2->rootGroup()->uuid()); entries1 = getEntriesMap(db1); entries2 = getEntriesMap(db2); QList<SO *> missingEntries; Q_FOREACH(SO * cloudEntry, entries2) { if (!processEntry(db2, cloudEntry)) continue; // remote entry also exists in local database if (entries1.contains(cloudEntry->uuid())) { SO *localEntry = entries1[cloudEntry->uuid()]; syncEntry(localEntry, cloudEntry); syncLocation(localEntry, cloudEntry); } // entry exists only in remote database else { missingEntries.append(cloudEntry); } } if (missingEntries.length() > 0) addMissingEntries(missingEntries); // count whether any unique entry exist in local database // to further decide whether we need to update remote db Q_FOREACH(SO * localEntry, entries1) { if (!processEntry(db1, localEntry)) continue; if (!entries2.contains(localEntry->uuid())) { bool isRemoved = Tools::hasChild(db1->metadata()->recycleBin(), localEntry); if (isRemoved) { // entry should be created and removed to recycle bin in remote database getSyncObject()->increase(getObjectType(), SRemoved(), SRemote()); } else { // entry is missing in remote database getSyncObject()->increase(getObjectType(), SMissing(), SRemote()); } } } return DatabaseSync::syncObject; }
bool IdlInterpreterManager::isKindOf(const std::string& className) const { if (className == getObjectType()) { return true; } return SubjectImp::isKindOf(className); }
bool SignatureFileDescriptorAdapter::isKindOf(const std::string& className) const { if ((className == getObjectType()) || (className == "SignatureFileDescriptor")) { return true; } return SignatureFileDescriptorImp::isKindOf(className); }
bool SpectralLibraryManager::isKindOf(const std::string& className) const { if (className == getObjectType()) { return true; } return SubjectAdapter::isKindOf(className); }
//------------------------------------------------------------------------------ std::string Entity::toString() const { std::stringstream ss; if (m_name.empty()) ss << "[unnamed_entity " << getObjectType().getName() << "]"; else ss << m_name; return ss.str(); }
bool GeoreferenceDescriptorAdapter::isKindOf(const std::string& className) const { if ((className == getObjectType()) || (className == "GeoreferenceDescriptor")) { return true; } return GeoreferenceDescriptorImp::isKindOf(className); }
bool UnitsAdapter::isKindOf(const std::string& className) const { if ((className == getObjectType()) || (className == "Units")) { return true; } return UnitsImp::isKindOf(className); }
bool IdlProxy::isKindOf(const std::string& className) const { if (className == getObjectType()) { return true; } return SubjectImp::isKindOf(className); }
void GroupsSync::updateEntryData(Group *entry, Group *newData) { qDebug() << "Updating the " + getType() + " data"; Q_ASSERT(entry); Q_ASSERT(newData); entry->copyDataFrom(newData); entry->setTimeInfo(newData->timeInfo()); getSyncObject()->increase(getObjectType(), SOlder(), SLocal()); }
SEM::Value GetStaticMethod(Context& context, SEM::Value rawValue, const String& methodName, const Debug::SourceLocation& location) { auto value = derefOrBindValue(context, std::move(rawValue)); assert(value.type()->isRef() && value.type()->isBuiltInReference()); assert(value.type()->refTarget()->isStaticRef()); const auto targetType = value.type()->refTarget()->staticRefTarget()->resolveAliases(); if (!targetType->isObjectOrTemplateVar()) { throw ErrorException(makeString("Cannot get static method '%s' for non-object type '%s' at position %s.", methodName.c_str(), targetType->toString().c_str(), location.toString().c_str())); } const auto methodSet = getTypeMethodSet(context, targetType); const auto canonicalMethodName = CanonicalizeMethodName(methodName); const auto methodIterator = methodSet->find(canonicalMethodName); if (methodIterator == methodSet->end()) { throw ErrorException(makeString("Cannot find static method '%s' for type '%s' at position %s.", methodName.c_str(), targetType->toString().c_str(), location.toString().c_str())); } const auto& methodElement = methodIterator->second; if (!methodElement.isStatic()) { throw ErrorException(makeString("Cannot call non-static method '%s' for type '%s' at position %s.", methodName.c_str(), targetType->toString().c_str(), location.toString().c_str())); } if (targetType->isObject()) { // Get the actual function so we can refer to it. const auto& function = targetType->getObjectType()->functions().at(canonicalMethodName); const auto functionTypeTemplateMap = targetType->generateTemplateVarMap(); const auto functionType = simplifyFunctionType(context, function->type().substitute(functionTypeTemplateMap)); const auto functionRefType = createFunctionPointerType(context, functionType); auto functionRef = addDebugInfo(SEM::Value::FunctionRef(targetType, function.get(), {}, functionRefType), location); if (targetType->isInterface()) { const auto interfaceMethodType = createStaticInterfaceMethodType(context, functionType); return addDebugInfo(SEM::Value::StaticInterfaceMethodObject(std::move(functionRef), std::move(value), interfaceMethodType), location); } else { return functionRef; } } else { const bool isTemplated = true; const auto functionType = createFunctionPointerType(context, methodElement.createFunctionType(isTemplated)); return addDebugInfo(SEM::Value::TemplateFunctionRef(targetType, methodName, functionType), location); } }
/*virtual*/ std::string CCopasiObject::getObjectDisplayName(bool regular /*=true*/, bool richtext /*=false*/) const { std::string ret = ""; if (mpObjectParent) { ret = mpObjectParent->getObjectDisplayName(regular, richtext); if (ret == "(CN)Root" || ret == "ModelList[]" || ret.substr(0, 7) == "(Model)") { ret = ""; } } if (ret.length() >= 2) if ((ret.substr(ret.length() - 2) == "[]") && (!isReference())) { ret.insert(ret.length() - 1, getObjectName()); if (isNameVector() || isVector() || getObjectType() == "ParameterGroup") ret += "[]"; return ret; } if ((ret.length() != 0) && (ret[ret.length() - 1] != '.')) ret += "."; if (isNameVector() || isVector() || getObjectType() == "ParameterGroup") ret += getObjectName() + "[]"; else if (isReference() || getObjectType() == "Parameter" || getObjectType() == getObjectName()) ret += getObjectName(); else ret += "(" + getObjectType() + ")" + getObjectName(); return ret; }
void DatabaseSync<SO>::updateEntryGroup(SO *entry, SO *new_data) { qDebug() << "Updating parent group"; Q_ASSERT(entry); Q_ASSERT(new_data); Q_ASSERT(getParentGroup(new_data)); Group *targetGroup = db1->resolveGroup(getParentGroup(new_data)->uuid()); Q_ASSERT(targetGroup); setParentGroup(entry, targetGroup); entry->setTimeInfo(new_data->timeInfo()); getSyncObject()->increase(getObjectType(), SOlder(), SLocal()); }
void TableWidget::removeObjects(void) { Table *table=nullptr; unsigned count, op_count=0, i; BaseObject *object=nullptr; ObjectType obj_type=BASE_OBJECT; try { table=dynamic_cast<Table *>(this->object); obj_type=getObjectType(sender()); count=table->getObjectCount(obj_type); op_count=op_list->getCurrentSize(); for(i=0; i < count; i++) { object=table->getObject(0, obj_type); if(!object->isProtected() && !dynamic_cast<TableObject *>(object)->isAddedByRelationship()) { op_list->registerObject(object, Operation::OBJECT_REMOVED, 0, this->object); table->removeObject(object); } else throw Exception(Exception::getErrorMessage(ERR_REM_PROTECTED_OBJECT) .arg(Utf8String::create(object->getName())) .arg(object->getTypeName()), ERR_REM_PROTECTED_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__); } } catch(Exception &e) { if(op_count < op_list->getCurrentSize()) { count=op_list->getCurrentSize()-op_count; op_list->ignoreOperationChain(true); for(i=0; i < count; i++) { op_list->undoOperation(); op_list->removeLastOperation(); } op_list->ignoreOperationChain(false); } listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void Object::unrealize() { if (val) { ValueObjectStreamOut stream; encodeStream(stream); if (stream.empty()) printf("TODO unrealize object %s\n", gObjectTypeNames[getObjectType()]); else stream.toValue(*val); } }
void readDTIcons(void) { FILE *fp; AppRec app; char *name, *directory, *fname, *icon, *push_action, *drop_action, *xp, *yp; char s[MAXAPPSTRINGLEN]; int i, p, x, y; XtAppAddActions(app_context, icon_actions, XtNumber(icon_actions)); trans = XtParseTranslationTable(icon_translations); dticons_blocked = False; if (stat(resources.dticon_file, &dticons_stats) || !(fp = fopen(resources.dticon_file, "r"))) { dticons_readable = False; error(getAnyShell(), "Cannot read desktop icons from", resources.dticon_file); return; } dticons_readable = True; for (i=0; (p = parseIcon(fp, &name, &directory, &fname, &icon, &push_action, &drop_action, &xp, &yp)) > 0; i++) { dtIcons = (DTIconRec **) XTREALLOC(dtIcons, (i+1) * sizeof(DTIconRec *)); app.name = XtNewString(strparse(s, name, "\\:")); app.directory = XtNewString(strparse(s, directory, "\\:")); app.fname = XtNewString(strparse(s, fname, "\\:")); app.icon = XtNewString(strparse(s, icon, "\\:")); app.push_action = XtNewString(strparse(s, push_action, "\\:")); app.drop_action = XtNewString(strparse(s, drop_action, "\\:")); app.objType = getObjectType(app.push_action); app.remove_file = False; if ((x = atoi(strparse(s, xp, "\\:"))) < 0) x += winInfo.rootWidth - DTICONWIDTH; if ((y = atoi(strparse(s, yp, "\\:"))) < 0) y += winInfo.rootHeight - DTICONHEIGHT; dtIcons[i] = createDTIcon(getAnyShell(), &app, x, y); dtIcons[i]->save = True; displayDTIcon(dtIcons[i]); } if (p == -1) error(getAnyShell(), "Error reading desktop icons from", resources.dticon_file); n_dtIcons = i; if (fclose(fp)) sysError(getAnyShell(), "Error reading desktop icons:"); }
void Field::exec() { startTurn(); if (isDestroyed()) return; if (getObjectType()->isPermanent()) return; duration--; assert(duration >= 0); if (duration == 0) destroy(); }
void ControllerComponent::MoveRight(GridMap * currMap) { auto infoC = this->getParent()->getComponent<InformationComponent>(); if (infoC) { infoC->setRotation(Vector3(0.f, 0.f, 0.f)); float indexX = infoC->getPosition().x / (currMap->getMapWidth() * currMap->getTileSize()) * currMap->getMapWidth(); float indexY = infoC->getPosition().y / (currMap->getMapHeight() * currMap->getTileSize()) * currMap->getMapHeight(); int playerIndexX = (int)indexX; int playerIndexY = currMap->getMapHeight() - (int)indexY; if (((int)indexX + 1) < currMap->getMapWidth()) { if (currMap->getGridMap()[playerIndexY][playerIndexX + 1]->getTileID() == Grid::TILE_FLOOR) { if (currMap->getGridMap()[playerIndexY][playerIndexX + 1]->getGridEntity() != NULL) { auto gridObject = dynamic_cast<EntityGridObject*>(currMap->getGridMap()[playerIndexY][playerIndexX + 1]->getGridEntity()); if (gridObject) { if (currMap->PushObjects(playerIndexX, playerIndexY, GridMap::DIRECTION_RIGHT, gridObject->getObjectType(), this->getParent())) { //currMap->getGridMap()[playerIndexY][playerIndexX]->removeEntity(); this->m_sMovement = MovementUpdate( playerIndexX, playerIndexY, GridMap::DIRECTION_RIGHT, currMap->getGridMap()[playerIndexY][playerIndexX + 1]->getGridPos(), true ); } } } else { //currMap->getGridMap()[playerIndexY][playerIndexX]->removeEntity(); this->m_sMovement = MovementUpdate( playerIndexX, playerIndexY, GridMap::DIRECTION_RIGHT, currMap->getGridMap()[playerIndexY][playerIndexX + 1]->getGridPos(), true ); } } } } m_dMoveDelay = 0.0; }
bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlString) { exml::Document doc; if (doc.parse(_composerXmlString) == false) { EWOL_ERROR(" can not load file XML string..."); return false; } exml::Element* root = (exml::Element*)doc.getNamed("composer"); if (root == nullptr) { // Maybe a multiple node XML for internal config: root = doc.toElement(); if (root == nullptr) { EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: \"composer\" ..."); return false; } if (root->size() == 0) { EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) no node in the Container XML element."); return false; } } // call upper class to parse his elements ... ewol::widget::Container::loadXML(root); requestUpdateSize(); return true; }
void DatabaseSync<SO>::syncLocation(SO *localEntry, SO *cloudEntry) { // entry location was changed - to another group or recycle bin. It // changes independently from lastModificationTime // updating only in a case // if remote entry has newer location change timestamp if (localEntry->timeInfo().locationChanged().toTime_t() < cloudEntry->timeInfo().locationChanged().toTime_t()) { bool isRemoved = Tools::hasChild(db2->metadata()->recycleBin(), cloudEntry); // entry was moved to normal group if (!isRemoved) updateEntryGroup(localEntry, cloudEntry); // entry was moved to recycle bin which is also group else removeEntry(localEntry); } // Case when local entry location is newer than remote entry location // we need to just count such changes to decide further whether whole remote // database should be updated else if (localEntry->timeInfo().locationChanged().toTime_t() > cloudEntry->timeInfo().locationChanged().toTime_t()) { bool isRemoved = Tools::hasChild(db1->metadata()->recycleBin(), localEntry); // entry was moved to normal group if (!isRemoved) getSyncObject()->increase(getObjectType(), SOlder(), SRemote()); // entry was moved to recycle bin which is also group else getSyncObject()->increase(getObjectType(), SRemoved(), SRemote()); } }
void DatabaseSync<SO>::addMissingEntries(QList<SO *> missingEntries) { // we can not check if item is really a new item because there is no way to // check locally whether it was removed w/o recycle bin if (!db1->metadata()->recycleBinEnabled()) { // TODO instead of syncing to recycle bin entries will be removed. // Show user dialog to confirm removal // Strongly recommend to the user to enable recycle bin to prevent manual // sync return; } // sort by creation time.Parent group always created before child.Sort // guaranties parents will be created before childs qSort(missingEntries.begin(), missingEntries.end(), compareByCreationTime); qDebug() << "Add missing entries of type " + getType(); Q_FOREACH(SO * entry, missingEntries) { const Group *parentGr = getParentGroup(entry); Group *group = Q_NULLPTR; QMap<Uuid, Group *> allGroups = db1->rootGroup()->groupsMapRecursive(true); if (allGroups.contains(parentGr->uuid())) group = allGroups.value(parentGr->uuid()); // handle case when missing entry should be created in recycle bin. // Could happen when entry in remote database was created and immeadiately // removed else if (db1->metadata()->recycleBin() && (db1->metadata()->recycleBin()->uuid() == parentGr->uuid())) group = db1->metadata()->recycleBin(); qDebug() << "Create new entry in the recycle bin"; Q_ASSERT(group); // creating new entry SO *newEntry = new SO(); newEntry->setUuid(entry->uuid()); newEntry->copyDataFrom(entry); setParentGroup(newEntry, group); newEntry->setTimeInfo(entry->timeInfo()); qDebug() << "Add missing " + getType() + ": " + getEntryName(newEntry) +" to group::" +group->getGroupName(); getSyncObject()->increase(getObjectType(), SMissing(), SLocal()); } }
void TableWidget::handleObject(void) { ObjectType obj_type=BASE_OBJECT; try { obj_type=getObjectType(sender()); showTableObjectForm(obj_type); listObjects(obj_type); } catch(Exception &e) { listObjects(obj_type); throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void Object::releaseObject() { if (val) { value &v = *val; if (!v["unrealize"].isUndefined()) v.call<void>("unrealize"); else { unrealize(); val->set("ptr", emscripten::val::null() ); val->set("type", (int)getObjectType() ); } delete val; } delete this; }
CEvent::CEvent(const std::string & name, const CCopasiContainer * pParent): CCopasiContainer(name, pParent, "Event"), CAnnotation(), mpModel(static_cast<CModel *>(getObjectAncestor("Model"))), mAssignments("ListOfAssignments", this), mDelayAssignment(true), mFireAtInitialTime(false), mPersistentTrigger(false), mpTriggerExpression(NULL), mpDelayExpression(NULL), mpPriorityExpression(NULL), mType(Assignment) { mKey = (CCopasiRootContainer::getKeyFactory()->add(getObjectType(), this)); initObjects(); }
jobject JPPrimitiveType::convertToJavaObject(HostRef* obj) { JPCleaner cleaner; JPTypeName tname = getObjectType(); JPClass* c = JPTypeManager::findClass(tname); jclass jc = c->getClass(); cleaner.addLocal(jc); vector<HostRef*> args(1); args[0] = obj; JPObject* o = c->newInstance(args); jobject res = o->getObject(); delete o; return res; }
void CSObject::setIdRecursive(ISceneNode* node, int id) { if (node) { // set the data node->setID(getObjectType()); node->setName(intToStringc(id)); // edited // set all the children also list<ISceneNode*> list = node->getChildren(); core::list<ISceneNode*>::Iterator Iterator; for (Iterator = list.begin(); Iterator != list.end(); ++Iterator) { setIdRecursive((*Iterator), id); } } }
void changeDTIconProc(XtPointer awp, int conf) { DTIconRec *dticon = ((AppSpecRec *) awp)->win.dticon; XTFREE(awp); dticons_blocked = False; if (conf == YES) { XtDestroyWidget(dticon->app.form); if (dticon->app.loaded) freeIcon(dticon->app.icon_pm); if (dticon->label_mask != None) freePixmap(dticon->label_mask); if (dticon->drop_pixmap != None) freePixmap(dticon->drop_pixmap); dticon->app.objType = getObjectType(dticon->app.push_action); readApplicationIcon(getAnyShell(), &dticon->app, ERR_POPUP); displayDTIcon(dticon); if (resources.auto_save) writeDTIcons(True); } }
void DatabaseSync<SO>::syncEntry(SO *localEntry, SO *cloudEntry) { // local entry last update time is older than remote entry.Updating local // database if (localEntry->timeInfo().lastModificationTime().toTime_t() < cloudEntry->timeInfo().lastModificationTime().toTime_t()) { qDebug() << QString( "Local Db has older " + getType() + " data.UUID=" +localEntry->uuid().toHex()); updateEntryData(localEntry, cloudEntry); } // we need to just count changes to decide further whether whole remote // database should be updated else if (localEntry->timeInfo().lastModificationTime().toTime_t() > cloudEntry->timeInfo().lastModificationTime().toTime_t()) { getSyncObject()->increase(getObjectType(), SOlder(), SRemote()); qDebug() << QString( "Remote DB has older " + getType() + "data.UUID=" + cloudEntry->uuid().toHex()); } }