/*
 *
 * [desc.]
 */
#include "Tools/Viewer/Parser/include/parser.h"
using namespace morpheo::tools::viewer::bdd;
namespace morpheo{
namespace tools{
namespace viewer{
namespace parser{     

  void Parse::parser_limitparam(QDomNode n){
       while( !n.isNull() )
      {
	QDomElement e = n.toElement();
	if( !e.isNull() )
	  {
	    
	    if (e.tagName() == "parameter" )
	      {
                #ifdef DBUG_PARSE
		cout << "parameter" <<endl;
		cout << e.attribute("name","").toStdString() <<endl;
		#endif
		limit=new morpheo::tools::viewer::bdd::LimitParam\
		  (e.attribute("name","").toStdString(),\
		   e.attribute("min","").toInt(0,10),\
		   e.attribute("max","").toInt(0,10),\
		   e.attribute("step","").toStdString(),\
		   e.attribute("default","").toInt(0,10),\
		   e.attribute("level","").toInt(0,10));
		
		//base->addLimitParam(limit);		
		parser_limitparam(n.firstChild());
		if( (n.nextSibling().toElement()).tagName()!= "group"){
		  base->addLimitParam(limit);		
		  delete limit;
		}
	      } 
	    if (e.tagName() == "group" )
	      {

		limit->setGroup(e.attribute("name","").toStdString());
		base->addLimitParam(limit);		
		delete limit;
		
	      }
	    if (e.tagName() == "link" )
	      {

		base->addLinksrc(e.attribute("name","").toStdString(),\
				 e.attribute("src","").toStdString());
		base->addLinkdest(e.attribute("name","").toStdString(),\
				 e.attribute("dest","").toStdString());
	      }
      
	  }
	n = n.nextSibling(); //next channel
	    
      }
      
  }

};//end parser
};//end viewer
};//end tools
};//end morpheo

