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


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

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


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

示例1: resolveContextObjectPropertyPath

//==============================================================================
std::string RPURU::resolveContextObjectPropertyPath(const ObjectHandle& contextObject, const char* propertyPath,
                                                    IDefinitionManager& definitionManager)
{
	assert(contextObject != nullptr);
	const auto classDef = contextObject.getDefinition(definitionManager);
	assert(classDef != nullptr);
	std::string tmp = propertyPath;
	std::vector<std::string> paths;
	paths.push_back(tmp);

	char* pch;
	pch = strtok(const_cast<char*>(tmp.c_str()), ".");
	if (pch != NULL)
	{
		pch = strtok(NULL, ".");
		while (pch != NULL)
		{
			paths.push_back(pch);
			pch = strtok(NULL, ".");
		}
	}
	PropertyAccessor pa;
	for (auto& path : paths)
	{
		resolveProperty(contextObject, *classDef, path.c_str(), pa, definitionManager);
		if (pa.isValid())
		{
			break;
		}
	}
	return pa.getFullPath();
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:33,代码来源:reflectedproperty_undoredo_helper.cpp

示例2: 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

示例3: resolveProperty

//==============================================================================
void RPURU::resolveProperty(const ObjectHandle& handle, const IClassDefinition& classDef, const char* propertyPath,
                            PropertyAccessor& o_Pa, IDefinitionManager& definitionManager)
{
	o_Pa = handle.getDefinition(definitionManager)->bindProperty(propertyPath, handle);
	if (o_Pa.isValid())
	{
		return;
	}
	const PropertyIteratorRange& props = classDef.allProperties();
	for (PropertyIterator pi = props.begin(); pi != props.end(); ++pi)
	{
		std::string parentPath = pi->getName();
		const PropertyAccessor& prop = classDef.bindProperty(parentPath.c_str(), handle);
		assert(prop.isValid());
		if (prop.getProperty()->isMethod())
		{
			continue;
		}
		const Variant& value = prop.getValue();
		if (value.typeIs<ObjectHandle>())
		{
			ObjectHandle subHandle;
			bool isOk = value.tryCast(subHandle);
			assert(isOk);
			if ((subHandle == nullptr) || (subHandle.getDefinition(definitionManager) == nullptr))
			{
				continue;
			}
			parentPath = parentPath + "." + propertyPath;

			resolveProperty(subHandle, *subHandle.getDefinition(definitionManager), parentPath.c_str(), o_Pa,
			                definitionManager);

			if (o_Pa.isValid())
			{
				return;
			}
		}
	}
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:41,代码来源:reflectedproperty_undoredo_helper.cpp


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