Skip to content

OTPModule

dsmurfin edited this page Aug 28, 2021 · 3 revisions

OTPModule

OTP Module

public protocol OTPModule 

An OTP Module contains specific transform information about an OTPPoint such as position, rotation and hierarchy.

Implementors providing their own module types must implement all of these requirements for creating, sending and parsing received modules of that type.

Default Implementations

moduleIdentifier

An instance accessor of the static module identifier.

public var moduleIdentifier: OTPModuleIdentifier 

Requirements

identifier

Uniquely identifies the module using an OTPModuleIdentifier.

static var identifier: OTPModuleIdentifier 

dataLength

The size of the module's data in bytes.

static var dataLength: OTPPDULength 

moduleLength

The total size of the module in bytes, including identifiers and length.

static var moduleLength: OTPPDULength 

logDescription

A human-readable log description of this module.

var logDescription: String 

init()

Initializes this OTPModule with default values.

init()

createAsData()

Creates a Module as Data.

func createAsData() -> Data

Returns

The OTPModule as a Data object.

parse(fromData:​)

Attempts to create an OTPModule from the data.

static func parse(fromData data: Data) throws -> (module: Self, length: OTPPDULength)

Parameters

  • data: The data to be parsed.

Throws

An error of type ModuleLayerValidationError.

Returns

A valid OTPModule and the length of the PDU.

merge(modules:​)

Merges an arrray of modules.

static func merge(modules: [OTPModule]) -> (module: Self?, excludePoint: Bool)

Parameters

  • modules: The OTPModules to be merged.

Returns

An optional OTPModule of this type, and whether to exclude the OTPPoint due to a mismatch.

isEqualToModule(_:​)

Calculates whether this module is considered equal to another one.

func isEqualToModule(_ module: OTPModule) -> Bool

Parameters

  • module: The OTPModule to be compared against.

Returns

Whether these OTPModules are considered equal.

Clone this wiki locally