Add length deferrer support to composer

This commit is contained in:
Adam Jensen 2018-05-13 10:27:38 -04:00
parent 55f99cb34a
commit d40c50f80a
2 changed files with 30 additions and 10 deletions

View File

@ -16,6 +16,8 @@ type StoreComposer struct {
GetReader GetReaderDataStore GetReader GetReaderDataStore
UsesConcater bool UsesConcater bool
Concater ConcaterDataStore Concater ConcaterDataStore
UsesLengthDeferrer bool
LengthDeferrer LengthDeferrerDataStore
} }
// NewStoreComposer creates a new and empty store composer. // NewStoreComposer creates a new and empty store composer.
@ -45,6 +47,9 @@ func newStoreComposerFromDataStore(store DataStore) *StoreComposer {
if mod, ok := store.(ConcaterDataStore); ok { if mod, ok := store.(ConcaterDataStore); ok {
composer.UseConcater(mod) composer.UseConcater(mod)
} }
if mod, ok := store.(LengthDeferrerDataStore); ok {
composer.UseLengthDeferrer(mod)
}
return composer return composer
} }
@ -90,6 +95,12 @@ func (store *StoreComposer) Capabilities() string {
} else { } else {
str += "✗" str += "✗"
} }
str += ` LengthDeferrer: `
if store.UsesLengthDeferrer {
str += "✓"
} else {
str += "✗"
}
return str return str
} }
@ -120,3 +131,8 @@ func (store *StoreComposer) UseConcater(ext ConcaterDataStore) {
store.UsesConcater = ext != nil store.UsesConcater = ext != nil
store.Concater = ext store.Concater = ext
} }
func (store *StoreComposer) UseLengthDeferrer(ext LengthDeferrerDataStore) {
store.UsesLengthDeferrer = ext != nil
store.LengthDeferrer = ext
}

View File

@ -31,6 +31,7 @@ type StoreComposer struct {
USE_FIELD(Locker) USE_FIELD(Locker)
USE_FIELD(GetReader) USE_FIELD(GetReader)
USE_FIELD(Concater) USE_FIELD(Concater)
USE_FIELD(LengthDeferrer)
} }
// NewStoreComposer creates a new and empty store composer. // NewStoreComposer creates a new and empty store composer.
@ -50,6 +51,7 @@ func newStoreComposerFromDataStore(store DataStore) *StoreComposer {
USE_FROM(Locker) USE_FROM(Locker)
USE_FROM(GetReader) USE_FROM(GetReader)
USE_FROM(Concater) USE_FROM(Concater)
USE_FROM(LengthDeferrer)
return composer return composer
} }
@ -70,6 +72,7 @@ func (store *StoreComposer) Capabilities() string {
USE_CAP(Locker) USE_CAP(Locker)
USE_CAP(GetReader) USE_CAP(GetReader)
USE_CAP(Concater) USE_CAP(Concater)
USE_CAP(LengthDeferrer)
return str return str
} }
@ -85,3 +88,4 @@ USE_FUNC(Finisher)
USE_FUNC(Locker) USE_FUNC(Locker)
USE_FUNC(GetReader) USE_FUNC(GetReader)
USE_FUNC(Concater) USE_FUNC(Concater)
USE_FUNC(LengthDeferrer)