// XmlClassInfo.h: interface for the CXmlClassInfo class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(_XMLCLASSINFO_H_)
#define _XMLCLASSINFO_H_

#include <map>
#include <string>
#include "XmlBaseElement.h"
#include "XmlGuiCategoryInfoList.h"
#include "XmlGuiGridInfo.h"
#include "XmlFormInfo.h"
#include "XmlClassCardinality.h"
#include "XmlTreeIcons.h"

using namespace std;

typedef map<cmString, CXmlBaseElement*> ClassMemberMap;

class CXmlClassInfo : public CXmlBaseElement
{
public:
	CXmlClassInfo();
	virtual ~CXmlClassInfo();

	// implementation of XmlBaseElement
	//
	virtual bool BuildFromXml(IXMLDOMNode* node);
	virtual bool AppendToDOMDocument(IXMLDOMDocument2* xmlDoc, IXMLDOMElement* parentElement);

	// children management
	//
	ClassMemberMap* GetMembers();
	void GetMembers(ClassMemberMap& members, enDataType dataType = enDataType_None, bool recursive = true);
	
	CXmlBaseElement* AddMember(enDataType dataType);

	bool AttachMember(CXmlBaseElement* member);
	CXmlBaseElement* DetachMember(const cmString& id);

	void RemoveMemberById(const cmString& id);
	void RemoveMember(const cmString& name);
	CXmlBaseElement* GetMember(const cmString& name, 
							   enDataType dataType = enDataType_None, 
							   bool recursive = false);
	CXmlBaseElement* GetMemberById(const cmString& id, bool recursive = true);

	int GetMemberCount(enDataType dataType = enDataType_None);
	
	static cmString GetXmlNodeName() {return _T("ClassInfo");}

	// properties get/set
	//
	void SetCaption(const cmString& caption);
	cmString GetCaption() const;

	void SetContainerCaption(const cmString& containerCaption);
	cmString GetContainerCaption() const;

	void SetRenderingMode(enRenderingMode renderingMode);
	enRenderingMode GetRenderingMode();

	// definition inheritance management
	//
	bool GetDefinitionInheritance() const;
	void SetDefinitionInheritance(bool inheritance);

	bool GetLockedByInheritance() const;
	void SetLockedByInheritance(bool locked);

	cmString GetInherithClassId() const;
	void SetInherithClassId(const cmString& classId);

	cmString GetAtlClassGuid() const;
	void SetAtlClassGuid(const cmString& guid);

	cmString GetAtlInterfaceGuid() const;
	void SetAtlInterfaceGuid(const cmString& guid);

	bool CanInheritDefinition();

	CXmlGuiCategoryInfoList* GetCategoryInfoList();
	CXmlFormInfo* GetForm();
	CXmlClassCardinality* GetCardinalityInfo();
	CXmlGuiGridInfo* GetGridInfo();

	virtual void Clear();
	virtual void ClearAllGuids(bool recurse = true);

	// tree icons 
	//
	CXmlTreeIcons* GetTreeIcons();
	CXmlTreeIcons* GetMapTreeIcons();
	CXmlTreeIcons* GetArrayTreeIcons();

	void SetExpandedAtStartup(bool expanded, bool recursive = false);

protected:
	
	virtual void SetDefaults();

	ClassMemberMap members_;

	cmString caption_;
	cmString containerCaption_;	// container caption(used when cardinality is "map" or "array")

	// rendering
	//
	enRenderingMode renderingMode_;
	CXmlGuiCategoryInfoList categoryList_;
	CXmlGuiGridInfo gridInfo_;
	CXmlClassCardinality cardinality_;
	CXmlFormInfo form_;

	bool definitionInheritance_;
	cmString inherithClassId_;
	bool lockedByInheritance_;

	CXmlTreeIcons treeIcons_; 
	CXmlTreeIcons mapTreeIcons_;
	CXmlTreeIcons arrayTreeIcons_;

	cmString atlClassGuid_;
	cmString atlInterfaceGuid_;

};

#endif // !defined(_XMLCLASSINFO_H_)
