@wildboar/rose
Version:
Remote Operation Service Element PDUs in TypeScript
150 lines (149 loc) • 5.5 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from '@wildboar/asn1';
import * as $ from '@wildboar/asn1/functional';
import { _enum_for_RealizationParameter_realization_type, _decode_RealizationParameter_realization_type, _encode_RealizationParameter_realization_type, } from '../Remote-Operations-Realizations/RealizationParameter-realization-type.ta.mjs';
/**
* @summary RealizationParameter
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* RealizationParameter ::= SEQUENCE {
* realization-type ENUMERATED {association-service(0), transfer-service(1)},
* concatenation BOOLEAN DEFAULT FALSE
* }
* ```
*
*/
export class RealizationParameter {
realization_type;
concatenation;
constructor(
/**
* @summary `realization_type`.
* @public
* @readonly
*/
realization_type,
/**
* @summary `concatenation`.
* @public
* @readonly
*/
concatenation) {
this.realization_type = realization_type;
this.concatenation = concatenation;
}
/**
* @summary Restructures an object into a RealizationParameter
* @description
*
* This takes an `object` and converts it to a `RealizationParameter`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `RealizationParameter`.
* @returns {RealizationParameter}
*/
static _from_object(_o) {
return new RealizationParameter(_o.realization_type, _o.concatenation);
}
/**
* @summary Getter that returns the default value for `concatenation`.
* @public
* @static
* @method
*/
static get _default_value_for_concatenation() {
return false;
}
/**
* @summary The enum used as the type of the component `realization_type`
* @public
* @static
*/
static _enum_for_realization_type = _enum_for_RealizationParameter_realization_type;
}
/**
* @summary The Leading Root Component Types of RealizationParameter
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_1_spec_for_RealizationParameter = [
new $.ComponentSpec('realization-type', false, $.hasTag(_TagClass.universal, 10)),
new $.ComponentSpec('concatenation', true, $.hasTag(_TagClass.universal, 1)),
];
/**
* @summary The Trailing Root Component Types of RealizationParameter
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_2_spec_for_RealizationParameter = [];
/**
* @summary The Extension Addition Component Types of RealizationParameter
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _extension_additions_list_spec_for_RealizationParameter = [];
let _cached_decoder_for_RealizationParameter = null;
/**
* @summary Decodes an ASN.1 element into a(n) RealizationParameter
* @function
* @param {_Element} el The element being decoded.
* @returns {RealizationParameter} The decoded data structure.
*/
export function _decode_RealizationParameter(el) {
if (!_cached_decoder_for_RealizationParameter) {
_cached_decoder_for_RealizationParameter = function (el) {
let realization_type;
let concatenation = RealizationParameter._default_value_for_concatenation;
const callbacks = {
'realization-type': (_el) => {
realization_type = _decode_RealizationParameter_realization_type(_el);
},
concatenation: (_el) => {
concatenation = $._decodeBoolean(_el);
},
};
$._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_RealizationParameter, _extension_additions_list_spec_for_RealizationParameter, _root_component_type_list_2_spec_for_RealizationParameter, undefined);
return new RealizationParameter(realization_type, concatenation);
};
}
return _cached_decoder_for_RealizationParameter(el);
}
let _cached_encoder_for_RealizationParameter = null;
/**
* @summary Encodes a(n) RealizationParameter into an ASN.1 Element.
* @function
* @param value The element being encoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The RealizationParameter, encoded as an ASN.1 Element.
*/
export function _encode_RealizationParameter(value, elGetter) {
if (!_cached_encoder_for_RealizationParameter) {
_cached_encoder_for_RealizationParameter = function (value) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ _encode_RealizationParameter_realization_type(value.realization_type, $.BER),
/* IF_DEFAULT */ value.concatenation === undefined ||
$.deepEq(value.concatenation, RealizationParameter._default_value_for_concatenation)
? undefined
: $._encodeBoolean(value.concatenation, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_RealizationParameter(value, elGetter);
}
/* eslint-enable */