当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectRef类代码示例

本文整理汇总了C++中ObjectRef的典型用法代码示例。如果您正苦于以下问题:C++ ObjectRef类的具体用法?C++ ObjectRef怎么用?C++ ObjectRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: config

void DesktopConfigDbBackend::init()
{
	m_manager->reset();
	m_currentOid = 1;

	//KSimpleConfig config( m_fileName ); // DEPRECATED KDE3 -> KDE4 by Percy
    KConfig config( m_fileName );

	QStringList groups = config.groupList();
	QStringList::ConstIterator it( groups.begin() );
	QStringList::ConstIterator end( groups.end() );
	QMap<QString,QString> map;
	for ( ; it != end; ++it ) {
		map = config.entryMap( *it );
		ObjectRef<Object> obj;
		if ( map.contains( "oid" ) )
			obj = Classes::classInfo( *it )->create( stringToOid( map["oid"] ), m_manager, true );
		else
			obj = Classes::classInfo( *it )->create( m_manager );
		assert( obj );
		if ( m_currentOid < obj->oid() )
			m_currentOid = obj->oid();
		//QMapConstIterator<QString,QString> mit( map.begin() ); // DEPRECATED Qt3 -> Qt4 by Percy
		//QMapConstIterator<QString,QString> mend( map.end() ); // DEPRECATED Qt3 -> Qt4 by Percy
        QMap<QString, QString>::const_iterator mit( map.begin() );
        QMap<QString, QString>::const_iterator mend( map.end() );
		for ( ; mit != mend; ++mit ) {
			if ( mit.key() != "oid" )
				//obj->setProperty( mit.key(), mit.data() ); // DEPRECATED Qt3 -> Qt4 by Percy
                obj->setProperty( mit.key().toAscii(), QVariant(mit.value()) );
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:kandau-svn,代码行数:33,代码来源:desktopconfigdbbackend.cpp

示例2: parseMember

/*
    member = string name-separator value
*/
bool JsonParser::parseMember(ObjectRef o)
{
    BEGIN << "parseMember";
    Scope scope(context);

    QString key;
    if (!parseString(&key))
        return false;
    QChar token = nextToken();
    if (token != NameSeparator) {
        lastError = QJsonParseError::MissingNameSeparator;
        return false;
    }
    ScopedValue val(scope);
    if (!parseValue(val))
        return false;

    ScopedString s(scope, context->engine->newIdentifier(key));
    uint idx = s->asArrayIndex();
    if (idx < UINT_MAX) {
        o->putIndexed(idx, val);
    } else {
        Property *p = o->insertMember(s, Attr_Data);
        p->value = val.asReturnedValue();
    }

    END;
    return true;
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:32,代码来源:qv4jsonobject.cpp

示例3: init

void ArrayPrototype::init(ExecutionEngine *engine, ObjectRef ctor)
{
    Scope scope(engine);
    ScopedObject o(scope);
    ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
    ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
    ctor->defineDefaultProperty(QStringLiteral("isArray"), method_isArray, 1);
    defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
    defineDefaultProperty(engine->id_toString, method_toString, 0);
    defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
    defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
    defineDefaultProperty(QStringLiteral("join"), method_join, 1);
    defineDefaultProperty(QStringLiteral("pop"), method_pop, 0);
    defineDefaultProperty(QStringLiteral("push"), method_push, 1);
    defineDefaultProperty(QStringLiteral("reverse"), method_reverse, 0);
    defineDefaultProperty(QStringLiteral("shift"), method_shift, 0);
    defineDefaultProperty(QStringLiteral("slice"), method_slice, 2);
    defineDefaultProperty(QStringLiteral("sort"), method_sort, 1);
    defineDefaultProperty(QStringLiteral("splice"), method_splice, 2);
    defineDefaultProperty(QStringLiteral("unshift"), method_unshift, 1);
    defineDefaultProperty(QStringLiteral("indexOf"), method_indexOf, 1);
    defineDefaultProperty(QStringLiteral("lastIndexOf"), method_lastIndexOf, 1);
    defineDefaultProperty(QStringLiteral("every"), method_every, 1);
    defineDefaultProperty(QStringLiteral("some"), method_some, 1);
    defineDefaultProperty(QStringLiteral("forEach"), method_forEach, 1);
    defineDefaultProperty(QStringLiteral("map"), method_map, 1);
    defineDefaultProperty(QStringLiteral("filter"), method_filter, 1);
    defineDefaultProperty(QStringLiteral("reduce"), method_reduce, 1);
    defineDefaultProperty(QStringLiteral("reduceRight"), method_reduceRight, 1);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:30,代码来源:qv4arrayobject.cpp

示例4: toJsonObject

QJsonObject JsonObject::toJsonObject(ObjectRef o, V4ObjectSet &visitedObjects)
{
    QJsonObject result;
    if (!o || o->asFunctionObject())
        return result;

    Scope scope(o->engine());

    if (visitedObjects.contains(o)) {
        // Avoid recursion.
        // For compatibility with QVariant{List,Map} conversion, we return an
        // empty object (and no error is thrown).
        return result;
    }

    visitedObjects.insert(o);

    ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
    ScopedValue name(scope);
    QV4::ScopedValue val(scope);
    while (1) {
        name = it.nextPropertyNameAsString(val);
        if (name->isNull())
            break;

        QString key = name->toQStringNoThrow();
        if (!val->asFunctionObject())
            result.insert(key, toJsonValue(val, visitedObjects));
    }

    visitedObjects.remove(o);

    return result;
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:34,代码来源:qv4jsonobject.cpp

示例5: tryPlayerMove

void GameController::tryPlayerMove (Direction direction) {
    if (isFinished ()) {
        return;
    }

    Coords playerCoords = level.getObjectCoords (player);

    Coords playerDestination = playerCoords + direction;

    if (level.isValidCoord (playerDestination)) {

        if (!level.isEmpty (playerDestination)) {
            ObjectRef targetObject = level.getObject (playerDestination);

            auto interaction = targetObject->getGameClass ().interactionFunction;

            GameCommands commands (*this, targetObject);

            interaction (commands);
        } else {
            level.setObject (playerDestination, player);
            level.clear (playerCoords);
        }
    }

    displayFunction (data, level);
}
开发者ID:andrewAsdf,项目名称:treasure,代码行数:27,代码来源:GameController.cpp

示例6: renameObjects

void ComponentModelRegistry::dumpComponentGraph(ostream& os, bool display_nodeprops, bool display_linkprops)
{
    renameObjects();

    os << "# Microgrid system topology, generated by " << PACKAGE_NAME << " " << PACKAGE_VERSION << endl
       << "digraph Microgrid {" << endl
       << "overlap=\"false\"; labeljust=\"l\"; concentrate=\"true\"; splines=\"true\"; node [shape=box]; edge [len=2,constraint=\"false\"];" << endl;
    for (auto& i : m_objects)
    {
        ObjectRef objref = i.first;
        os << *m_names[objref] << " [label=\"" << *m_names[objref];
        string name = objref->GetName();
        if (name != *m_names[objref])
            os << "\\nconfig:" << name;
        if (display_nodeprops && !m_objprops[objref].empty())
        {
            for (auto& p : m_objprops[objref])
            {
                os << "\\n" << *p.first;
                if (p.second->type != Entity::VOID)
                {
                    os << ':';
                    printEntity(os, *p.second);
                }
            }
        }
        os << "\"];" << endl;
    }

    for (auto& i : m_linkprops)
    {
        auto& endpoints = i.first;
        auto& props = i.second;

        os << *m_names[endpoints.first] << " -> " << *m_names[endpoints.second.first]
           << " [constraint=\"" << (endpoints.second.second.first ? "false" : "true") << "\"";

        if (endpoints.second.second.second)
            os << ",dir=both";

        if (display_linkprops)
        {
            os << ",label=\"";
            for (auto& p : props)
            {
                os << *p.first;
                if (p.second->type != Entity::VOID)
                {
                    os << ':';
                    printEntity(os, *p.second);
                }
                os << ' ';
            }
            os << "\"";
        }
        os << "];"  << endl;
    }
    os << "}" << endl;
}
开发者ID:6366295,项目名称:mgsim,代码行数:59,代码来源:config.cpp

示例7: canWork

        bool canWork (const URIs &uris, const lvtk::Atom& atom) override
        {
            if (atom.as_object().otype() != uris.jobs_ObjectRef)
                return false;

            ObjectRef ref (uris, atom.as_object());
            return ref.has_class_type (uris.jobs_Disposable);
        }
开发者ID:kushview,项目名称:ksp1,代码行数:8,代码来源:Jobs.cpp

示例8: refBBox

	const FBox WorldViewer::refBBox(ObjectRef ref) const {
		int index = ref.index();
		if(ref.isEntity() && index >= 0 && index < (int)m_entities.size()) {
			if(m_entities[index].mode == VisEntity::shadowed)
				return m_entities[index].shadow->boundingBox();
		}

		return m_world->refBBox(ref);
	}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: JO

QString Stringify::JO(ObjectRef o)
{
    if (stack.contains(o.getPointer())) {
        ctx->throwTypeError();
        return QString();
    }

    Scope scope(ctx);

    QString result;
    stack.push(o.getPointer());
    QString stepback = indent;
    indent += gap;

    QStringList partial;
    if (propertyList.isEmpty()) {
        ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
        ScopedValue name(scope);

        ScopedValue val(scope);
        while (1) {
            name = it.nextPropertyNameAsString(val);
            if (name->isNull())
                break;
            QString key = name->toQString();
            QString member = makeMember(key, val);
            if (!member.isEmpty())
                partial += member;
        }
    } else {
        ScopedString s(scope);
        for (int i = 0; i < propertyList.size(); ++i) {
            bool exists;
            s = propertyList.at(i);
            ScopedValue v(scope, o->get(s, &exists));
            if (!exists)
                continue;
            QString member = makeMember(s->toQString(), v);
            if (!member.isEmpty())
                partial += member;
        }
    }

    if (partial.isEmpty()) {
        result = QStringLiteral("{}");
    } else if (gap.isEmpty()) {
        result = QStringLiteral("{") + partial.join(QLatin1Char(',')) + QStringLiteral("}");
    } else {
        QString separator = QStringLiteral(",\n") + indent;
        result = QStringLiteral("{\n") + indent + partial.join(separator) + QStringLiteral("\n") + stepback + QStringLiteral("}");
    }

    indent = stepback;
    stack.pop();
    return result;
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:56,代码来源:qv4jsonobject.cpp

示例10: init

void BooleanPrototype::init(ExecutionEngine *engine, ObjectRef ctor)
{
    Scope scope(engine);
    ScopedObject o(scope);
    ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
    ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
    defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
    defineDefaultProperty(engine->id_toString, method_toString);
    defineDefaultProperty(engine->id_valueOf, method_valueOf);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:qv4booleanobject.cpp

示例11: mutexSentinel

void ObjectFactory::RegisterObject(ObjectRef& objRef)
{
	MutexSentinel mutexSentinel(m_mutex);
	std::map<CStdString, ObjectRef>::iterator pair = m_classes.find(objRef->GetClassName());
	if(pair != m_classes.end())
	{
		m_classes.erase(pair);
	}
	m_classes.insert(std::make_pair(objRef->GetClassName(), objRef));
}
开发者ID:HiPiH,项目名称:Oreka,代码行数:10,代码来源:ObjectFactory.cpp

示例12: work

 void work (const URIs& uris, const lvtk::Atom& atom) override
 {
     SampleCache& cache (*getSampleCache());
     if (LayerData* data = cache.getLayerData (uris, atom.as_object(), false))
     {
         const ObjectRef ref (jobs->getWorkForge(), uris.ksp1_Layer, data);
         if (ref.get<LayerData>() != nullptr) {
             respond (ref.total_size(), ref.cobj());
         }
     }
 }
开发者ID:kushview,项目名称:ksp1,代码行数:11,代码来源:Jobs.cpp

示例13: objectTransform

// this is the trickest part in the program, because we need to output the objects in each timeline (each timeline
// describes one object), but we need to keep refering back to the mainline to see if the object is attached to any
// bones, and if so, calculate how this affects the final position of the object
// Note that we're only interested in exporting objects - not bones
std::ostream& operator<< (std::ostream& out, const Timeline& timeline) {
    
    if(!timeline.isTypeObject())
        return out;
    
    out << "\t\t[" << timeline.m_id + 1 << "] = {" << endl;
    for(vector<Object*>::const_iterator it = timeline.m_objects.begin(); it != timeline.m_objects.end(); ) {
        // For each object we have to check if it is attached to a bone. If it is, then
        // we need to recursively look up the bone's properties and calculate the values to add to the
        // object position.
        
        Object* object = *it;
        
        // search the mainline for any references to this timeline and key pair
        int mainlineKeyId;
        ObjectRef* objectRef = timeline.m_owner->findReferenceToObject(timeline.m_id, object->getId(), &mainlineKeyId);
                
        
        Transform objectTransform(object->getX(), object->getY(), object->getAngle(), object->getScaleX(), object->getScaleY());
        BoneRef* boneRef = timeline.m_owner->getBoneReference(objectRef, mainlineKeyId);
        Transform parentTransform = timeline.buildTransform(boneRef, mainlineKeyId);
        objectTransform.apply_parent_transform(parentTransform);
        
        float x = objectTransform.x;
        float y = objectTransform.y;
        int z = objectRef->getZIndex();
        float angle = objectTransform.angle;
        float scaleX = objectTransform.scale_x;
        float scaleY = objectTransform.scale_y;
                
        out << "\t\t\t[" << object->getId() + 1 << "] = {" << endl;
                    
        out << "\t\t\t\t['angle'] = " << boost::format("%.4f") % angle << "," << endl;
        out << "\t\t\t\t['texture'] = '" << timeline.m_owner->getFileName(object->getFolder(), object->getFile()) << "'," << endl;
        out << "\t\t\t\t['zindex'] = " << z << "," << endl;
        out << "\t\t\t\t['scale_x'] = " << boost::format("%.4f") % scaleX << "," << endl;
        out << "\t\t\t\t['scale_y'] = " << boost::format("%.4f") % scaleY << "," << endl;
        out << "\t\t\t\t['time'] = " << object->getTime() << "," << endl;
        out << "\t\t\t\t['x'] = " << boost::format("%.6f") % x << "," << endl;
        out << "\t\t\t\t['y'] = " << boost::format("%.6f") % y << "," << endl;
        out << "\t\t\t\t['spin'] = " << object->getSpin() << "," << endl;
        out << "\t\t\t\t['pivot_x'] = " << 0 << "," << endl;
        out << "\t\t\t\t['pivot_y'] = " << timeline.m_owner->getFile(object->getFolder(), object->getFile())->getHeight()<< endl;
        
        out << "\t\t\t}";
        if(++it != timeline.m_objects.end())
            out << ", ";
        out << endl;
    }
    out << "\t\t}";
    return out;
}
开发者ID:samuchan,项目名称:NekoPunch,代码行数:56,代码来源:timeline.cpp

示例14: testObjectBlock

void testObjectBlock (void)
{
    /*ObjectRef<int> obj;
    obj.allocate();
    *obj.get() = 18;*/

    ObjectRef<TestDummyClass> ptr;
    ptr.allocate();
    ptr.get()->i = 19;
    ptr.get()->j = 20;

    ObjectRef<TestDummyClass> ptr1 = ptr;
}
开发者ID:ArsenyChernyaev,项目名称:corecvs,代码行数:13,代码来源:main_test_buffer.cpp

示例15: getFreeParticle

std::shared_ptr<Ego::Particle> ParticleHandler::spawnParticle(const Vector3f& spawnPos, const Facing& spawnFacing, const PRO_REF spawnProfile,
                                                              const PIP_REF particleProfile, const ObjectRef spawnAttach, Uint16 vrt_offset, const TEAM_REF spawnTeam,
                                                              const ObjectRef spawnOrigin, const ParticleRef spawnParticleOrigin, const int multispawn, const ObjectRef spawnTarget, const bool onlyOverWater)
{
    const std::shared_ptr<ParticleProfile> &ppip = ProfileSystem::get().ParticleProfileSystem.get_ptr(particleProfile);

    if (!ppip)
    {
        const std::string spawnOriginName = _currentModule->getObjectHandler().exists(spawnOrigin) ? _currentModule->getObjectHandler()[spawnOrigin]->getName() : "INVALID";
        const std::string spawnProfileName = ProfileSystem::get().isValidProfileID(spawnProfile) ? ProfileSystem::get().getProfile(spawnProfile)->getPathname() : "INVALID";
		Log::get().debug("spawn_one_particle() - cannot spawn particle with invalid particle profile == %d, spawn origin == %" PRIuZ " (\"%s\"), spawn profile == %d (\"%s\"))\n",
                         REF_TO_INT(particleProfile), 
                         spawnOrigin.get(), spawnOriginName.c_str(),
                         REF_TO_INT(spawnProfile), spawnProfileName.c_str());

        return Ego::Particle::INVALID_PARTICLE;
    }

    // count all the requests for this particle type
    ppip->_spawnRequestCount++;

    //Try to get a free particle
    std::shared_ptr<Ego::Particle> particle = getFreeParticle(ppip->force);
    if(particle) {
        //Initialize particle and add it into the game
        if(particle->initialize(ParticleRef(_totalParticlesSpawned++), spawnPos, spawnFacing, spawnProfile, particleProfile, spawnAttach, vrt_offset, 
                                spawnTeam, spawnOrigin, ParticleRef(spawnParticleOrigin), multispawn, spawnTarget, onlyOverWater)) 
        {
            _pendingParticles.push_back(particle);
            _particleMap[particle->getParticleID()] = particle;
        }
        else {
            //If we failed to spawn somehow, put it back to the unused pool
            _unusedPool.push_back(particle);
        }        
    }

    if(!particle) {
        const std::string spawnOriginName = _currentModule->getObjectHandler().exists(spawnOrigin) ? _currentModule->getObjectHandler().get(spawnOrigin)->getName() : "INVALID";
        const std::string particleProfileName = LOADED_PIP(particleProfile) ? ProfileSystem::get().ParticleProfileSystem.get_ptr(particleProfile)->_name : "INVALID";
        const std::string spawnProfileName = ProfileSystem::get().isValidProfileID(spawnProfile) ? ProfileSystem::get().getProfile(spawnProfile)->getPathname().c_str() : "INVALID";
        Log::get().debug("spawn_one_particle() - cannot allocate a particle!    owner == %" PRIuZ "(\"%s\"), spawn profile == %d(\"%s\"), particle profile == %d(\"%s\")\n",
                         spawnOrigin.get(), spawnOriginName.c_str(),
                         REF_TO_INT(spawnProfile), spawnProfileName.c_str(),
                         REF_TO_INT(particleProfile), particleProfileName.c_str());        
    }

    return particle;
}
开发者ID:dreamsxin,项目名称:egoboo,代码行数:49,代码来源:ParticleHandler.cpp


注:本文中的ObjectRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。