AttitudeStateHistoryMetadataKey.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.files.ccsds.ndm.adm.acm;

  18. import org.orekit.files.ccsds.utils.ContextBinding;
  19. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  20. import org.orekit.files.ccsds.utils.lexical.TokenType;


  21. /** Keys for {@link AttitudeStateHistoryMetadata attitude state history container} entries.
  22.  * @author Luc Maisonobe
  23.  * @since 12.0
  24.  */
  25. public enum AttitudeStateHistoryMetadataKey {

  26.     /** Comment entry. */
  27.     COMMENT((token, context, container) ->
  28.             token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),

  29.     /** Attitude identification number. */
  30.     ATT_ID((token, context, container) -> token.processAsFreeTextString(container::setAttID)),

  31.     /** Identification number of previous attitude. */
  32.     ATT_PREV_ID((token, context, container) -> token.processAsFreeTextString(container::setAttPrevID)),

  33.     /** Basis of this attitude state time history data. */
  34.     ATT_BASIS((token, context, container) -> token.processAsFreeTextString(container::setAttBasis)),

  35.     /** Identification number of the attitude determination or simulation upon which this attitude is based.*/
  36.     ATT_BASIS_ID((token, context, container) -> token.processAsFreeTextString(container::setAttBasisID)),

  37.     /** Reference frame defining the starting point of the transformation. */
  38.     REF_FRAME_A((token, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameA, context, true, true, false)),

  39.     /** Reference frame defining the end point of the transformation. */
  40.     REF_FRAME_B((token, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameB, context, false, false, true)),

  41.     /** Rotation sequence entry. */
  42.     EULER_ROT_SEQ((token, context, container) -> token.processAsRotationOrder(container::setEulerRotSeq)),

  43.     /** Number of data states included. */
  44.     NUMBER_STATES((token, context, container) -> token.processAsInteger(container::setNbStates)),

  45.     /** Attitude element set type.
  46.      * @see AttitudeElementsType
  47.      */
  48.     ATT_TYPE((token, context, container) -> token.processAsEnum(AttitudeElementsType.class, container::setAttitudeType)),

  49.     /** Attitude rate element set type.
  50.      * @see RateElementsType
  51.      */
  52.     RATE_TYPE((token, context, container) -> token.processAsEnum(RateElementsType.class, container::setRateType));

  53.     /** Processing method. */
  54.     private final transient TokenProcessor processor;

  55.     /** Simple constructor.
  56.      * @param processor processing method
  57.      */
  58.     AttitudeStateHistoryMetadataKey(final TokenProcessor processor) {
  59.         this.processor = processor;
  60.     }

  61.     /** Process an token.
  62.      * @param token token to process
  63.      * @param context context binding
  64.      * @param container container to fill
  65.      * @return true of token was accepted
  66.      */
  67.     public boolean process(final ParseToken token, final ContextBinding context, final AttitudeStateHistoryMetadata container) {
  68.         return processor.process(token, context, container);
  69.     }

  70.     /** Interface for processing one token. */
  71.     interface TokenProcessor {
  72.         /** Process one token.
  73.          * @param token token to process
  74.          * @param context context binding
  75.          * @param container container to fill
  76.          * @return true of token was accepted
  77.          */
  78.         boolean process(ParseToken token, ContextBinding context, AttitudeStateHistoryMetadata container);
  79.     }

  80. }