Skip to content

Data Utils

Popax21 edited this page Sep 1, 2022 · 6 revisions

Composite(Async)DataProcessor<T, I, D>

Implements an I(Async)DataProcessor<T, I, D> which combines a list of other data processors by invoking them in a row and chaining their results. Processors can be added using AddProcessor, and are invoked in increasing value of their order parameter.

Delegate(Async)DataProcessor<T, I, D>

Implements an I(Async)DataProcessor<T, I, D> which simply invokes a set of delegates it's given. Does nothing if null is used instead of a delegate.

ConstantDataProcessor<T, I, D>

Implements an IDataProcessor<T, I, D> which replaces any data with a constant value. Optionally disposes the old data if it implements IDisposable.

(Async)DataProcessorFilter<T, I, D>

Implements an I(Async)DataProcessor<T, I, D> which proxies to another processor if a given filter function returns true, otherwise does nothing. Can be used to filter out what targets a processor should affect.

AsyncProcessorWrapper<T, I, D>

Implements an IAsyncDataProcessor<T, I, D> which wraps a synchronous IDataProcessor<T, I, D>

ScopedObjectRegistrar<T>

A singleton which implements an IScopeRegistrar<T> which calls IScopedObject.RegisterScopes if the target implements this interface.

DataCache<T, D>

The base caching class of Procedurline. Allows one to cache so called "scoped data" of type D, which is associated with a target of type T, and whose scope keys are registered using a given IScopeRegistrar<T> instance. The scoped data can be retrieved using the GetScopedData method, and is automatically disposed once the associated key becomes invalid. It's possible to provide a custom key factory method by overwriting CreateKey, which can be used to use custom DataScopeKey subclasses.

When GetScopedData is given a scope key as an argument, it will also register all scopes it belongs to on the scope key used for caching using DataScopeKey.RegisterScopes. The intended use case of this mechanism is to account for the fact that the original data which was used to derive the cached data could have been processed before as well, like it would be the case if a cache is inserted as part of a bigger processor chain. As such, when providing a key which has scopes accounting for the validity of this original data, the cache will handle an invalidation of this original data the same as it would an invalidation of the cached data, ensuring no stale data remains in the cache.

(Async)DataProcessorCache<T, I, D> are subclasses which cache a specific I(Async)DataProcessor<T, I, D> instance. SpriteAnimationCache is an implementation which specializes in caching sprite animations.

DataScopeMultiplexer<T>

An abstract IScopeRegistrar<T> implementation which can be used to efficiently multiplex between different ways of treating data on the fly. It works by creating one transparent "mux" scope, and a non-transparent "index" scope for every valid multiplexing index. It then registers both the global mux scope and the index scope corresponding to the currently active index on the key.

When MuxIndex (the property holding the currently active multiplexer index) gets assigned, it invalidates the mux scope's registrars, which causes all keys to be re-registered on the new index scope. An index scope can be invalidated if that specific index will be treated differently in the future.

(Async)DataProcessorMultiplexer<T, I, D> are implementations of this class which multiplex between different I(Async)DataProcessor<T, I, D>s. They also allow one to change an index's processor at runtime. When a processor index is set to null, it will not do anything.

Another implementation of the class is SpriteMultiplexer.