/******************************************************************************
** Copyright (C) 2001, University of Alabama in Huntsville. 
** All rights reserved.
**
** File   : CRelation.cpp
**
** Author : David Phillips
**
** Description:
**    This file provides implementation for the CRelation
**    class.
**
** History:
** 24-Nov-2001 : David Phillips
**    Created file.
** 02-Dec-2001 : Satish Hota
**    * Initialized m_pType and m_pToArc to NULL in the constructor.
**    * Implemented the AddArc method.  Adding input concepts to the m_ArcList
**      vector.
**    * Added and implemented GetFromArcs and GetToArc methods.
******************************************************************************/

//## begin module%1.4%.codegen_version preserve=yes
//   Read the documentation to learn more about C++ code generator
//   versioning.
//## end module%1.4%.codegen_version

//## begin module%3BE226E400F0.cm preserve=no
//	  %X% %Q% %Z% %W%
//## end module%3BE226E400F0.cm

//## begin module%3BE226E400F0.cp preserve=no
//## end module%3BE226E400F0.cp

//## Module: CRelation%3BE226E400F0; Pseudo Package body
//## Source file: C:\Documents and Settings\dphillips.PORTABLE\Desktop\CS650\ConGraT\CGEngine\CRelation.cpp

//## begin module%3BE226E400F0.additionalIncludes preserve=no
//## end module%3BE226E400F0.additionalIncludes

//## begin module%3BE226E400F0.includes preserve=yes
//## end module%3BE226E400F0.includes

// CRelation
#include "CGEngine\CRelation.h"
//## begin module%3BE226E400F0.additionalDeclarations preserve=yes
//## end module%3BE226E400F0.additionalDeclarations


// Class CRelation 

CRelation::CRelation()
  //## begin CRelation::CRelation%3BE226E400F0_const.hasinit preserve=no
  //## end CRelation::CRelation%3BE226E400F0_const.hasinit
  //## begin CRelation::CRelation%3BE226E400F0_const.initialization preserve=yes
  //## end CRelation::CRelation%3BE226E400F0_const.initialization
{
  //## begin CRelation::CRelation%3BE226E400F0_const.body preserve=yes
  //## end CRelation::CRelation%3BE226E400F0_const.body
	m_pType = NULL;
	m_pToArc = NULL;
}

CRelation::CRelation(const CRelation &right)
  //## begin CRelation::CRelation%3BE226E400F0_copy.hasinit preserve=no
  //## end CRelation::CRelation%3BE226E400F0_copy.hasinit
  //## begin CRelation::CRelation%3BE226E400F0_copy.initialization preserve=yes
  //## end CRelation::CRelation%3BE226E400F0_copy.initialization
{
  //## begin CRelation::CRelation%3BE226E400F0_copy.body preserve=yes
  //## end CRelation::CRelation%3BE226E400F0_copy.body
}


CRelation::~CRelation()
{
  //## begin CRelation::~CRelation%3BE226E400F0_dest.body preserve=yes
  //## end CRelation::~CRelation%3BE226E400F0_dest.body
}


void CRelation::AddArc(CConcept* pArc)
{
    if(m_pToArc)
	{
		m_FromArcList.push_back(m_pToArc);
	}
	m_pToArc = pArc;
	pArc->AddRelation(this);
}

CRelation & CRelation::operator=(const CRelation &right)
{
  //## begin CRelation::operator=%3BE226E400F0_assign.body preserve=yes
	throw ACConstruct::Not_Implemented_Yet();
  //## end CRelation::operator=%3BE226E400F0_assign.body
}


int CRelation::operator==(const CRelation &right) const
{
  //## begin CRelation::operator==%3BE226E400F0_eq.body preserve=yes
	throw ACConstruct::Not_Implemented_Yet();
  //## end CRelation::operator==%3BE226E400F0_eq.body
}

int CRelation::operator!=(const CRelation &right) const
{
  //## begin CRelation::operator!=%3BE226E400F0_neq.body preserve=yes
	throw ACConstruct::Not_Implemented_Yet();
  //## end CRelation::operator!=%3BE226E400F0_neq.body
}



//## Other Operations (implementation)
void CRelation::Change_Type ()
{
  //## begin CRelation::Change_Type%3BE22F4B0085.body preserve=yes
	throw ACConstruct::Not_Implemented_Yet();
  //## end CRelation::Change_Type%3BE22F4B0085.body
}

void CRelation::Copy ()
{
  //## begin CRelation::Copy%3BE2315401C4.body preserve=yes
	throw ACConstruct::Not_Implemented_Yet();
  //## end CRelation::Copy%3BE2315401C4.body
}

void CRelation::Replace(CConcept* pOriginalConcept, CConcept* pWithConcept)
{
	if (pOriginalConcept == m_pToArc)
	{
		m_pToArc->RemoveRelation(this);
		m_pToArc = pWithConcept;
		pWithConcept->AddRelation(this);
		return;
	}

	for(int i=0;i<m_FromArcList.size();i++)
	{
		if(pOriginalConcept == m_FromArcList[i])
		{
			m_FromArcList[i]->RemoveRelation(this);
			m_FromArcList[i] = pWithConcept;
			pWithConcept->AddRelation(this);
			return;
		}
	}
}

void CRelation::Simplify ()
{
  //## begin CRelation::Simplify%3BE2315401CE.body preserve=yes
	throw ACConstruct::Not_Implemented_Yet();
  //## end CRelation::Simplify%3BE2315401CE.body
}

// Additional Declarations
  //## begin CRelation%3BE226E400F0.declarations preserve=yes
  //## end CRelation%3BE226E400F0.declarations

//## begin module%3BE226E400F0.epilog preserve=yes
//## end module%3BE226E400F0.epilog

const CConcept::ConceptVector* CRelation::GetFromArcs()
{
    return &m_FromArcList;
}

CConcept* CRelation::GetToArc()
{
	return m_pToArc;
}
