Commit 61b93f3e authored by T.J. Corona's avatar T.J. Corona
Browse files

Associate operation: check that input is valid before executing.

parent 2e4053f3
......@@ -49,6 +49,8 @@ class SMTKCORE_EXPORT Attribute : public resource::Component
friend class smtk::attribute::RefItem;
public:
smtkTypeMacro(smtk::attribute::Attribute);
static smtk::attribute::AttributePtr New(
const std::string& myName, smtk::attribute::DefinitionPtr myDefinition)
{
......
......@@ -17,6 +17,8 @@
#include "smtk/attribute/Resource.h"
#include "smtk/attribute/ResourceItem.h"
#include "smtk/io/Logger.h"
namespace smtk
{
namespace attribute
......@@ -28,6 +30,28 @@ Associate::Result Associate::operateInternal()
smtk::attribute::Resource::Ptr resource = std::dynamic_pointer_cast<smtk::attribute::Resource>(
this->parameters()->associations()->objectValue());
// Currently, we cannot specialize associations between resources and
// components. This means an attribute component is allowed as an input. If we
// recieve an attribute component, access its resource.
if (resource == nullptr)
{
smtk::attribute::Attribute::Ptr attribute =
std::dynamic_pointer_cast<smtk::attribute::Attribute>(
this->parameters()->associations()->objectValue());
if (attribute != nullptr)
{
resource = attribute->attributeResource();
}
}
// If we still do not have a valid resource, return with failure.
if (resource == nullptr)
{
smtkErrorMacro(this->log(), "Could not access attribute resource.");
return this->createResult(smtk::operation::Operation::Outcome::FAILED);
}
// Access the resource to which we will associate.
auto associateToItem = this->parameters()->findResource("associate to");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment