/*******************************************************************************
** Copyright (c) 1992-2025 MAK Technologies, Inc
** All rights reserved.
*******************************************************************************/
//! \file xmlFileReader.h
//! \ingroup omtReader
#pragma once



#include <omtReader/omtReader.h>
#include <vlutil/vlString.h>

//! XML Tag Definitions
#include <mtl/xmlFedTags.h>
#include <mtl/fedReader.h>
#ifdef DtUSE_UTILITIES_NAMESPACE
namespace DtUSE_UTILITIES_NAMESPACE
{
#endif
class DtOMTTree;
class DtComplexComponentNode;
class DtEnumerationNode;
class DtAttributeFedNode;
class DtParameterFedNode;
class DtObjectClassFedNode;
class DtInteractionClassFedNode;
class DtFieldComponentNode;
class DtAlternativeComponentNode;
class DtExerciseConn;

class DT_DLL_OMTREADER DtXMLFileReader
{

public: 

   //! default constructor
   DtXMLFileReader();
   
   //! destructor
   virtual ~DtXMLFileReader();

   //! This creates an OMT tree from a file.
   //! The exercise connection (if not 0) is used to initialize RTI handles
   //! Ownership of this tree is passed to the person who called this function
   virtual DtOMTTree* readFile(const DtFilename& str, DtExerciseConn* ex = 0);

   //! Create an OMT tree from the give files. Expect the given fom type or try to determine it if given type is invalid.
   //! The exercise connection (if not 0) is used to initialize RTI handles
   //! Ownership of this tree is passed to the person who called this function
   virtual DtOMTTree* readFiles(const std::vector<DtFilename>& str, DtFomType fomTypeToUse=DtFomInvalid, DtExerciseConn* ex = 0);

   virtual const DtString& getLastError();
   virtual void clearLastError();

   bool isEvolvedFormat(const DtString& fileName);
   static bool isEvolvedFormat(xmlNodePtr& rootNode);
   static xmlNode*  getNodeByName( xmlNode*  rootNode,
      const xmlChar* nodeName );
   static const xmlChar* childContentByName(xmlNode* node,
      const xmlChar *name);
	  
   virtual void includeMIM(bool inc);
   virtual bool MIMincluded();

public:

   // Parse the contents of the given buffer into the provided xml doc tree.
   static DtFedReadStatus parseBuffer(const char* buffer, int size, xmlDocPtr* newXmlDocTree, DtString& lastError);

   // Parse the contents of the given file into the provided xml doc tree.
   static DtFedReadStatus parseFile(const char *fedFileName,
      xmlDoc  **newXmlDocTree, DtString& lastError);

protected:
   
protected:
   DtString myLastError;
   DtExerciseConn* myExConn;
   std::vector<DtOMTTree*> myOMTTrees;
   bool MIM;

private:
   
   //! Copy Constructor
   DtXMLFileReader(const DtXMLFileReader& orig);
   
   //! Assignment Operator
   DtXMLFileReader& operator=(const DtXMLFileReader& rhs);

   //! Setup the tree handles.
   void buildTree(DtOMTTree* omtTree);
   void setAttributeHandles(DtObjectClassFedNode* objNode);
   void setParameterHandles(DtInteractionClassFedNode* objNode);

};



#ifdef DtUSE_UTILITIES_NAMESPACE
} // end of namespace DtUSE_UTILITIES_NAMESPACE
#endif
