// XmlBaseElement.h: interface for the CXmlBaseElement class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(_XMLBASEELEMENT_H_)
#define _XMLBASEELEMENT_H_

#include <string>
#include <map>
#include "XmlSerializable.h"
#include "enums.h"
#include "cmString.h"

using namespace std;

class CXmlBaseElement;

typedef map<cmString, CXmlBaseElement*> XmlElementMap;

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

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

	// get/set methods
	//
	cmString GetName() const;
	void SetName(const cmString& name);
	
	cmString GetDescription() const;
	void SetDescription(const cmString& description);
	
	enDataType GetDataType() const;
	void SetDataType(enDataType dataType);

	cmString GetId() const;
	void SetId(const cmString& id);

	cmString GetPath() const;
	void SetPath(const cmString& path);

	static cmString GetXmlNodeName() {return _T("BaseInfo");}	

	static cmString DataType2String(enDataType dataType);
	static cmString ValidationMode2String(enValidationMode validationMode);
	static cmString RenderingMode2String(enRenderingMode renderingMode);
	static cmString Cardinality2String(enCardinality cardinality);
	
	static cmString LongMemberDisplayMode2String(enLongMemberDisplayMode displayMode);
	static cmString StringMemberDisplayMode2String(enStringMemberDisplayMode displayMode);
	static cmString DoubleMemberDisplayMode2String(enDoubleMemberDisplayMode displayMode);
	static cmString BooleanMemberDisplayMode2String(enBooleanMemberDisplayMode displayMode);

protected:
	
	virtual void Clear();
	virtual void SetDefaults();
	virtual cmString EscapeToXml(const cmString& str);
	virtual cmString EscapeToPlainText(const cmString& str);

	cmString name_;				// name of the element
	cmString description_;		// description of the element
	enDataType dataType_;		// data type of the element
	cmString id_;					// unique key of the element
	cmString path_;				// used for debug


};

#endif // !defined(_XMLBASEELEMENT_H_)
