//-----------------------------------------------------------------------------
// Register everything
//-----------------------------------------------------------------------------
MStatus CVsMayaMPxFactoryBase::RegisterEverything( MFnPlugin &pluginFn )
{
	MStatus retVal;

	// Set the name & description of the CVsMayaMPxFactoryCommand making sure not to conflict with
	// an already existing command

	MString pluginCommandName( pluginFn.name() );

	bool nameOk( true );
	for ( const CVsMayaMPxFactoryBase *pFactory( s_pFirstFactory ); pFactory; pFactory = pFactory->m_pNextFactory )
	{
		if ( pFactory->GetName() == pluginCommandName )
		{
			pluginCommandName += "PluginInfo";
			nameOk = false;
			break;
		}
	}

	for ( int suffix( 0 ); !nameOk; nameOk = true, ++suffix )
	{
		for ( const CVsMayaMPxFactoryBase *pFactory( s_pFirstFactory ); pFactory; pFactory = pFactory->m_pNextFactory )
		{
			if ( pFactory->GetName() == pluginCommandName )
			{
				pluginCommandName += suffix;
				nameOk = false;
				continue;
			}
		}
	}

	CVsMayaMPxCommandDecorator< CVsMayaMPxFactoryCommand >::s_name = pluginCommandName;

	CVsMayaMPxCommandDecorator< CVsMayaMPxFactoryCommand >::s_desc =
		MString( "Displays information about and what's inside of the " ) + pluginFn.name() + " plugin.";

	for ( const CVsMayaMPxFactoryBase *pFactory( s_pFirstFactory ); pFactory; pFactory = pFactory->m_pNextFactory )
	{
		const MStatus regStat( pFactory->Register( pluginFn ) );

		if ( !regStat )
		{
			MGlobal::displayWarning(
				pluginFn.name() + ": Couldn't Register \"" + pFactory->GetName() + "\"" );
			retVal = regStat;
		}
	}

	return retVal;
}
//-----------------------------------------------------------------------------
// Deregister everything
//-----------------------------------------------------------------------------
MStatus CVsMayaMPxFactoryBase::DeregisterEverything( MFnPlugin &pluginFn )
{
	MStatus retVal;

	for ( const CVsMayaMPxFactoryBase *pFactory( s_pFirstFactory ); pFactory; pFactory = pFactory->m_pNextFactory )
	{
		const MStatus regStat( pFactory->Deregister( pluginFn ) );

		if ( !regStat )
		{
			MGlobal::displayWarning(
				pluginFn.name() + ": Couldn't Deregister \"" + pFactory->GetName() + "\"" );
			retVal = regStat;
		}
	}

	return retVal;
}