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


C++ Identifier::Document方法代码示例

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


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

示例1: SetParent

    bool RetainedEntityInterface::SetParent(
        const Identifier& child, const Identifier& parent, int insertionPosition)
    {
        if (child.Document() != parent.Document())
            return false;

        auto childType = _scene->GetObjectType(child.ObjectType());
        if (!childType) return false;

        auto* childObj = _scene->GetEntityInt(child.Document(), child.Object());
        if (!childObj || childObj->_type != child.ObjectType())
            return false;

        if (childObj->_parent != 0) {
            auto* oldParent = _scene->GetEntityInt(child.Document(), childObj->_parent);
            if (oldParent) {
                auto i = std::find(oldParent->_children.begin(), oldParent->_children.end(), child.Object());
                oldParent->_children.erase(i);

                auto oldParentType = _scene->GetObjectType(parent.ObjectType());
                if (oldParentType)
                    _scene->InvokeOnChange(
                        *oldParentType, *oldParent, 
                        RetainedEntities::ChangeType::RemoveChild);
            }

            childObj->_parent = 0;
        }

///////////////////////////////////////////////////////////////////////////////////////////////////
            // if parent is set to 0, then this is a "remove from parent" operation
        if (!parent.Object()) {
            _scene->InvokeOnChange(*childType, *childObj, RetainedEntities::ChangeType::SetParent);
            return true;
        }

        auto* parentObj = _scene->GetEntityInt(parent.Document(), parent.Object());
        if (!parentObj || parentObj->_type != parent.ObjectType()) {
            _scene->InvokeOnChange(*childType, *childObj, RetainedEntities::ChangeType::SetParent);
            return false;
        }

        if (insertionPosition < 0 || insertionPosition >= (int)parentObj->_children.size()) {
            parentObj->_children.push_back(child.Object());
        } else {
            parentObj->_children.insert(
                parentObj->_children.begin() + insertionPosition,
                child.Object());
        }
        childObj->_parent = parentObj->_id;

        _scene->InvokeOnChange(*childType, *childObj, RetainedEntities::ChangeType::SetParent);

        auto parentType = _scene->GetObjectType(parent.ObjectType());
        if (parentType)
            _scene->InvokeOnChange(*parentType, *parentObj, RetainedEntities::ChangeType::AddChild);

        return true;
    }
开发者ID:coreafive,项目名称:XLE,代码行数:59,代码来源:RetainedEntities.cpp

示例2: CreateObject

	bool RetainedEntityInterface::CreateObject(const Identifier& id, 
        const PropertyInitializer initializers[], size_t initializerCount)
    {
        auto type = _scene->GetObjectType(id.ObjectType());
        if (!type) return false;

        for (auto i=_scene->_objects.cbegin(); i!=_scene->_objects.cend(); ++i)
            if (i->_doc == id.Document() && i->_id == id.Object()) return false;

        RetainedEntity newObject;
        newObject._doc = id.Document();
        newObject._id = id.Object();
        newObject._type = id.ObjectType();
        newObject._parent = 0;

        for (size_t c=0; c<initializerCount; ++c)
            _scene->SetSingleProperties(newObject, *type, initializers[c]);

        _scene->_objects.push_back(std::move(newObject));

        _scene->InvokeOnChange(*type, _scene->_objects[_scene->_objects.size()-1], RetainedEntities::ChangeType::Create);
        return true;
    }
开发者ID:coreafive,项目名称:XLE,代码行数:23,代码来源:RetainedEntities.cpp

示例3: DeleteObject

	bool RetainedEntityInterface::DeleteObject(const Identifier& id)
    {
        for (auto i=_scene->_objects.begin(); i!=_scene->_objects.end(); ++i)
            if (i->_doc == id.Document() && i->_id == id.Object()) {
                assert(i->_type == id.ObjectType());
                RetainedEntity copy(std::move(*i));
                _scene->_objects.erase(i);

                auto type = _scene->GetObjectType(id.ObjectType());
                if (type)
                    _scene->InvokeOnChange(*type, copy, RetainedEntities::ChangeType::Delete);
                return true;
            }
        return false;
    }
开发者ID:coreafive,项目名称:XLE,代码行数:15,代码来源:RetainedEntities.cpp

示例4: GetProperty

	bool RetainedEntityInterface::GetProperty(const Identifier& id, PropertyId prop, void* dest, unsigned* destSize) const
    {
        auto type = _scene->GetObjectType(id.ObjectType());
        if (!type) return false;
        if (prop == 0 || prop > type->_properties.size()) return false;

        const auto& propertyName = type->_properties[prop-1];

        for (auto i=_scene->_objects.begin(); i!=_scene->_objects.end(); ++i)
            if (i->_doc == id.Document() && i->_id == id.Object()) {
                auto res = i->_properties.GetParameter<unsigned>(propertyName.c_str());
                if (res.first) {
                    *(unsigned*)dest = res.second;
                }
                return true;
            }

        return false;
    }
开发者ID:coreafive,项目名称:XLE,代码行数:19,代码来源:RetainedEntities.cpp

示例5: SetProperty

	bool RetainedEntityInterface::SetProperty(
        const Identifier& id, 
        const PropertyInitializer initializers[], size_t initializerCount)
    {
        auto type = _scene->GetObjectType(id.ObjectType());
        if (!type) return false;

        for (auto i=_scene->_objects.begin(); i!=_scene->_objects.end(); ++i)
            if (i->_doc == id.Document() && i->_id == id.Object()) {
                bool gotChange = false;
                for (size_t c=0; c<initializerCount; ++c) {
                    auto& prop = initializers[c];
                    gotChange |= _scene->SetSingleProperties(*i, *type, prop);
                }
                if (gotChange) _scene->InvokeOnChange(*type, *i, RetainedEntities::ChangeType::SetProperty);
                return true;
            }

        return false;
    }
开发者ID:coreafive,项目名称:XLE,代码行数:20,代码来源:RetainedEntities.cpp


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