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 AttitudeStateHistoryMetadata attitude state history container} entries.
25 * @author Luc Maisonobe
26 * @since 12.0
27 */
28 public enum AttitudeStateHistoryMetadataKey {
29
30 /** Comment entry. */
31 COMMENT((token, context, container) ->
32 token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
33
34 /** Attitude identification number. */
35 ATT_ID((token, context, container) -> token.processAsFreeTextString(container::setAttID)),
36
37 /** Identification number of previous attitude. */
38 ATT_PREV_ID((token, context, container) -> token.processAsFreeTextString(container::setAttPrevID)),
39
40 /** Basis of this attitude state time history data. */
41 ATT_BASIS((token, context, container) -> token.processAsFreeTextString(container::setAttBasis)),
42
43 /** Identification number of the attitude determination or simulation upon which this attitude is based.*/
44 ATT_BASIS_ID((token, context, container) -> token.processAsFreeTextString(container::setAttBasisID)),
45
46 /** Reference frame defining the starting point of the transformation. */
47 REF_FRAME_A((token, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameA, context, true, true, false)),
48
49 /** Reference frame defining the end point of the transformation. */
50 REF_FRAME_B((token, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameB, context, false, false, true)),
51
52 /** Rotation sequence entry. */
53 EULER_ROT_SEQ((token, context, container) -> token.processAsRotationOrder(container::setEulerRotSeq)),
54
55 /** Number of data states included. */
56 NUMBER_STATES((token, context, container) -> token.processAsInteger(container::setNbStates)),
57
58 /** Attitude element set type.
59 * @see AttitudeElementsType
60 */
61 ATT_TYPE((token, context, container) -> token.processAsEnum(AttitudeElementsType.class, container::setAttitudeType)),
62
63 /** Attitude rate element set type.
64 * @see RateElementsType
65 */
66 RATE_TYPE((token, context, container) -> token.processAsEnum(RateElementsType.class, container::setRateType));
67
68 /** Processing method. */
69 private final transient TokenProcessor processor;
70
71 /** Simple constructor.
72 * @param processor processing method
73 */
74 AttitudeStateHistoryMetadataKey(final TokenProcessor processor) {
75 this.processor = processor;
76 }
77
78 /** Process an token.
79 * @param token token to process
80 * @param context context binding
81 * @param container container to fill
82 * @return true of token was accepted
83 */
84 public boolean process(final ParseToken token, final ContextBinding context, final AttitudeStateHistoryMetadata container) {
85 return processor.process(token, context, container);
86 }
87
88 /** Interface for processing one token. */
89 interface TokenProcessor {
90 /** Process one token.
91 * @param token token to process
92 * @param context context binding
93 * @param container container to fill
94 * @return true of token was accepted
95 */
96 boolean process(ParseToken token, ContextBinding context, AttitudeStateHistoryMetadata container);
97 }
98
99 }