StorageLdpcPageLayout constructor

StorageLdpcPageLayout({
  1. required LdpcCode code,
  2. required int pageDataBits,
  3. int outerCheckBitsPerBlock = 0,
  4. PermutationDescriptor? encodedBitPermutation,
})

Creates a validated page layout.

Implementation

StorageLdpcPageLayout({
  required this.code,
  required this.pageDataBits,
  this.outerCheckBitsPerBlock = 0,
  PermutationDescriptor? encodedBitPermutation,
}) : encodedBitPermutation = encodedBitPermutation ??
          PermutationDescriptor.identity(
            _encodedPageBits(
              code,
              pageDataBits,
              outerCheckBitsPerBlock,
            ),
          ) {
  if (pageDataBits < 1) {
    throw ArgumentError.value(
        pageDataBits, 'pageDataBits', 'Must be positive.');
  }
  if (outerCheckBitsPerBlock < 0 ||
      outerCheckBitsPerBlock >= code.messageBits) {
    throw ArgumentError.value(
      outerCheckBitsPerBlock,
      'outerCheckBitsPerBlock',
      'Must be non-negative and smaller than the LDPC message width.',
    );
  }
  if (this.encodedBitPermutation.length != encodedPageBits) {
    throw RohdHclException(
      'Encoded-page permutation length '
      '${this.encodedBitPermutation.length} does not match '
      '$encodedPageBits encoded bits.',
    );
  }
}