1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use notifier::INotifier;
use notification_level::NotificationLevel;

pub struct NotificationService {
    notifiers: Vec<Box<INotifier>>
}

impl NotificationService {
    pub fn new() -> NotificationService {
        NotificationService {
            notifiers: Vec::new()
        }
    }

    pub fn add(&mut self, notifier: Box<INotifier>) {
        self.notifiers.push(notifier);
    }

    pub fn notify(&self, message: &String, notification_level: NotificationLevel) {
        for notifier in &self.notifiers {
            notifier.notify(message, &notification_level);
        }
    }
}