#if !defined(_INLINE)
static char cvsid[] = "@(#)$Id: ContextAdapter.cpp,v 1.3 1999/05/22 13:00:28 philogelos Exp $";
static char debugFileId[] = __FILE__;
#endif
#include "containers/dicts/DumbDictionary.hpp"
#include "algorithms/enumerations/EnumerationAlgorithms.hpp"
#include "ContextAdapter.hpp"
#include "LinkManager.hpp"
#include "OGuard.hpp"
#include "PGuard.hpp"
#include "Debug.hpp"
#include "String.hpp"
ContextAdapter::ContextAdapter()
{
LinkManager::reg( this, attributes = new DumbDictionary() );
}
ContextAdapter::~ContextAdapter()
{
LinkManager::free( this, attributes );
}
Top *ContextAdapter::getBy( Top *aKey ) const
{
OGuard _key( aKey, this );
return( attributes -> getValueAtKey( aKey ) );
}
Top *ContextAdapter::setBy( Top *aKey, Top *aValue )
{
OGuard _key( aKey, this );
OGuard _value( aValue, this );
if( isAt( aKey ) )
{
return( attributes -> setValueAtKey( aKey, aValue ) );
}
else
{
attributes -> addKey( aKey, aValue );
return nil;
}
}
boolean ContextAdapter::isAt( Top *aKey ) const
{
OGuard _key( aKey, this );
return( attributes -> isSuchKey( aKey ) );
}
boolean ContextAdapter::equals( const Top *anOther ) const
{
ContextAdapter *other;
other = DCAST( anOther, ContextAdapter );
OGuard _other( other, this );
if( other == ( ContextAdapter * ) NIL )
{
return false;
}
else
{
return( attributes -> equals( other -> attributes ) );
}
}
Top *ContextAdapter::clone() const
{
ContextAdapter *result;
result = new ContextAdapter();
PGuard _result( result, this );
EAlg::get() ->
add( result -> attributes, attributes -> getValueEnumeration() );
return result;
}
String ContextAdapter::toString() const
{
return Object::toString() + " attributes: " +
attributes -> toString();
}
String ContextAdapter::getString() const
{
return Object::getString() + " attributes: " +
attributes -> getString();
}
String ContextAdapter::getClassName() const
{
return "ContextAdapter";
}
#if defined(_INLINE)
#include "../src/Debug.ipp"
#endif