本文整理汇总了C++中ObjectHandle::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectHandle::isValid方法的具体用法?C++ ObjectHandle::isValid怎么用?C++ ObjectHandle::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectHandle
的用法示例。
在下文中一共展示了ObjectHandle::isValid方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: redo
bool MoveItemDataCommand::redo(const ObjectHandle& arguments) const /* override */
{
if (!arguments.isValid())
{
return false;
}
auto pCommandArgs = arguments.getBase<MoveItemDataCommandArgument>();
if (!MoveItemDataCommand_Detail::isValid(pCommandArgs))
{
return false;
}
const auto& dir = (pCommandArgs->direction_);
auto& model = (*pCommandArgs->pModel_);
const auto& startPos = (pCommandArgs->startPos_);
const auto& endPos = (pCommandArgs->endPos_);
const auto& count = (pCommandArgs->count_);
const auto& startParent = (pCommandArgs->startParent_);
const auto& endParent = (pCommandArgs->endParent_);
if (dir == MoveItemDataCommandArgument::Direction::ROW)
{
return model.moveRows(startParent, startPos, count, endParent, endPos);
}
return false;
}
示例2: getCommandDescription
ObjectHandle MoveItemDataCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
auto handle = GenericObject::create(*get<IDefinitionManager>());
assert(handle.get() != nullptr);
auto& genericObject = (*handle);
if (!arguments.isValid())
{
genericObject.set("Name", "Invalid");
genericObject.set("Type", "Move");
return ObjectHandle(std::move(handle));
}
auto pCommandArgs = arguments.getBase<MoveItemDataCommandArgument>();
if (!MoveItemDataCommand_Detail::isValid(pCommandArgs))
{
genericObject.set("Name", "Invalid");
genericObject.set("Type", "Move");
return ObjectHandle(std::move(handle));
}
genericObject.set("Name", "Move");
genericObject.set("Type", "Move");
return ObjectHandle(std::move(handle));
}
示例3: getCommandDescription
CommandDescription RemoveItemCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
auto object = GenericObject::create();
if (!arguments.isValid())
{
object->set("Name", "Invalid");
object->set("Type", "Remove");
}
else
{
auto pCommandArgs = arguments.getBase<RemoveItemCommandArgument>();
if (!RemoveItemCommand_Detail::isValid(pCommandArgs))
{
object->set("Name", "Invalid");
object->set("Type", "Remove");
}
else
{
object->set("Id", pCommandArgs->key_);
object->set("Name", "Remove");
object->set("Type", "Remove");
object->set("PreValue", pCommandArgs->value_);
}
}
return std::move(object);
}
示例4: getCommandDescription
ObjectHandle InsertItemCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
auto handle = GenericObject::create(*definitionManager_);
assert(handle.get() != nullptr);
auto& genericObject = (*handle);
if (!arguments.isValid())
{
genericObject.set("Name", "Invalid");
genericObject.set("Type", "Insert");
return ObjectHandle(std::move(handle));
}
auto pCommandArgs = arguments.getBase<InsertItemCommandArgument>();
if (!InsertItemCommand_Detail::isValid(pCommandArgs))
{
genericObject.set("Name", "Invalid");
genericObject.set("Type", "Insert");
return ObjectHandle(std::move(handle));
}
genericObject.set("Id", pCommandArgs->key_);
genericObject.set("Name", "Insert");
genericObject.set("Type", "Insert");
genericObject.set("PostValue", pCommandArgs->value_);
return ObjectHandle(std::move(handle));
}
示例5: getCommandDescription
ObjectHandle SetItemDataCommand::getCommandDescription(const ObjectHandle& arguments) const /* override */
{
auto handle = GenericObject::create(*definitionManager_);
assert(handle.get() != nullptr);
auto& genericObject = (*handle);
if (!arguments.isValid())
{
genericObject.set("Name", "Invalid");
genericObject.set("Type", "Data");
return ObjectHandle(std::move(handle));
}
auto pCommandArgs = arguments.getBase<SetItemDataCommandArgument>();
if (!SetItemDataCommand_Detail::isValid(pCommandArgs))
{
genericObject.set("Name", "Invalid");
genericObject.set("Type", "Data");
return ObjectHandle(std::move(handle));
}
genericObject.set("Name", "Data");
genericObject.set("Type", "Data");
const auto& oldValue = (pCommandArgs->oldValue_);
const auto& newValue = (pCommandArgs->newValue_);
genericObject.set("PreValue", oldValue);
genericObject.set("PostValue", newValue);
return ObjectHandle(std::move(handle));
}
示例6: 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;
}
示例7: redo
bool RemoveItemCommand::redo(const ObjectHandle& arguments) const /* override */
{
if (!arguments.isValid())
{
return false;
}
auto pCommandArgs = arguments.getBase<RemoveItemCommandArgument>();
if (!RemoveItemCommand_Detail::isValid(pCommandArgs))
{
return false;
}
auto& model = (*static_cast<CollectionModel*>(pCommandArgs->pModel_));
const auto& key = (pCommandArgs->key_);
return model.removeItem(key);
}
示例8: 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;
}
示例9: reflectedRoot
//------------------------------------------------------------------------------
ObjectHandle reflectedRoot(const ObjectHandle& source, const IDefinitionManager& definitionManager)
{
if (!source.isValid())
{
return source;
}
auto root = source.storage();
auto reflectedRoot = definitionManager.getObjectDefinition(root) != nullptr ? root : nullptr;
for (;;)
{
auto inner = root->inner();
if (inner == nullptr)
{
break;
}
root = inner;
reflectedRoot = definitionManager.getObjectDefinition(root) != nullptr ? root : nullptr;
}
return ObjectHandle(reflectedRoot);
}
示例10: redo
bool SetItemDataCommand::redo(const ObjectHandle& arguments) const /* override */
{
if (!arguments.isValid())
{
return false;
}
auto pCommandArgs = arguments.getBase<SetItemDataCommandArgument>();
if (!SetItemDataCommand_Detail::isValid(pCommandArgs))
{
return false;
}
auto& model = (*pCommandArgs->pModel_);
const auto& index = (pCommandArgs->index_);
const auto& roleId = (pCommandArgs->roleId_);
const auto& newValue = (pCommandArgs->newValue_);
auto pItem = model.item(index);
assert(pItem != nullptr);
return pItem->setData(index.row_, index.column_, roleId, newValue);
}
示例11: updateCheckoutState
void BaseEditor::updateCheckoutState(const ObjectHandle& handle)
{
if (!handle.isValid())
{
return;
}
ObjectHandle root = handle;
while (root.parent().isValid())
{
root = root.parent();
}
auto path = getResourceFileName(root);
if (path == nullptr || *path == char(0))
{
return;
}
updateCheckoutState(path);
}