DogEngine class
Registry and interface for everything related to dogs.
- Mixed-in types
- Available extensions
Constructors
- DogEngine.new({bool registerBaseConverters = true, DogNativeCodec codec = const DefaultNativeCodec()})
-
Creates a new DogEngine instance.
If
registerBaseConverters
is true, the following converters will be registered:
Properties
-
allAssociatedConverters
→ Map<
Type, DogConverter> -
Returns all DogConverters registered in this DogEngine instance and its
parents.
no setter
-
allConverters
→ List<
DogConverter> -
Returns all converters registered in this DogEngine instance and its
parents.
no setter
-
allStructures
→ Map<
String, DogStructure> -
Returns all DogStructures registered in this DogEngine instance and its
parents.
no setter
-
allTreeBaseFactories
→ Map<
TypeCapture, TreeBaseConverterFactory> -
Returns all OperationModeFactorys registered in this DogEngine instance
and its parents.
no setter
- codec → DogNativeCodec
-
The DogNativeCodec used by this DogEngine instance.
See DogNativeCodec for more details.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
metadata
→ Map<
Object, Object?> -
Returns a read-only map of all metadata entries.
no setterinherited
- modeRegistry ↔ OperationModeRegistry
-
The OperationModeRegistry used by this DogEngine instance.
See OperationModeRegistry for more details.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
{bool clearStructures = true}) → void - Fully clears the DogEngine instance, effectively resetting it to its initial state.
-
clearMeta(
) → void -
Clears all metadata entries.
inherited
-
close(
) → void - Closes this DogEngine instance and unregisters it from its parent.
-
convertIterableFromNative(
dynamic value, Type serialType, IterableKind kind) → dynamic -
Converts the
value
, which can be either a Iterable or instance of the type associated withserialType
, depending on the IterableKind, to its native representation using the converter associated withserialType
. -
convertIterableToNative(
dynamic value, Type serialType, IterableKind kind) → dynamic -
Converts the
value
, which can be either a Iterable or instance of the type associated withserialType
, depending on the IterableKind, to its native representation using the converter associated withserialType
. -
convertObjectFromNative(
dynamic value, Type serialType) → dynamic -
Converts a
value
to its native representation using the converter associated withserialType
. -
convertObjectToNative(
dynamic value, Type serialType) → dynamic -
Converts a
value
to its native representation using the converter associated withserialType
. -
createProjection(
Type target, {Iterable< Map> ? properties, Iterable<Object> ? objects, Iterable<ProjectionTransformer> ? transformers, bool shallow = false}) → dynamic -
Available on DogEngine, provided by the ProjectionExtension extension
Creates a projection from the givenproperties
andobjects
using createProjectionDocument. Ifshallow
is true, the objects are not converted to their native representation, but instead their field map is used. The resulting document is then converted to the giventarget
type. -
createProjectionDocument(
{Iterable< Map> ? properties, Iterable<Object> ? objects, Iterable<ProjectionTransformer> ? transformers, bool shallow = false}) → Map<String, dynamic> -
Available on DogEngine, provided by the ProjectionExtension extension
Creates a projection document from the givenproperties
andobjects
. Theproperties
are merged into the document first, followed by theobjects
. Ifshallow
is true, the objects are not converted to their native representation, but instead their field map is used. Iftransformers
are given, they are applied to the document in order. -
describe<
T> ({SchemaConfig config = const SchemaConfig()}) → SchemaType -
Available on DogEngine, provided by the SchemaGenerateExtension extension
Generates a schema for the given typeT
. -
findAnnotationTranslation(
String id) → String? -
Returns the annotation override for the given
id
or null if not present. -
findAssociatedConverter(
Type type) → DogConverter? -
Returns the DogConverter that is associated with
type
or null if not present. -
findConverter(
Type type) → DogConverter? -
Returns the first registered DogConverter of the given
type
. -
findConverterBySerialName(
String name) → DogConverter? -
Returns the DogStructure that is associated with the serial name
name
-
findModeFactory(
Type type) → OperationModeFactory< OperationMode> ? -
Returns the OperationModeFactory that is associated with
type
or null if not present. -
findStructureBySerialName(
String name) → DogStructure? -
Returns the DogStructure that is associated with the serial name
name
or null if not present. -
findStructureByType(
Type type) → DogStructure? -
Returns the DogStructure associated with
type
. -
findTreeBaseFactory(
TypeCapture type) → TreeBaseConverterFactory? -
Returns the TreeBaseConverterFactory that is associated with
type
. -
fork(
{DogNativeCodec? codec, Symbol? identity, bool listen = true}) → DogEngine -
Creates a new DogEngine instance that is a child of this instance.
The DogNativeCodec will be inherited from this instance but can be
overridden by supplying a
codec
. Ifidentity
is specified, the child will be associated with the givenidentity
Symbol. Iflisten
is set to false, changes in the parent will not rebuild the child, already cached converters in the child will therefore persist, otherwise, the child will have its caches cleared so future calls access the parents updated state. -
fromFieldMap<
T> (Map< String, dynamic> fieldMap, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → T -
Available on DogEngine, provided by the DogEngineShortcuts extension
Converts a field map to an instance ofT
using the structure associated withT
ortype
and the supplied IterableKind. Iftree
is supplied, the structure associated with the tree is used. -
fromGraph<
T> (DogGraphValue value, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → T -
Available on DogEngine, provided by the DogEngineShortcuts extension
Converts DogGraphValue supplied viavalue
to its normal representation by using the converter associated withT
ortree
. -
fromJson<
T> (String encoded, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → T -
Available on DogEngine, provided by the DogJsonExtension extension
Converts JSON supplied viaencoded
to its normal representation by using the converter associated withT
ortree
. -
fromNative<
T> (dynamic value, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → T -
Available on DogEngine, provided by the DogEngineShortcuts extension
Converts avalue
to its native representation using the converter associated withT
ortype
and the supplied IterableKind. Iftree
is supplied, the converter associated with the tree is used. -
getChild(
Symbol identity) → DogEngine? -
Returns a child DogEngine instance that is associated with the given
identity
. If no child is associated with the givenidentity
, null will be returned. -
getChildOrFork(
Symbol identity, {DogNativeCodec? codec, dynamic callback(DogEngine)?}) → DogEngine -
Returns a child DogEngine instance that is associated with the given
identity
. If no child is associated with the givenidentity
, a new DogEngine instance will be created via fork. -
getMeta<
T> ({Object? key, T orElse()?}) → T -
Returns the metadata entry for the given key or type argument.
If no metadata entry is found, throws an exception or automatically
calls the
orElse
function to initialize the metadata entry and return it.inherited -
getMetaOrNull<
T> ([Object? key]) → T? -
Returns the metadata entry for the given key or type argument.
If no metadata entry is found, returns null.
inherited
-
getTreeConverter(
TypeTree tree, [bool allowPolymorphic = true]) → DogConverter -
Returns the DogConverter for the given
tree
. IfallowPolymorphic
is true, the returned converter may contain polymorphic converters if any type tree terminals are not concrete. -
importSchema(
SchemaType type) → SyntheticTypeCapture -
Available on DogEngine, provided by the SchemaGenerateExtension extension
Materializes atype
schema in the current engine scope, registering the resulting structures and converters. -
materialize(
SchemaType type) → MaterializedConverter -
Available on DogEngine, provided by the SchemaGenerateExtension extension
Materializes atype
schema, creating a MaterializedConverter that can be used to convert data to and from the schema. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
populateChange(
) → void - Populates an engine change to all children. This will cause all children to rebuild their cache and emit a change events to their children.
-
project<
TARGET> (Object value, [Object? a, Object? b, Object? c]) → TARGET -
Available on DogEngine, provided by the ProjectionExtension extension
Creates a projection from the given values, see createProjection. Parameters can be either a Map or an Object. If an Object is given, it's runtime type is used to find the corresponding DogStructure before serializing the object to its native map form. This will therefore not work with generic types. Consider manually serializing the object toNative first in that case before passing it in as a map. -
projectDocument(
Object value, [Object? a, Object? b, Object? c]) → Map< String, dynamic> -
Available on DogEngine, provided by the ProjectionExtension extension
Creates a projection document from the given values, see createProjectionDocument. -
projectDocumentShallow(
Object value, [Object? a, Object? b, Object? c]) → Map< String, dynamic> -
Available on DogEngine, provided by the ProjectionExtension extension
Creates a shallow projection document from the given values, see createProjectionDocument. -
projectShallow<
TARGET> (Object value, [Object? a, Object? b, Object? c]) → TARGET -
Available on DogEngine, provided by the ProjectionExtension extension
Creates a shallow projection from the given values, see createProjection. -
registerAllConverters(
Iterable< DogConverter> converters) → void - Registers multiple converters using registerAutomatic. For more details see DogEngine.registerAutomatic.
-
registerAllTreeBaseFactories(
Iterable< MapEntry< entries) → voidTypeCapture, TreeBaseConverterFactory> > - Registers multiple tree base factories using registerTreeBaseFactory.
-
registerAssociatedConverter(
DogConverter converter, {bool emitChangeToStream = true, Type? type}) → void -
Registers a
converter
in this DogEngine instance and emits a event to the change stream ifemitChangeToStream
is true. -
registerAutomatic(
DogConverter converter, [bool emitChangeToStream = true]) → Future< void> -
Registers a
converter
in this DogEngine instance and emits a event to the change stream ifemitChangeToStream
is true. -
registerModeFactory(
OperationModeFactory< OperationMode> factory, {bool emitChangeToStream = true, Type? type}) → void -
Registers a OperationModeFactory in this DogEngine instance and emits
a event to the change stream if
emitChangeToStream
is true. -
registerShelvedConverter(
DogConverter converter, {bool emitChangeToStream = true}) → void -
Registers a
converter
in this DogEngine instance and emits a event to the change stream ifemitChangeToStream
is true. Shelved converters are converters that are not associated with a type, but can be used by querying the explicit type of the converter. -
registerStructure(
DogStructure structure, {bool emitChangeToStream = true, Type? type}) → void -
Registers a DogStructure in this DogEngine instance and emits a event
to the change stream if
emitChangeToStream
is true. -
registerTreeBaseFactory(
TypeCapture type, TreeBaseConverterFactory factory) → void - Registers and associates a single TreeBaseConverterFactory with Type.
-
reset(
) → void - Resets the DogEngine's operation mode cache. All registered converters and structures will not be affected.
-
setMeta<
T> (T value, {Object? key}) → void -
Sets the metadata entry for the given key or type argument.
inherited
-
setSingleton(
) → void -
Sets this current instance as
_instance
. -
toFieldMap<
T> (T value, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → Map< String, dynamic> -
Available on DogEngine, provided by the DogEngineShortcuts extension
Converts a value of typeT
to a field map using the structure associated withT
ortype
and the supplied IterableKind. Iftree
is supplied, the structure associated with the tree is used. -
toGraph<
T> (T value, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → DogGraphValue -
Available on DogEngine, provided by the DogEngineShortcuts extension
Converts avalue
to its DogGraphValue representation using the converter associated withT
ortree
. -
toJson<
T> (T value, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → String -
Available on DogEngine, provided by the DogJsonExtension extension
Converts avalue
to its JSON representation using the converter associated withT
ortree
. -
toNative<
T> (T value, {IterableKind kind = IterableKind.none, Type? type, TypeTree? tree}) → dynamic -
Available on DogEngine, provided by the DogEngineShortcuts extension
Converts avalue
to its native representation using the converter associated withT
ortype
and the supplied IterableKind. Iftree
is supplied, the converter associated with the tree is used. -
toString(
) → String -
A string representation of this object.
inherited
-
use(
void block()) → void -
Uses this DogEngine instance for global instance calls for the duration of
block
. -
validate<
T> (T value) → void -
Available on DogEngine, provided by the DogEngineShortcuts extension
Validates the suppliedvalue
using the ValidationMode mapped toT
. Throws a ValidationException if validateObject returns false. -
validateAnnotated(
dynamic value, [Type? type]) → AnnotationResult -
Validates the supplied
value
using the ValidationMode mapped to thevalue
s runtime type ortype
if specified. The resulting AnnotationResult contains all error messages that were generated during validation. -
validateObject(
dynamic value, [Type? type]) → bool -
Validates the supplied
value
using the ValidationMode mapped to thevalue
s runtime type ortype
if specified.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited