sofiza/sfz/group.rs
1use std::fmt::Debug;
2
3use crate::sfz::{Opcode, OpcodeMap};
4
5/// Groups allow entering common parameters for multiple regions.
6///
7/// A group is defined with the <group> opcode, and the parameters enumerated
8/// on it last till the next group opcode, or till the end of the file.
9///
10#[derive(Clone, Debug, Default, PartialEq)]
11pub struct Group {
12 /// This list of opcodes overwrites the default ones.
13 pub opcodes: OpcodeMap,
14
15 /// The label of this group.
16 pub label: String,
17}
18
19impl Group {
20 /// New group.
21 pub fn new() -> Self {
22 Self::default()
23 }
24
25 /// Add an opcode to the group.
26 pub fn add_opcode(&mut self, o: &Opcode) {
27 self.opcodes.insert(o.str_name(), o.clone());
28 }
29}