#lang mzscheme
(require scheme/class)
(define cache<%>
(interface ()
clear-cache!))
(define entity-cache<%>
(interface (cache<%>)
id->entity
entity->id))
(define attribute-cache<%>
(interface (cache<%>)
id->attribute
attribute->id))
(define cache-mixin
(mixin () (entity-cache<%> attribute-cache<%>)
(init-field entity-cache)
(init-field attribute-cache)
(super-new)
(define/public (id->entity id)
(send entity-cache id->entity id))
(define/public (entity->id entity)
(send entity-cache entity->id entity))
(define/public (id->attribute id)
(send attribute-cache id->attribute id))
(define/public (attribute->id attr)
(send attribute-cache attribute->id attr))
(define/public (clear-cache!)
(send entity-cache clear-cache!)
(send attribute-cache clear-cache!))
(inspect #f)))
(provide entity-cache<%>
attribute-cache<%>
cache-mixin)