• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ WeakPtr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ApplyAttributes

void LuaScriptInstance::ApplyAttributes()
{
    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_APPLYATTRIBUTES];
    if (function && function->BeginCall(this))
    {
        function->EndCall();
    }
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:8,代码来源:LuaScriptInstance.cpp


示例2: HoldObject

		/*=============================================================================
		-- Adds the object to the inventory. Effectively "picking up" the object.
		=============================================================================*/
		void Actor::HoldObject(WeakPtr<Object> object)
		{
			if (!object.expired())
			{
				mInventory->AddObject(object);
				object.lock()->SetHost( GetManager()->GetEntity(GetId()) );
			}
		}
开发者ID:DanWatkins,项目名称:GlanceEngineSDK,代码行数:11,代码来源:Actor.cpp


示例3: PushWeakObject

void PushWeakObject(duk_context* ctx, Object* object)
{
    if (!object)
    {
        duk_push_null(ctx);
        return;
    }

    duk_push_heap_stash(ctx);

    // Check if the wrapper for the object already exists in stash
    // This is required so that comparisons of object references (e.g. against the me property) work properly
    if (duk_has_prop_index(ctx, -1, (size_t)object))
    {
        duk_get_prop_index(ctx, -1, (size_t)object);
        WeakPtr<Object>* oldPtr = GetWeakPtr(ctx, -1);
        if (oldPtr && oldPtr->Get() == object)
        {
            duk_remove(ctx, -2); // Remove stash
            return;
        }
        else
            duk_pop(ctx); // Valid existing wrapper not found
    }

    duk_push_object(ctx);
    WeakPtr<Object>* ptr = new WeakPtr<Object>(object);
    duk_push_pointer(ctx, ptr);
    duk_put_prop_string(ctx, -2, "\xff""weak");
    duk_push_c_function(ctx, WeakPtr_Finalizer, 1);
    duk_set_finalizer(ctx, -2);

    // Set prototype. If not found, use base class prototype (e.g. IComponent)
    duk_get_global_string(ctx, object->GetTypeName().CString());
    if (!duk_is_object(ctx, -1))
    {
        duk_pop(ctx);
        duk_get_global_string(ctx, object->GetTypeInfo()->GetBaseTypeInfo()->GetTypeName().CString());
    }
    duk_get_prop_string(ctx, -1, "prototype");
    duk_set_prototype(ctx, -3);
    duk_pop(ctx);

    // Proxied property access handling for scene, entity & component
    if (object->GetType() == Scene::GetTypeStatic())
        SetupProxy(ctx, SceneProxyFunctions);
    if (object->GetType() == Entity::GetTypeStatic())
        SetupProxy(ctx, EntityProxyFunctions);
    else if (dynamic_cast<IComponent*>(object))
        SetupProxy(ctx, ComponentProxyFunctions);

    // Store to stash
    duk_dup(ctx, -1);
    duk_put_prop_index(ctx, -3, (size_t)object);
    duk_remove(ctx, -2); // Remove stash
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:56,代码来源:BindingsHelpers.cpp


示例4: HandleEvent

void LuaScriptInstance::HandleEvent(StringHash eventType, VariantMap& eventData)
{
    WeakPtr<LuaFunction> function = eventTypeToFunctionMap_[eventType];
    if (function && function->BeginCall(this))
    {
        function->PushUserType(eventType, "StringHash");
        function->PushUserType(eventData, "VariantMap");
        function->EndCall();
    }
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:10,代码来源:LuaScriptInstance.cpp


示例5: GetEventSender

void LuaScriptInstance::HandleObjectEvent(StringHash eventType, VariantMap& eventData)
{
    Object* object = GetEventSender();
    WeakPtr<LuaFunction> function = objectToEventTypeToFunctionMap_[object][eventType];
    if (function && function->BeginCall(this))
    {
        function->PushUserType(eventType, "StringHash");
        function->PushUserType(eventData, "VariantMap");
        function->EndCall();
    }
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:11,代码来源:LuaScriptInstance.cpp


示例6: HandlePostFixedUpdate

void LuaScriptInstance::HandlePostFixedUpdate(StringHash eventType, VariantMap& eventData)
{
    using namespace PhysicsPostStep;
    float timeStep = eventData[P_TIMESTEP].GetFloat();

    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_FIXEDPOSTUPDATE];
    if (function && function->BeginCall(this))
    {
        function->PushFloat(timeStep);
        function->EndCall();
    }
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:12,代码来源:LuaScriptInstance.cpp


示例7: ENABLE

RawPtr<Node> NodeIntersectionObserverData::createWeakPtr(Node* node)
{
#if ENABLE(OILPAN)
    return node;
#else
    if (!m_weakPointerFactory)
        m_weakPointerFactory = new WeakPtrFactory<Node>(node);
    WeakPtr<Node> result = m_weakPointerFactory->createWeakPtr();
    ASSERT(result.get() == node);
    return result;
#endif
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:12,代码来源:NodeIntersectionObserverData.cpp


示例8: DropObject

		/*=============================================================================
		-- Drops the object with the id in the inventory if it exists.
		=============================================================================*/
		void Actor::DropObject(int id)
		{
			//place the object on the ground behind the Actor so it does not walk over it right away.
			WeakPtr<Object> object = mInventory->GetObject(id);

			if (!object.expired())
			{
				object.lock()->SetHeld(false);
				object.lock()->SetPos(Vector3D<double>(GetPos().x+32.0, GetPos().y+32.0, GetPos().z+2.0));
				mInventory->RemoveObject(id);
			}
		}
开发者ID:DanWatkins,项目名称:GlanceEngineSDK,代码行数:15,代码来源:Actor.cpp


示例9: ReactToCollision

		/*=============================================================================
		-- Special actions for colliding with certain enity types.
		=============================================================================*/
		void Actor::ReactToCollision(WeakPtr<Entity> entity)
		{
			if (entity.expired())
				return;

			if (entity.lock()->GetType() == OBJECT)
			{
				WeakPtr<Object> object = WeakPtr<Object>(DynamicPtrCast<Object>(entity.lock()));

				if (object.lock()->GetObtainable())
					HoldObject( object );
			}
		}
开发者ID:DanWatkins,项目名称:GlanceEngineSDK,代码行数:16,代码来源:Actor.cpp


示例10: SetScriptNetworkDataAttr

void LuaScriptInstance::SetScriptNetworkDataAttr(PODVector<unsigned char> data)
{
    if (scriptObjectRef_ == LUA_REFNIL)
        return;

    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_READNETWORKUPDATE];
    if (function && function->BeginCall(this))
    {
        MemoryBuffer buf(data);
        function->PushUserType((Deserializer&)buf, "Deserializer");
        function->EndCall();
    }
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:13,代码来源:LuaScriptInstance.cpp


示例11: HandleEvent

void LuaScript::HandleEvent(StringHash eventType, VariantMap& eventData)
{
    LuaFunctionVector& functions = eventHandleFunctions_[eventType];
    for (unsigned i = 0; i < functions.Size(); ++i)
    {
        WeakPtr<LuaFunction> function = functions[i];
        if (function && function->BeginCall())
        {
            function->PushUserType(eventType, "StringHash");
            function->PushUserType(eventData, "VariantMap");
            function->EndCall();
        }
    }
}
开发者ID:erlgo,项目名称:Urho3D,代码行数:14,代码来源:LuaScript.cpp


示例12: ASSERT

void GenericEventQueue::sharedTimerFired()
{
    ASSERT(!sharedTimer().isActive());
    ASSERT(!pendingQueues().isEmpty());

    while (!pendingQueues().isEmpty()) {
        WeakPtr<GenericEventQueue> queue = pendingQueues().takeFirst();
        if (!queue)
            continue;
        queue->dispatchOneEvent();
    }

    if (sharedTimer().isActive())
        sharedTimer().stop();
}
开发者ID:hnney,项目名称:webkit,代码行数:15,代码来源:GenericEventQueue.cpp


示例13: WeakPtr

    WeakPtr(const WeakPtr<S>& src)
    {
        if (src.isValid()) {
            ptr = src.getRawPtr();
#ifdef WEAK_PTR_HAS_EXTRA_PTR_TO_COUNTERS
            heapObjectCounters = HeapObjectRefManipulator::getHeapObjectCounters(ptr);
#endif
            HeapObjectRefManipulator::incWeakCounter(getHeapObjectCounters());
        } else {
            ptr = NULL;
#ifdef WEAK_PTR_HAS_EXTRA_PTR_TO_COUNTERS
            heapObjectCounters = NULL;
#endif
        }
    }
开发者ID:BackupTheBerlios,项目名称:luced,代码行数:15,代码来源:WeakPtr.hpp


示例14: m_messagingProxy

InProcessWorkerObjectProxy::InProcessWorkerObjectProxy(
    const WeakPtr<InProcessWorkerMessagingProxy>& messagingProxy)
    : m_messagingProxy(messagingProxy.get()),
      m_messagingProxyWeakPtr(messagingProxy),
      m_defaultIntervalInSec(kDefaultIntervalInSec),
      m_nextIntervalInSec(kDefaultIntervalInSec),
      m_maxIntervalInSec(kMaxIntervalInSec) {}
开发者ID:mirror,项目名称:chromium,代码行数:7,代码来源:InProcessWorkerObjectProxy.cpp


示例15: GetScene

void LuaScriptInstance::OnMarkedDirty(Node* node)
{
    // Script functions are not safe from worker threads
    Scene* scene = GetScene();
    if (scene && scene->IsThreadedUpdate())
    {
        scene->DelayedMarkedDirty(this);
        return;
    }

    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_TRANSFORMCHANGED];
    if (function && function->BeginCall(this))
    {
        function->EndCall();
    }
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:16,代码来源:LuaScriptInstance.cpp


示例16:

PODVector<unsigned char> LuaScriptInstance::GetScriptNetworkDataAttr() const
{
    if (scriptObjectRef_ == LUA_REFNIL)
        return PODVector<unsigned char>();

    VectorBuffer buf;

    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_WRITENETWORKUPDATE];
    if (function && function->BeginCall(this))
    {
        function->PushUserType((Serializer&)buf, "Serializer");
        function->EndCall();
    }

    return buf.GetBuffer();
}
开发者ID:janfrost,项目名称:Urho3D,代码行数:16,代码来源:LuaScriptInstance.cpp


示例17: create

SimpleReaderNode::Ptr SimpleReaderNode::create(const QString &name, WeakPtr parent)
{
    Ptr newNode(new SimpleReaderNode(name, parent));
    newNode->m_weakThis = newNode;
    if (parent)
        parent.data()->m_children.append(newNode);
    return newNode;
}
开发者ID:choenig,项目名称:qt-creator,代码行数:8,代码来源:qmljssimplereader.cpp


示例18: UnsubscribeFromScriptMethodEvents

void LuaScriptInstance::ReleaseObject()
{
    if (scriptObjectRef_ == LUA_REFNIL)
        return;

    if (IsEnabledEffective())
        UnsubscribeFromScriptMethodEvents();

    // Unref script object
    luaL_unref(luaState_, LUA_REGISTRYINDEX, scriptObjectRef_);
    scriptObjectRef_ = LUA_REFNIL;

    WeakPtr<LuaFunction> function = luaScript_->GetFunction("DestroyScriptObjectInstance");
    if (function && function->BeginCall())
    {
        function->PushUserType((void*)this, "LuaScriptInstance");
        function->EndCall();
    }
}
开发者ID:Gotusso,项目名称:Urho3D,代码行数:19,代码来源:LuaScriptInstance.cpp


示例19: lookup

ImageDataCache::Ptr ImageDataCachePrivate::lookup(ImageDataMetadata::Ptr metadata)
{
    if (cache.contains(metadata)) {
        WeakPtr weakPtr = cache[metadata];
        ImageDataCache::Ptr ptr = weakPtr.toStrongRef();

        if (ptr.isNull()) {
            cache.remove(metadata);
        } else {
            return ptr;
        }
    }

    ImageDataCache::Ptr ptr(new ImageDataCache::CacheEntry());

    cache.insert(metadata, ptr.toWeakRef());

    return ptr;
}
开发者ID:khorben,项目名称:sudoku-united,代码行数:19,代码来源:imagedatacache.cpp


示例20: getSymPath

const SymbolPath SymbolNode::getSymPath() const
{
	SymbolPath path;
	const SymbolNode* curNode = this;
	for (WeakPtr wpParent = m_parent; !wpParent.isNull();)
	{
		Ptr pParent = wpParent.toStrongRef();
		for (ConstChildIterator pChild = pParent->childConstBegin();
			pChild != pParent->childConstEnd(); ++pChild)
		{
			if (pChild.value().data() == curNode)
			{
				path.addParentSymbol(pChild.key());
				break;
			}
		}
		wpParent = pParent->m_parent;
	}
	return path;
}
开发者ID:league1991,项目名称:CodeAtlas,代码行数:20,代码来源:SymbolNode.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WindowEventProducerRecPtr类代码示例发布时间:2022-06-01
下一篇:
C++ UtlHashMap类代码示例发布时间:2022-06-01
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap