1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.xr.runtime.internal
18 
19 import androidx.annotation.RestrictTo
20 import androidx.xr.runtime.math.Pose
21 import java.util.UUID
22 
23 /** Describes a fixed location and orientation in the real world. */
24 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
25 public interface Anchor {
26 
27     /** Describes the state of persistence for an [Anchor]. */
28     public class PersistenceState private constructor(private val value: Int) {
29         public companion object {
30             /** The anchor has not been requested to be persisted. */
31             @JvmField public val NotPersisted: PersistenceState = PersistenceState(0)
32 
33             /** The anchor has been requested to be persisted but the operation is still pending. */
34             @JvmField public val Pending: PersistenceState = PersistenceState(1)
35 
36             /** The anchor has been persisted. */
37             @JvmField public val Persisted: PersistenceState = PersistenceState(2)
38         }
39     }
40 
41     /** The location of the anchor in the world coordinate space. */
42     public val pose: Pose
43 
44     /** The current state of the pose of this anchor. */
45     public val trackingState: TrackingState
46 
47     /** The [PersistenceState] for this anchor. */
48     public val persistenceState: PersistenceState
49 
50     /** The [UUID] that identifies this Anchor if it is persisted. */
51     public val uuid: UUID?
52 
53     /**
54      * Detaches this anchor from its [Trackable]. After detaching, the anchor will not be updated
55      * anymore and cannot be reattached to another trackable.
56      */
detachnull57     public fun detach()
58 
59     /**
60      * Sends a request to persist this anchor. The value of [persistenceState] will be updated based
61      * on the progress of this operation. The value of [uuid] will be set if the operation is
62      * successful.
63      */
64     public fun persist()
65 }
66