本文整理汇总了C++中PropertyAccessor::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyAccessor::isValid方法的具体用法?C++ PropertyAccessor::isValid怎么用?C++ PropertyAccessor::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyAccessor
的用法示例。
在下文中一共展示了PropertyAccessor::isValid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getReflectionController
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 );
}
}
示例2: 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();
}
示例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;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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;
}
}
}
}
示例7: 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;
}