1use crate::types::NodeType;
4use std::collections::HashMap;
5
6pub struct DomainConfig {
9 pub name: String,
11 pub half_lives: HashMap<NodeType, f32>,
14 pub default_half_life: f32,
16 pub relations: Vec<String>,
18 pub git_co_change: bool,
20}
21
22impl DomainConfig {
23 pub fn code() -> Self {
25 let mut half_lives = HashMap::new();
26 half_lives.insert(NodeType::File, 168.0); half_lives.insert(NodeType::Function, 336.0); half_lives.insert(NodeType::Class, 504.0); half_lives.insert(NodeType::Struct, 504.0); half_lives.insert(NodeType::Enum, 504.0); half_lives.insert(NodeType::Module, 720.0); half_lives.insert(NodeType::Directory, 720.0); half_lives.insert(NodeType::Type, 504.0); Self {
35 name: "code".into(),
36 half_lives,
37 default_half_life: 168.0,
38 relations: vec![
39 "contains".into(),
40 "imports".into(),
41 "calls".into(),
42 "references".into(),
43 "implements".into(),
44 ],
45 git_co_change: true,
46 }
47 }
48
49 pub fn music() -> Self {
51 let mut half_lives = HashMap::new();
52 half_lives.insert(NodeType::System, 720.0); half_lives.insert(NodeType::Process, 336.0); half_lives.insert(NodeType::Material, 168.0); half_lives.insert(NodeType::Concept, 504.0); Self {
60 name: "music".into(),
61 half_lives,
62 default_half_life: 336.0,
63 relations: vec![
64 "routes_to".into(),
65 "sends_to".into(),
66 "controls".into(),
67 "modulates".into(),
68 "contains".into(),
69 "monitors".into(),
70 ],
71 git_co_change: false,
72 }
73 }
74
75 pub fn generic() -> Self {
77 Self {
78 name: "generic".into(),
79 half_lives: HashMap::new(),
80 default_half_life: 336.0, relations: vec![
82 "contains".into(),
83 "references".into(),
84 "depends_on".into(),
85 "produces".into(),
86 "consumes".into(),
87 ],
88 git_co_change: false,
89 }
90 }
91
92 pub fn memory() -> Self {
94 let mut half_lives = HashMap::new();
95 half_lives.insert(NodeType::File, 1008.0); half_lives.insert(NodeType::Module, 720.0); half_lives.insert(NodeType::Concept, 720.0); half_lives.insert(NodeType::Process, 168.0); half_lives.insert(NodeType::Reference, 336.0); half_lives.insert(NodeType::System, 840.0); Self {
102 name: "memory".into(),
103 half_lives,
104 default_half_life: 504.0,
105 relations: vec![
106 "contains".into(),
107 "mentions".into(),
108 "references".into(),
109 "relates_to".into(),
110 "happened_on".into(),
111 "supersedes".into(),
112 "decided".into(),
113 "tracks".into(),
114 ],
115 git_co_change: false,
116 }
117 }
118
119 pub fn half_life_for(&self, node_type: NodeType) -> f32 {
121 self.half_lives
122 .get(&node_type)
123 .copied()
124 .unwrap_or(self.default_half_life)
125 }
126}