#ifndef _MAttributePattern
#define _MAttributePattern
//-
// ==========================================================================
// Copyright (C) 1995 - 2011 Autodesk, Inc., and/or its licensors.  All
// rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its
// licensors,  which is protected by U.S. and Canadian federal copyright law
// and by international treaties.
//
// The Data may not be disclosed or distributed to third parties or be
// copied or duplicated, in whole or in part, without the prior written
// consent of Autodesk.
//
// The copyright notices in the Software and this entire statement,
// including the above license grant, this restriction and the following
// disclaimer, must be included in all copies of the Software, in whole
// or in part, and all derivative works of the Software, unless such copies
// or derivative works are solely in the form of machine-executable object
// code generated by a source language processor.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
// AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED
// WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF
// NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
// OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO
// EVENT WILL AUTODESK AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST
// REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR
// CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS LICENSORS HAS
// BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.
// ==========================================================================
//+
//
// CLASS:    MAttributePattern
//
// ****************************************************************************

#if defined __cplusplus

// ****************************************************************************
// INCLUDED HEADER FILES

#include <maya/MTypes.h>
#include <maya/MObject.h>
#include <maya/MStatus.h>
#include <maya/MString.h>

// ****************************************************************************
// CLASS DECLARATION (MAttributePattern)

//! \ingroup OpenMaya
//! \brief The pattern of an attribute tree that can be applied to nodes or node classes
/*!
Class that provides a pattern of attributes to be applied to nodes as
dynamic attributes or to node classes as extension attributes.

An attribute pattern is a pattern describing an attribute tree. In the simplest
implementation it can just store an internal copy of the tree to be applied.
The code to apply the attribute patterns will use the rootAttr() and
rootAttrCount() methods to iterate through the list of top level attributes to
be applied.  It presumes that if they are compounds then their children will
already be parented properly.

\code
	for( unsigned int i=0; i < tmpl.rootAttrCount(); ++i )
	{
		applyAttributesToNodes( tmpl.rootAttr(i), someNode );
	}
\endcode

When creating the pattern from inside MPxAttributePatternFactory you add
only the root level attributes, i.e. the attributes without parents. As
a simple example if your pattern factory has data that specifies creating
a pattern with one integer attribute and one compound with three float
children the code would like something like this.

\code
	MStatus status;

	MFnCompoundAttribute parentAttr;
	MObject parentObj1 = parentAttr.create( "parent", "par", &status );

	MFnNumericAttribute childAttrX;
	MFnNumericAttribute childAttrY;
	MFnNumericAttribute childAttrZ;
	MObject childObjX = childAttrX.create( "childX", "cx" MFnNumericData::kFloat, 0, &status );
	MObject childObjY = childAttrY.create( "childY", "cy" MFnNumericData::kFloat, 0, &status );
	MObject childObjZ = childAttrZ.create( "childZ", "cz" MFnNumericData::kFloat, 0, &status );
	parentAttr.addChild( childObjX );
	parentAttr.addChild( childObjY );
	parentAttr.addChild( childObjZ );

	MFnNumericAttribute otherParent;
	MObject parentObj2 = otherParent.create( "intValue", "iv" MFnNumericData::kInt, 0, &status );

	// Note that you only add the top-level attributes to the pattern,
	// not the children.
	MAttributePattern* tmpl = new MAttributePattern("myPattern");
	return ( (tmpl->addRootAttr( parentObj1 ) == MS::kSuccess)
		&&   (tmpl->addRootAttr( parentObj2 ) == MS::kSuccess) );
\endcode

*/
class OPENMAYA_EXPORT MAttributePattern
{
public:
	MAttributePattern	();
	MAttributePattern	( const MString& name );
	MAttributePattern	( const MAttributePattern& rhs );
	MAttributePattern& operator=( const MAttributePattern& rhs );
	bool operator==( const MAttributePattern& rhs ) const;
	~MAttributePattern	();

	static MAttributePattern*	findPattern		(const MString& name);
	static unsigned int			attrPatternCount	();
	static MAttributePattern*	attrPattern		(unsigned int n);

public:
	MString			name			(MStatus* ReturnStatus = NULL) const;
	unsigned int 	rootAttrCount	(MStatus* ReturnStatus = NULL) const;
	MObject	  		rootAttr		(unsigned int idx, MStatus* ReturnStatus = NULL) const;

	MStatus	  		removeRootAttr	(unsigned int idx);
	MStatus	  		removeRootAttr	(const MObject& attr);
	MStatus			addRootAttr		(const MObject& attr);

	static const char* className();

protected:
	void*			fAttributePattern;
	MAttributePattern	( void* mayaAttributePattern );
};

#endif /* __cplusplus */
#endif /* _MAttributePattern */
