fbxcel_dom/v7400/
document.rs1use fbxcel::tree::v7400::Tree;
4
5use crate::v7400::{
6 connection::ConnectionsCache,
7 definition::DefinitionsCache,
8 global_settings::GlobalSettings,
9 object::{scene::SceneHandle, ObjectHandle, ObjectsCache},
10};
11
12pub use self::loader::Loader;
13
14mod loader;
15
16#[derive(Debug, Clone)]
18pub struct Document {
19 tree: Tree,
21 objects: ObjectsCache,
23 connections: ConnectionsCache,
25 definitions: DefinitionsCache,
27}
28
29impl Document {
30 pub fn tree(&self) -> &Tree {
32 &self.tree
33 }
34
35 pub(crate) fn objects_cache(&self) -> &ObjectsCache {
37 &self.objects
38 }
39
40 pub(crate) fn connections_cache(&self) -> &ConnectionsCache {
42 &self.connections
43 }
44
45 pub(crate) fn definitions_cache(&self) -> &DefinitionsCache {
47 &self.definitions
48 }
49
50 pub fn objects(&self) -> impl Iterator<Item = ObjectHandle<'_>> {
52 self.objects
53 .object_node_ids()
54 .map(move |id| id.to_object_handle(self))
55 }
56
57 pub fn scenes(&self) -> impl Iterator<Item = SceneHandle<'_>> {
59 self.objects.document_nodes().iter().map(move |obj_id| {
60 SceneHandle::new(obj_id.to_object_handle(self))
61 .expect("Should never fail: Actually using `Document` objects")
62 })
63 }
64
65 #[inline]
67 #[must_use]
68 pub fn global_settings(&self) -> Option<GlobalSettings> {
69 GlobalSettings::new(self)
70 }
71}
72
73impl AsRef<Tree> for Document {
74 fn as_ref(&self) -> &Tree {
75 &self.tree
76 }
77}