unipdf/pdf/model/model.go

56 lines
1.3 KiB
Go
Raw Normal View History

/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE.md', which is part of this source code package.
*/
package model
import (
. "github.com/unidoc/unidoc/pdf/core"
)
// A PDFModel is a higher level PDF construct which can be collapsed into a PDF primitive.
// Each PDFModel has an underlying Primitive and vice versa.
// Copies can be made, but care must be taken to do it properly.
type PdfModel interface {
ToPdfObject() PdfObject
GetContainingPdfObject() PdfObject
}
/*
type ModelManager struct {
primitiveCache map[PdfModel]PdfObject
modelCache map[PdfObject]PdfModel
}
func NewModelManager() *ModelManager {
mm := ModelManager{}
mm.primitiveCache = map[PdfModel]PdfObject{}
mm.modelCache = map[PdfObject]PdfModel{}
return &mm
}
// Register (cache) a model to primitive relationship.
func (this *ModelManager) Register(primitive PdfObject, model PdfModel) {
this.primitiveCache[model] = primitive
this.modelCache[primitive] = model
}
func (this *ModelManager) GetPrimitiveFromModel(model PdfModel) PdfObject {
primitive, has := this.primitiveCache[model]
if !has {
return nil
}
return primitive
}
func (this *ModelManager) GetModelFromPrimitive(primitive PdfObject) PdfModel {
model, has := this.modelCache[primitive]
if !has {
return nil
}
return model
}
*/