#include "ComponentTraverseInfo.h"

namespace AMDiS {
  const int SingleComponentInfo::EMPTY = 0;
  const int SingleComponentInfo::EQ_SPACES_NO_AUX = 1;
  const int SingleComponentInfo::EQ_SPACES_WITH_AUX = 2;
  const int SingleComponentInfo::EQ_SPACES_WITH_DIF_AUX = 3;
  const int SingleComponentInfo::DIF_SPACES_NO_AUX = 4;
  const int SingleComponentInfo::DIF_SPACES_WITH_AUX = 5;
  const int SingleComponentInfo::DIF_SPACES_WITH_DIF_AUX = 6;

  void SingleComponentInfo::updateStatus()
  {
    if (rowFESpace == NULL) {
      status = SingleComponentInfo::EMPTY;
      return;
    }

    if (colFESpace == NULL || 
	(colFESpace != NULL && rowFESpace->getMesh() == colFESpace->getMesh())) {
      if (auxFESpaces.size() == 0) {
	status = SingleComponentInfo::EQ_SPACES_NO_AUX;
      } else {
	status = SingleComponentInfo::EQ_SPACES_WITH_AUX;
	for (int i = 0; i < static_cast<int>(auxFESpaces.size()); i++) {
	  if (auxFESpaces[i]->getMesh() != rowFESpace->getMesh()) {
	    status = SingleComponentInfo::EQ_SPACES_WITH_DIF_AUX;
	    break;
	  }
	}
      }
    } else {
      if (auxFESpaces.size() == 0) {
	status = SingleComponentInfo::DIF_SPACES_NO_AUX;
      } else {
	status = SingleComponentInfo::DIF_SPACES_WITH_AUX;
	for (int i = 0; i < static_cast<int>(auxFESpaces.size()); i++) {
	  if (auxFESpaces[i]->getMesh() != rowFESpace->getMesh() &&
	      auxFESpaces[i]->getMesh() != colFESpace->getMesh()) {
	    status = SingleComponentInfo::DIF_SPACES_WITH_DIF_AUX;
	    break;
	  }
	}
      }	
    }    
  }

}