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  
19  import org.orekit.files.ccsds.utils.ContextBinding;
20  import org.orekit.files.ccsds.utils.lexical.ParseToken;
21  import org.orekit.files.ccsds.utils.lexical.TokenType;
22  
23  
24  /** Keys for {@link AttitudeCovarianceHistoryMetadata covariance history container} entries.
25   * @author Luc Maisonobe
26   * @since 12.0
27   */
28  public enum AttitudeCovarianceHistoryMetadataKey {
29  
30      /** Comment entry. */
31      COMMENT((token, context, container) ->
32              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
33  
34      /** Covariance identification number. */
35      COV_ID((token, context, container) -> token.processAsFreeTextString(container::setCovID)),
36  
37      /** Identification number of previous covariance. */
38      COV_PREV_ID((token, context, container) -> token.processAsFreeTextString(container::setCovPrevID)),
39  
40      /** Basis of this covariance time history data. */
41      COV_BASIS((token, context, container) -> token.processAsFreeTextString(container::setCovBasis)),
42  
43      /** Identification number of the orbit determination or simulation upon which this covariance is based.*/
44      COV_BASIS_ID((token, context, container) -> token.processAsFreeTextString(container::setCovBasisID)),
45  
46      /** Reference frame of the covariance. */
47      COV_REF_FRAME((token, context, container) -> token.processAsFrame(container::setCovReferenceFrame, context, true, true, true)),
48  
49      /** Covariance element set type.
50       * @see AttitudeCovarianceType
51       */
52      COV_TYPE((token, context, container) -> token.processAsEnum(AttitudeCovarianceType.class, container::setCovType));
53  
54      /** Processing method. */
55      private final transient TokenProcessor processor;
56  
57      /** Simple constructor.
58       * @param processor processing method
59       */
60      AttitudeCovarianceHistoryMetadataKey(final TokenProcessor processor) {
61          this.processor = processor;
62      }
63  
64      /** Process an token.
65       * @param token token to process
66       * @param context context binding
67       * @param container container to fill
68       * @return true of token was accepted
69       */
70      public boolean process(final ParseToken token, final ContextBinding context, final AttitudeCovarianceHistoryMetadata container) {
71          return processor.process(token, context, container);
72      }
73  
74      /** Interface for processing one token. */
75      interface TokenProcessor {
76          /** Process one token.
77           * @param token token to process
78           * @param context context binding
79           * @param container container to fill
80           * @return true of token was accepted
81           */
82          boolean process(ParseToken token, ContextBinding context, AttitudeCovarianceHistoryMetadata container);
83      }
84  
85  }