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


C++ PropertyAccessor::setValue方法代码示例

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


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

示例1: addProperty

bool BaseGenericObject::addProperty(const char* name, const Variant& value, MetaData metadata, bool enableNotification)
{
	const IClassDefinition& definition = *this->getDefinition();
	ObjectHandle provider = this->getDerivedType();

	auto definitionModifier = definition.getDetails().getDefinitionModifier();
	if (definitionModifier == nullptr)
	{
		return false;
	}

	Collection testCollection;
	bool isCollection = value.tryCast<Collection>(testCollection);

	if (!definitionModifier->addProperty(name, value.type()->typeId(), std::move(metadata), isCollection))
	{
		return false;
	}

	PropertyAccessor accessor = definition.bindProperty(name, provider);
	if (enableNotification)
	{
		return accessor.setValue(value);
	}
	else
	{
		return accessor.setValueWithoutNotification(value);
	}
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:29,代码来源:base_generic_object.cpp

示例2: setValue

	void setValue( const PropertyAccessor & pa, const Variant & data )
	{
		Key key;
		if (!createKey( pa, key ))
		{
			pa.setValue( data );
			return;
		}

		std::unique_ptr< ReflectedPropertyCommandArgument > args( new ReflectedPropertyCommandArgument );
		args->setContextId( key.first );
		args->setPath( key.second.c_str() );
		args->setValue( data );
		
		// Access is only on the main thread
		assert( std::this_thread::get_id() == commandManager_.ownerThreadId() );

		const auto commandId = getClassIdentifier< SetReflectedPropertyCommand >();
		const auto pArgsDefinition =
			pa.getDefinitionManager()->getDefinition< ReflectedPropertyCommandArgument >();
		ObjectHandle commandArgs( std::move( args ), pArgsDefinition );
		auto command = commandManager_.queueCommand( commandId, commandArgs );

		// Queuing may cause it to execute straight away
		// Based on the thread affinity of SetReflectedPropertyCommand
		if (!command->isComplete())
		{
			commands_.emplace( std::pair< Key, CommandInstancePtr >( key, command ) );
		}
	}
开发者ID:bw-github,项目名称:wgtf,代码行数:30,代码来源:reflection_controller.cpp

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

示例4: callBasicDialog

void DialogTestModel::callBasicDialog(bool modal)
{
	assert(context_ != nullptr);
	auto uiFramework = context_->queryInterface<IUIFramework>();
	assert(uiFramework != nullptr);

	IDialog::ClosedCallback callback = [this](IDialog& dialog) {
		assert(definition_ != nullptr);
		PropertyAccessor accessor = definition_->bindProperty("basicDialogResult", this);
		accessor.setValue(dialog.result());
	};

	const IDialog::Mode mode = modal ? IDialog::Mode::MODAL : IDialog::Mode::MODELESS;
	uiFramework->showDialog("plg_dialog_test/basic_dialog.qml", mode, callback);
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:15,代码来源:dialog_test_model.cpp

示例5: setProperty

bool BaseGenericObject::setProperty(const char* name, const Variant& value, bool enableNotification)
{
	// Get existing property
	const IClassDefinition& definition = *this->getDefinition();
	ObjectHandle provider = this->getDerivedType();
	PropertyAccessor accessor = definition.bindProperty(name, provider);

	// do nothing if property does not exist and the value is void
	if (!accessor.isValid() && value.isVoid())
	{
		return false;
	}

	// set value to the property if property exists and the value is not void
	if (accessor.isValid() && !value.isVoid())
	{
		if (enableNotification)
		{
			return accessor.setValue(value);
		}
		else
		{
			return accessor.setValueWithoutNotification(value);
		}
	}

	// Property does not exist
	// Add new property and set it
	auto definitionModifier = definition.getDetails().getDefinitionModifier();
	if (definitionModifier == nullptr)
	{
		return false;
	}

	if (accessor.isValid() && value.isVoid())
	{
		definitionModifier->removeProperty(name);
		return false;
	}

	return addProperty(name, value, nullptr, enableNotification);
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:42,代码来源:base_generic_object.cpp


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