#include "Node.h"
/******************************************************************************/
/* --- defaultni konstruktor --- */
     Node::Node(){
  Low = High = NULL;
  varId = 0;
  nodeId = idCount++;

}
/******************************************************************************/
/* --- konstruktor s parametry --- */
    Node :: Node(int vid, Node * l, Node * h){
  Low = l;
  High = h;
  varId = vid;
  nodeId = idCount++;

}
/******************************************************************************/
/* --- funkce pro "premosteni" uzlu --- */
/* --- this->Low a/nebo this->High ukazujici na child premosti na newNode --- */

void Node::bypass(Node * child,Node * newNode){

if(Low == child) Low = newNode;
if(High == child) High = newNode;

}

/******************************************************************************/
/* --- funkce vypisujici informace o uzlu do streamu out --- */
/* --- je virtualni - pretizena u terminalu --- */
/* --- vraci vystupni proud --- */

ostream& Node::printInfo(ostream& out)const{
  out << "Neterminalni uzel s ID " << nodeId << endl;
  out << "    odpovidajici promena : " << varId << endl;
  if(Low==NULL)  out << "    Low potomek je NULL" << endl;
        else  out << "    Low potomek ma id: " << Low->nodeId << endl;
  if(High==NULL)  out << "    High potomek je NULL" << endl;
              else  out << "    High potomek ma id: " << High->nodeId << endl;

return out;
}
/******************************************************************************/
/* --- pretizeny operator vystupu do proudu --- */
/* --- vola funkci pro vypis informaci o uzlu --- */

ostream& operator<<(ostream & out,const Node & n){

   return n.printInfo(out);

  }

/******************************************************************************/
/* --- funkce pro rekurzivni vypis informaci o uzlu --- */
/* --- vypisi se informace o Low, High potomkovi(pokud existuje), pak o sobe --- */

ostream& Node::recurs_print(ostream &out){

 if(Low!=NULL) Low->recurs_print(out);
 if(High!=NULL) High->recurs_print(out);
 return printInfo(out);

}
/******************************************************************************/
/* --- inicializace staticke tridni promene --- */

unsigned int Node::idCount =0;


