#include "metadataBase.h"
#include "metadataPluginStrings.h"
#include <maya/MArgList.h>
#include <maya/MSyntax.h>
#include <maya/MSelectionList.h>
#include <maya/MFileObject.h>
#include <maya/adskDataAssociationsSerializer.h>
static const char* flagFile ( "-f" );
static const char* flagFileLong ( "-file" );
static const char* flagMetadataFormat ( "-mf" );
static const char* flagMetadataFormatLong ( "-metadataFormat" );
{
return syntax;
}
metadataBase::metadataBase()
: fMode(kCreate)
, fObjects()
{
}
metadataBase::~metadataBase()
{
delete fFile;
}
bool metadataBase::isUndoable() const
{
return false;
}
bool metadataBase::hasSyntax() const
{
return true;
}
{
{
{
displayError(msg);
return MS::kFailure;
}
fMode = kEdit;
}
{
fMode = kQuery;
}
fFileFlag.parse(argsDb, flagFile);
if( !fFileFlag.isModeValid(fMode) )
{
displayError(msg);
return MS::kFailure;
}
if( fFileFlag.isSet() )
{
if( ! fFileFlag.isArgValid() )
{
msg.
format( fmt, flagFileLong );
displayError(msg);
return MS::kFailure;
}
fFile->setRawFullName( fFileFlag.arg() );
}
fMetadataFormatFlag.parse(argsDb, flagMetadataFormat);
if( !fMetadataFormatFlag.isModeValid(fMode) )
{
displayError(msg);
return MS::kFailure;
}
formatType = fMetadataFormatFlag.arg( rawFormatType );
fSerializer = AssociationsSerializer::formatByName( formatType.
asChar() );
if( ! fSerializer )
{
displayError(msg);
status = MS::kNotFound;
return MS::kFailure;
}
MStatError(status, "argsDb.getObjects()");
for (
unsigned int i = 0; i<objects.
length(); ++i)
{
MStatError(status, "objects.getDependNode()");
fObjects.append( dgNode );
}
if( (fObjects.length() == 0) && (fMode != kQuery) )
{
displayError(msg);
}
return status;
}
{
if (MS::kSuccess != status) return status;
status = checkArgs(argsDb);
if( MS::kSuccess == status )
{
clearResult();
switch (fMode)
{
case kCreate: status = doCreate(); break;
case kEdit: status = doEdit(); break;
case kQuery: status = doQuery(); break;
}
}
return status;
}
{
return MS::kSuccess;
}
{
return MS::kSuccess;
}
{
return MS::kSuccess;
}
{
return MS::kSuccess;
}
{
return MS::kSuccess;
}