text: #include "TTranslationTable.h"
  
  TTranslationTable::TTranslationToken::TTranslationToken (const TString token, const TLeafName* leafName)
  	: fToken (token)
  {
  	fLeafName = leafName;
  }
  								
  void TTranslationTable::TTranslationToken::Copy (const TObject& obj)
  {
  	CHECK (Class () == obj.Class ());
  	
  	const TTranslationToken& token = (const TTranslationToken&)obj;
  	
  	fToken.Copy (token.fToken);
  	fLeafName = token.fLeafName;
  }
  
  TTranslationTable::TTranslationToken& TTranslationTable::TTranslationToken::operator = (const TTranslationToken& token)
  {
  	fToken = token.fToken;
  	fLeafName = token.fLeafName;
  	return (*this);
  }
  
  void TTranslationTable::AddToken (const TString& token, const TString& leafName)
  {
  	CHECK_ (!IsLeaf (token));
  	CHECK_ (!IsToken (token));
  	CHECK_ (IsLeaf (leafName));
  	CHECK_ (!IsToken (leafName));
  	
  	TLeafName toFind (leafName);
  	TLeafName* item = NULL;
  	fTaxaBlock.fBTree.FindItem ((const TObject&)toFind, (const TObject*&)item);
  	
  	fTranslationTokens.AddItem (new TTranslationToken (token, item));
  }
  
  bool TTranslationTable::IsToken (const TString& token) const
  {
  	TTranslationToken item (token);
  	return (fTranslationTokens.FindItem (item));
  }
  
  unsigned int TTranslationTable::GetLeafNumber (const TString& leafName) const
  {
  	if (IsLeaf (leafName))
  		return (fTaxaBlock.GetLeafNumber (leafName));
  		
  	const TTranslationToken token (leafName);
  	const TTranslationToken* item = NULL;
  	if (fTranslationTokens.FindItem ((const TObject&)token, (const TObject*&)item))
  		return (item->GetLeafNumber ());
  	return (0);
  }
  
  TTranslationTable::TTranslationTable (TTaxaBlock& taxaBlock)
  	: fTaxaBlock (taxaBlock)
  {
  }
  
  TTranslationTable::~TTranslationTable (void) 
  { 
  }
  
  