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


C++ PropertyAccessor类代码示例

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


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

示例1: assert

//==============================================================================
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

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

示例3: INSTANCE_METHOD_INJECTION_BUILTIN

Variant c_XMLReader::t___get(Variant name) {
  INSTANCE_METHOD_INJECTION_BUILTIN(XMLReader, XMLReader::__get);
  const xmlChar *retchar = NULL;
	int retint = 0;

  PropertyAccessor *propertyMap = xmlreader_properties_map.get(name);
  if (m_ptr) {
    if (propertyMap->getter_char) {
      retchar = propertyMap->getter_char(m_ptr);
    } else if (propertyMap->getter_int) {
      retint = propertyMap->getter_int(m_ptr);
    }
  }

  switch (propertyMap->return_type) {
    case KindOfString:
      if (retchar) {
        return String((char*)retchar, CopyString);
      } else {
        return String("");
      }
    case KindOfBoolean:
      return (retint ? true : false);

    case KindOfInt64:
      return retint;

    default:
      return null;
  }
  return null;
}
开发者ID:gavingeng,项目名称:hiphop-php,代码行数:32,代码来源:ext_xmlreader.cpp

示例4: getValue

	Variant getValue( const PropertyAccessor & pa )
	{
		// This createKey is added as a work-around for objects that were
		// not registered with the IObjectManager properly on creation.
		//
		// Objects need a key to be shared with other plugins.
		// E.g. getValue() will be sharing your object with plg_command_manager.
		//
		// Better to register your object with IObjectManager::registerObject()
		// or IObjectManager::registerUnmanagedObject() when you create the
		// ObjectHandle.
		//
		// @see IObjectManager
		Key key;
		if (!createKey( pa, key ))
		{
			return pa.getValue();
		}

		// TODO: assert access is only on the main thread
		auto range = commands_.equal_range( key );
		for (auto it = range.first; it != range.second; ++it)
		{
			auto instance = it->second;
			commandManager_.waitForInstance(instance);
		}
		commands_.erase( range.first, range.second );

		return pa.getValue();
	}
开发者ID:bw-github,项目名称:wgtf,代码行数:30,代码来源:reflection_controller.cpp

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

示例6: TEST_F

TEST_F( TestCommandFixture, creatMacro )
{
	auto & controller = getReflectionController();

	auto objHandle = klass_->createManagedObject();

	PropertyAccessor counter = klass_->bindProperty("counter", objHandle );
	CHECK(counter.isValid());

	const int TEST_VALUE = 57;
	{
		int value = TEST_VALUE;
		controller.setValue( counter, value );
	}

	{
		// TODO: wait on controller
		controller.getValue( counter );
	}

	{
		auto & commandSystemProvider = getCommandSystemProvider();
		auto & history = commandSystemProvider.getHistory();
		commandSystemProvider.createMacro( history );
		CHECK(commandSystemProvider.getMacros().empty() == false );
	}
}
开发者ID:bw-github,项目名称:wgtf,代码行数:27,代码来源:test_command_system.cpp

示例7: assert

//==============================================================================
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

示例8: invokeProperty

Variant BaseGenericObject::invokeProperty(const char* name, const ReflectedMethodParameters& parameters)
{
	const IClassDefinition& definition = *this->getDefinition();
	ObjectHandle provider = this->getDerivedType();
	PropertyAccessor accessor = definition.bindProperty(name, provider);
	if (!accessor.isValid())
	{
		TF_ASSERT(false && "Property could not be found");
		return Variant();
	}
	return accessor.invoke(parameters);
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:12,代码来源:base_generic_object.cpp

示例9: assert

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

示例10: readBowFileText

//! @brief read a text Bow file and fills a lexicon
//! @param fileIn the file to read
//! @param reader the file reader
//! @param lex the lexicon to fill
//! @param propertyAccessor
//! @param referenceProperties
void readBowFileText(ifstream& fileIn,
                     BoWBinaryReader& reader,
                     Lexicon& lex,
                     const PropertyAccessor& propertyAccessor,
                     set<LinguisticCode>& referenceProperties
                    )
{
    BoWText text;
    reader.readBoWText(fileIn,text);

    bool filterCategory = false;
    if ( referenceProperties.size() > 0 ) {
        filterCategory = true;
    }

    BoWTokenIterator it(text);
    while (! it.isAtEnd()) {
        const BoWToken& token = *(it.getElement());
        if (filterCategory) {
            set<LinguisticCode>::const_iterator referencePropertyIt =
                referenceProperties.find(propertyAccessor.readValue(token.getCategory()));
            if ( referencePropertyIt != referenceProperties.end() ) {
                lex.add(getStringDecomp(&token),token.getIndexString());
            }
        }
        else {
            lex.add(getStringDecomp(&token),token.getIndexString());
        }
        it++;
    }
}
开发者ID:Geekking,项目名称:lima,代码行数:37,代码来源:getLexiconFromBoW.cpp

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

示例12: createKey

	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;
	}
开发者ID:bw-github,项目名称:wgtf,代码行数:21,代码来源:reflection_controller.cpp

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

示例14: findFirstMetaData

	//--------------------------------------------------------------------------
	ObjectHandle MetaUtilities::findFirstMetaData(
		const TypeId& typeId, const PropertyAccessor& accessor,
		const IDefinitionManager & definitionManager) override
	{
		auto && metaData = accessor.getMetaData();
		auto targetMetaData = findFirstMetaData(typeId, metaData, definitionManager);
		if (targetMetaData != nullptr)
		{
			return targetMetaData;
		}

		return nullptr;
	}
开发者ID:wgsyd,项目名称:wgtf,代码行数:14,代码来源:meta_utilities_impl.hpp

示例15: invoke

	Variant invoke( const PropertyAccessor & pa, const ReflectedMethodParameters & parameters )
	{
		Key key;
		if (!createKey( pa, key ))
		{
			return pa.invoke( parameters );
		}

		std::unique_ptr<ReflectedMethodCommandParameters> commandParameters( new ReflectedMethodCommandParameters() );
		commandParameters->setId( key.first );
		commandParameters->setPath( key.second.c_str() );
		commandParameters->setParameters( parameters );

		const auto itr = commands_.emplace( std::pair< Key, CommandInstancePtr >( key, commandManager_.queueCommand(
			getClassIdentifier<InvokeReflectedMethodCommand>(), ObjectHandle( std::move( commandParameters ),
			pa.getDefinitionManager()->getDefinition<ReflectedMethodCommandParameters>() ) ) ) );

		commandManager_.waitForInstance( itr->second );
		ObjectHandle returnValueObject = itr->second.get()->getReturnValue();
		commands_.erase( itr );
		Variant* returnValuePointer = returnValueObject.getBase<Variant>();
		assert( returnValuePointer != nullptr );
		return *returnValuePointer;
	}
开发者ID:bw-github,项目名称:wgtf,代码行数:24,代码来源:reflection_controller.cpp


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