CollectorFactory
public actor CollectorFactory
The CollectorFactory singleton is responsible for creating and managing Collector instances. It maintains a dictionary of collector creation functions, keyed by type. It also provides functions to register new types of collectors and to create collectors from a JSON array.
-
The shared instance of the CollectorFactory.
Declaration
Swift
public static let shared: CollectorFactory
-
Registers the default DaVinci Collectors.
Declaration
Swift
public func registerDefaultCollectors()
-
Registers a new type of Collector.
Declaration
Swift
public func register(type: String, collector: any Collector.Type)
Parameters
type
The type of the Collector.
block
A function that creates a new instance of the Collector.
-
Creates a list of Collector instances from an array of dictionaries. Each dictionary should have a “type” field that matches a registered Collector type.
Declaration
Swift
public func collector(from array: [[String : Any]]) -> Collectors
Parameters
array
The array of dictionaries to create the Collectors from.
Return Value
A list of Collector instances.
-
Injects the ContinueNode instances into the collectors.
Declaration
Swift
public func inject(continueNode: ContinueNode)
Parameters
continueNode
The ContinueNode instance to be injected.
-
Resets the CollectorFactory by clearing all registered collectors.
Declaration
Swift
public func reset()