#if !defined(_INLINE)
static char cvsid[] = "@(#)$Id: MappedEnumeration.cpp,v 1.4 1999/05/22 13:00:56 philogelos Exp $";
static char debugFileId[] = __FILE__;
#endif
#include "iter/enumerations/MappedEnumeration.hpp"
#include "Debug.hpp"
#include "OGuard.hpp"
#include "String.hpp"
#include "LinkManager.hpp"
MappedEnumeration::MappedEnumeration( Enumeration *aBase, Map *aMap ) :
en( aBase ),
map( aMap )
{
preC_( ( Top * ) aBase != null );
preC_( ( Top * ) aMap != null );
LinkManager::reg( this, getEnum() );
LinkManager::reg( this, getMap() );
}
MappedEnumeration::~MappedEnumeration()
{
LinkManager::free( this, getEnum() );
LinkManager::free( this, getMap() );
}
boolean MappedEnumeration::hasMoreElements()
{
return getEnum() -> hasMoreElements();
}
Top *MappedEnumeration::getNextElement()
{
Top *item;
Top *result;
item = getEnum() -> getNextElement();
OGuard _( item, this );
result = getMap() -> apply( item );
return result;
}
Enumeration *MappedEnumeration::getEnum() const
{
return en;
}
Map *MappedEnumeration::getMap() const
{
return map;
}
boolean MappedEnumeration::equals( const Top *anOther ) const
{
MappedEnumeration *other;
if( DCAST( anOther, MappedEnumeration ) == null )
{
return false;
}
other = DCAST( anOther, MappedEnumeration );
return ( other -> getMap() -> equals( getMap() ) &&
other -> getEnum() -> equals( getEnum() ) );
}
Top *MappedEnumeration::clone() const
{
return new MappedEnumeration( getEnum(), getMap() );
}
String MappedEnumeration::getString() const
{
return String( " enum: ``" ) + getEnum() -> getString() +
"'' map: ``" + getMap() -> getString() + "''";
}
String MappedEnumeration::getClassName() const
{
return "MappedEnumeration";
}
#if defined(_INLINE)
#include "../src/Debug.ipp"
#endif
#if defined(_INLINE)
#include "../src/String.ipp"
#endif