//==============================================================================
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();
}
Пример #2
0
	bool createKey( const PropertyAccessor & pa, Key & o_Key )
	{
		const auto & obj = pa.getRootObject();
		if (obj == nullptr)
		{
			return false;
		}

		if (!obj.getId( o_Key.first ))
		{
			auto om = pa.getDefinitionManager()->getObjectManager();
			assert( !om->getObject( obj.data() ).isValid() );
			if (!om->getUnmanagedObjectId( obj.data(), o_Key.first ))
			{
				o_Key.first = om->registerUnmanagedObject( obj );
			}
		}

		o_Key.second = pa.getFullPath();
		return true;
	}