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


C++ ObjectHandle::isValid方法代码示例

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


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

示例1: redo

bool MoveItemDataCommand::redo(const ObjectHandle& arguments) const /* override */
{
	if (!arguments.isValid())
	{
		return false;
	}

	auto pCommandArgs = arguments.getBase<MoveItemDataCommandArgument>();
	if (!MoveItemDataCommand_Detail::isValid(pCommandArgs))
	{
		return false;
	}

	const auto& dir = (pCommandArgs->direction_);
	auto& model = (*pCommandArgs->pModel_);

	const auto& startPos = (pCommandArgs->startPos_);
	const auto& endPos = (pCommandArgs->endPos_);
	const auto& count = (pCommandArgs->count_);

	const auto& startParent = (pCommandArgs->startParent_);
	const auto& endParent = (pCommandArgs->endParent_);

	if (dir == MoveItemDataCommandArgument::Direction::ROW)
	{
		return model.moveRows(startParent, startPos, count, endParent, endPos);
	}

	return false;
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:30,代码来源:move_item_data_command.cpp

示例2: getCommandDescription

ObjectHandle MoveItemDataCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
	auto handle = GenericObject::create(*get<IDefinitionManager>());
	assert(handle.get() != nullptr);
	auto& genericObject = (*handle);

	if (!arguments.isValid())
	{
		genericObject.set("Name", "Invalid");
		genericObject.set("Type", "Move");
		return ObjectHandle(std::move(handle));
	}

	auto pCommandArgs = arguments.getBase<MoveItemDataCommandArgument>();
	if (!MoveItemDataCommand_Detail::isValid(pCommandArgs))
	{
		genericObject.set("Name", "Invalid");
		genericObject.set("Type", "Move");
		return ObjectHandle(std::move(handle));
	}

	genericObject.set("Name", "Move");
	genericObject.set("Type", "Move");

	return ObjectHandle(std::move(handle));
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:26,代码来源:move_item_data_command.cpp

示例3: getCommandDescription

CommandDescription RemoveItemCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
    auto object = GenericObject::create();

	if (!arguments.isValid())
	{
		object->set("Name", "Invalid");
		object->set("Type", "Remove");
	}
    else
    {
        auto pCommandArgs = arguments.getBase<RemoveItemCommandArgument>();
        if (!RemoveItemCommand_Detail::isValid(pCommandArgs))
        {
            object->set("Name", "Invalid");
            object->set("Type", "Remove");
        }
        else
        {
            object->set("Id", pCommandArgs->key_);
            object->set("Name", "Remove");
            object->set("Type", "Remove");
            object->set("PreValue", pCommandArgs->value_);
        }
    }

    return std::move(object);
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:28,代码来源:remove_item_command.cpp

示例4: getCommandDescription

ObjectHandle InsertItemCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
	auto handle = GenericObject::create(*definitionManager_);
	assert(handle.get() != nullptr);
	auto& genericObject = (*handle);

	if (!arguments.isValid())
	{
		genericObject.set("Name", "Invalid");
		genericObject.set("Type", "Insert");
		return ObjectHandle(std::move(handle));
	}

	auto pCommandArgs = arguments.getBase<InsertItemCommandArgument>();
	if (!InsertItemCommand_Detail::isValid(pCommandArgs))
	{
		genericObject.set("Name", "Invalid");
		genericObject.set("Type", "Insert");
		return ObjectHandle(std::move(handle));
	}

	genericObject.set("Id", pCommandArgs->key_);
	genericObject.set("Name", "Insert");
	genericObject.set("Type", "Insert");
	genericObject.set("PostValue", pCommandArgs->value_);

	return ObjectHandle(std::move(handle));
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:28,代码来源:insert_item_command.cpp

示例5: getCommandDescription

ObjectHandle SetItemDataCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
	auto handle = GenericObject::create(*definitionManager_);
	assert(handle.get() != nullptr);
	auto& genericObject = (*handle);

	if (!arguments.isValid())
	{
		genericObject.set("Name", "Invalid");
		genericObject.set("Type", "Data");
		return ObjectHandle(std::move(handle));
	}

	auto pCommandArgs = arguments.getBase<SetItemDataCommandArgument>();
	if (!SetItemDataCommand_Detail::isValid(pCommandArgs))
	{
		genericObject.set("Name", "Invalid");
		genericObject.set("Type", "Data");
		return ObjectHandle(std::move(handle));
	}

	genericObject.set("Name", "Data");
	genericObject.set("Type", "Data");

	const auto& oldValue = (pCommandArgs->oldValue_);
	const auto& newValue = (pCommandArgs->newValue_);
	genericObject.set("PreValue", oldValue);
	genericObject.set("PostValue", newValue);

	return ObjectHandle(std::move(handle));
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:31,代码来源:set_item_data_command.cpp

示例6: execute

//==============================================================================
ObjectHandle SetReflectedPropertyCommand::execute(
	const ObjectHandle & arguments ) const
{
	ReflectedPropertyCommandArgument * commandArgs =
		arguments.getBase< ReflectedPropertyCommandArgument >();
	auto objManager = definitionManager_.getObjectManager();
	assert( objManager != nullptr );
	ObjectHandle object = objManager->getObject( commandArgs->getContextId() );
	if (!object.isValid())
	{
		return CommandErrorCode::INVALID_ARGUMENTS;
	}
	PropertyAccessor property = object.getDefinition( definitionManager_ )->bindProperty( 
		commandArgs->getPropertyPath(), object );
	if (property.isValid() == false)
	{
		//Can't set
		return CommandErrorCode::INVALID_ARGUMENTS;
	}
	const Variant & data = commandArgs->getPropertyValue();
	bool br = property.setValue( data );
	if (!br)
	{
		return CommandErrorCode::INVALID_VALUE;
	}

	// Do not return the object
	// CommandInstance will hold a reference to the return value
	// and the CommandInstance is stored in the undo/redo history forever
	// This is due to a circular reference in CommandManagerImpl::pushFrame
	return nullptr;
}
开发者ID:bw-github,项目名称:wgtf,代码行数:33,代码来源:set_reflectedproperty_command.cpp

示例7: redo

bool RemoveItemCommand::redo(const ObjectHandle& arguments) const /* override */
{
	if (!arguments.isValid())
	{
		return false;
	}

	auto pCommandArgs = arguments.getBase<RemoveItemCommandArgument>();
	if (!RemoveItemCommand_Detail::isValid(pCommandArgs))
	{
		return false;
	}

	auto& model = (*static_cast<CollectionModel*>(pCommandArgs->pModel_));
	const auto& key = (pCommandArgs->key_);

	return model.removeItem(key);
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:18,代码来源:remove_item_command.cpp

示例8: validateArguments

//==============================================================================
bool SetReflectedPropertyCommand::validateArguments(const ObjectHandle& arguments) const
{
	if ( !arguments.isValid() ) 
	{
		return false;
	}

	auto commandArgs = arguments.getBase< ReflectedPropertyCommandArgument >();
	
	if ( commandArgs == nullptr ) 
	{
			return false;
	}

	auto objManager = definitionManager_.getObjectManager();
	if ( objManager == nullptr ) 
	{
		return false;
	}

	const ObjectHandle & object = objManager->getObject( commandArgs->getContextId() );
	if (!object.isValid())
	{
		return false;
	}

	const IClassDefinition* defn = object.getDefinition( definitionManager_ );
	PropertyAccessor property = defn->bindProperty(commandArgs->getPropertyPath(), object );
	if (property.isValid() == false)
	{
		return false;
	}
	
	const MetaType * dataType = commandArgs->getPropertyValue().type();
	const MetaType * propertyValueType = property.getValue().type();

	if ( !dataType->canConvertTo(propertyValueType) ) 
	{
		return false;
	}

	return true;
}
开发者ID:bw-github,项目名称:wgtf,代码行数:44,代码来源:set_reflectedproperty_command.cpp

示例9: reflectedRoot

//------------------------------------------------------------------------------
ObjectHandle reflectedRoot(const ObjectHandle& source, const IDefinitionManager& definitionManager)
{
	if (!source.isValid())
	{
		return source;
	}

	auto root = source.storage();
	auto reflectedRoot = definitionManager.getObjectDefinition(root) != nullptr ? root : nullptr;
	for (;;)
	{
		auto inner = root->inner();
		if (inner == nullptr)
		{
			break;
		}
		root = inner;
		reflectedRoot = definitionManager.getObjectDefinition(root) != nullptr ? root : nullptr;
	}
	return ObjectHandle(reflectedRoot);
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:22,代码来源:object_handle.cpp

示例10: redo

bool SetItemDataCommand::redo(const ObjectHandle& arguments) const /* override */
{
	if (!arguments.isValid())
	{
		return false;
	}

	auto pCommandArgs = arguments.getBase<SetItemDataCommandArgument>();
	if (!SetItemDataCommand_Detail::isValid(pCommandArgs))
	{
		return false;
	}

	auto& model = (*pCommandArgs->pModel_);
	const auto& index = (pCommandArgs->index_);
	const auto& roleId = (pCommandArgs->roleId_);
	const auto& newValue = (pCommandArgs->newValue_);

	auto pItem = model.item(index);
	assert(pItem != nullptr);
	return pItem->setData(index.row_, index.column_, roleId, newValue);
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:22,代码来源:set_item_data_command.cpp

示例11: updateCheckoutState

void BaseEditor::updateCheckoutState(const ObjectHandle& handle)
{
	if (!handle.isValid())
	{
		return;
	}

	ObjectHandle root = handle;

	while (root.parent().isValid())
	{
		root = root.parent();
	}

	auto path = getResourceFileName(root);

	if (path == nullptr || *path == char(0))
	{
		return;
	}

	updateCheckoutState(path);
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:23,代码来源:base_editor.cpp


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