use crate::types::NodeType;
use std::collections::HashMap;
pub struct DomainConfig {
pub name: String,
pub half_lives: HashMap<NodeType, f32>,
pub default_half_life: f32,
pub relations: Vec<String>,
pub git_co_change: bool,
}
impl DomainConfig {
pub fn code() -> Self {
let mut half_lives = HashMap::new();
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 {
name: "code".into(),
half_lives,
default_half_life: 168.0,
relations: vec![
"contains".into(),
"imports".into(),
"calls".into(),
"references".into(),
"implements".into(),
],
git_co_change: true,
}
}
pub fn music() -> Self {
let mut half_lives = HashMap::new();
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 {
name: "music".into(),
half_lives,
default_half_life: 336.0,
relations: vec![
"routes_to".into(),
"sends_to".into(),
"controls".into(),
"modulates".into(),
"contains".into(),
"monitors".into(),
],
git_co_change: false,
}
}
pub fn generic() -> Self {
Self {
name: "generic".into(),
half_lives: HashMap::new(),
default_half_life: 336.0,
relations: vec![
"contains".into(),
"references".into(),
"depends_on".into(),
"produces".into(),
"consumes".into(),
],
git_co_change: false,
}
}
pub fn memory() -> Self {
let mut half_lives = HashMap::new();
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 {
name: "memory".into(),
half_lives,
default_half_life: 504.0,
relations: vec![
"contains".into(),
"mentions".into(),
"references".into(),
"relates_to".into(),
"happened_on".into(),
"supersedes".into(),
"decided".into(),
"tracks".into(),
],
git_co_change: false,
}
}
pub fn light() -> Self {
let mut half_lives = HashMap::new();
half_lives.insert(NodeType::File, 1440.0); half_lives.insert(NodeType::Module, 1080.0); half_lives.insert(NodeType::Concept, 1080.0); half_lives.insert(NodeType::Process, 720.0); half_lives.insert(NodeType::Reference, 840.0); half_lives.insert(NodeType::System, 1440.0); Self {
name: "light".into(),
half_lives,
default_half_life: 840.0,
relations: vec![
"contains_section".into(),
"defines_protocol".into(),
"has_state".into(),
"has_glyph".into(),
"has_color".into(),
"has_metadata".into(),
"depends_on".into(),
"next_binding".into(),
"declares_entity".into(),
"declares_event".into(),
"declares_state".into(),
"declares_test".into(),
"declares_blocker".into(),
"declares_warning".into(),
"binds_to".into(),
],
git_co_change: false,
}
}
pub fn half_life_for(&self, node_type: NodeType) -> f32 {
self.half_lives
.get(&node_type)
.copied()
.unwrap_or(self.default_half_life)
}
}