making dataset init more safe

This commit is contained in:
Ulrich Mohr 2023-12-12 12:15:18 +01:00
parent 881ae8c096
commit 7f7f57038c
2 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,4 @@
use super::mutex;
use super::{mutex, objectmanager};
use super::objectmanager::SystemObjectIF;
#[derive(Copy, Clone, PartialEq)]
@ -101,7 +101,9 @@ impl<T: HasTypeId + Copy + Default> ReferencedDataset<T> {
}
}
pub fn initialize(&mut self, owner: &dyn SystemObjectIF) -> Result<(), ()> {
//Note, passing the object_manager is per design, so that this call can only be used during init (when storing the address is valid)
pub fn initialize(&mut self, object_manager: &dyn objectmanager::ObjectManager, owner_of_the_set: objectmanager::ObjectId) -> Result<(), ()> {
let owner = object_manager.get_object(owner_of_the_set)?;
let temp: T = T::default(); //TODO find nicer solution whithout local instance and trait bound to Default
let type_id = temp.get_type_id();
let other_set: &dyn DataSetIF;

View File

@ -163,7 +163,7 @@ impl SystemObjectIF for HandlerSender {
};
self.other_handler_queue = other_handler.get_command_queue();
self.other_data.initialize(other_handler)?;
self.other_data.initialize(object_manager, self.other_handler)?;
Ok(())
}
}