Data Capture Context Deserializer

Defined in framework ScanditDataCaptureCore

Warning

The deserialization API is not yet stable and will still change over the coming releases.

Note

This deserializer is not thread-safe, subsequent calls for the same context have to be called on the same thread.

SDCDataCaptureContextDeserializer
@interface SDCDataCaptureContextDeserializer : NSObject

Added in version 6.1.0

A deserializer to construct data capture contexts from JSON.

Related topics: Serialization.

+ contextDeserializerWithFrameSourceDeserializer:viewDeserializer:modeDeserializers:componentDeserializer:
+ (instancetype)
  contextDeserializerWithFrameSourceDeserializer:(SDCFrameSourceDeserializer *)
                                                 frameSourceDeserializer
                                viewDeserializer:(SDCDataCaptureViewDeserializer *)
                                                 viewDeserializer
                               modeDeserializers:(NSArray<id<SDCDataCaptureModeDeserializer>> *)
                                                 modeDeserializers
                           componentDeserializer:(NSArray<id<SDCDataCaptureComponentDeserializer>> *)
                                                 componentDeserializers

Added in version 6.3.0

Creates a new deserializer object.

delegate
@property (nonatomic, weak, nullable) id<SDCDataCaptureContextDeserializerDelegate> delegate

Added in version 6.1.0

The object informed about deserialization events.

avoidThreadDependencies
@property (nonatomic, assign) BOOL avoidThreadDependencies

Added in version 6.1.0

Avoids dependencies on other threads during contextFromJSONString:error: and updateContext:view:components:fromJSON:error:. This flag is not set by default which means the mentioned methods can have dependencies on other threads, the dependencies are as follows:

  • When the context specifies a capture mode array (even an empty one), the deserialization needs to synchronize with the context thread.

  • When the view specifies an overlay array (even an empty one), the deserialization needs to synchronize with the context thread.

These dependencies are necessary to ensure the consistency of the deserialization across multiple calls. In certain situations they can cause issues though because the context thread is waiting for another thread that is trying to execute a deserialization, resulting in a deadlock. This flag was introduced to allow to circumvent deadlocks in such cases.

If this flag is true, the deserializer can only be used with one context at a time and has to have created said context. Specifically this means the lifecycle is as follows:

It is possible to repeat this lifecycle over and over with different contexts, but it is essential that all calls involving a context are in sequence. It is not possible to create context A, update context A, create context B and then update context A again.

Just as without this flag the deserializer is not thread-safe and because of the above lifecycle all calls (not just the ones for the same context) have to be called on the same thread.

- contextFromJSONString:error:
- (nullable SDCDataCaptureContextDeserializerResult *)
  contextFromJSONString:(NSString *)jsonString
                  error:(NSError **)error

Added in version 6.1.0

Deserializes a data capture context from JSON.

An error is set if the provided JSON does not contain required properties or contains properties of the wrong type.

- updateContext:view:components:fromJSON:error:
- (nullable SDCDataCaptureContextDeserializerResult *)
  updateContext:(SDCDataCaptureContext *)context
           view:(nullable SDCDataCaptureView *)view
     components:(NSArray<id<SDCDataCaptureComponent>> *)components
       fromJSON:(NSString *)jsonString
          error:(NSError **)error

Added in version 6.3.0

Takes an existing data capture context and updates it by deserializing new or changed properties from JSON. See Updating from JSON for details of how updates are being done.

An error is set if the provided JSON does not contain required properties or contains properties of the wrong type.