forked from ROMEO/obsw
trait inheritance is strange
This commit is contained in:
parent
59f4a82da9
commit
bae91a61d4
@ -1,3 +1,5 @@
|
||||
use super::objectmanager::SystemObjectIF;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub struct TypeId {
|
||||
id: usize,
|
||||
@ -14,7 +16,7 @@ pub trait Reflection {
|
||||
}
|
||||
|
||||
pub trait DatapoolOwnerIF {
|
||||
fn get_set(&self, type_id: TypeId) -> Option<&dyn DataSetIF> {
|
||||
fn get_set(&self, _type_id: TypeId) -> Option<&dyn DataSetIF> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@ -75,7 +77,7 @@ impl<T: Reflection + Copy + Default> ReferencedDataset<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initialize(&mut self, owner: &dyn DatapoolOwnerIF) -> Result<(), ()> {
|
||||
pub fn initialize(&mut self, owner: &dyn SystemObjectIF) -> Result<(), ()> {
|
||||
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;
|
||||
@ -88,6 +90,7 @@ impl<T: Reflection + Copy + Default> ReferencedDataset<T> {
|
||||
}
|
||||
}
|
||||
//pointer cast is safe because we checked the type_id
|
||||
//getting pointer to avoid lifetime check
|
||||
self.actual_data = Some(other_set.get_actual_data() as *const dyn Reflection as *const T);
|
||||
//self.mutex = other.mutex
|
||||
Ok(())
|
||||
|
@ -90,6 +90,7 @@ pub struct TaskExecutor<'a> {
|
||||
|
||||
impl<'a> TaskExecutor<'a> {
|
||||
pub fn init_and_run(&mut self) {
|
||||
//TODO unlock global multitasking mutex
|
||||
let object_manager = TaskObjectManager {
|
||||
tasks: unsafe { slice::from_raw_parts(self.tasks.as_ptr(), self.tasks.len()) },
|
||||
};
|
||||
@ -140,6 +141,7 @@ impl<'a> crate::objectmanager::ObjectManager<'a> for TaskObjectManager<'a> {
|
||||
|
||||
impl<'a> Drop for TaskExecutor<'a> {
|
||||
fn drop(&mut self) {
|
||||
//TODO lock global multitasking mutex
|
||||
for task in self.tasks.iter_mut() {
|
||||
unsafe {
|
||||
crate::fsrc::osal::delete_task(task.get_handle());
|
||||
|
@ -162,7 +162,8 @@ impl SystemObjectIF for HandlerSender {
|
||||
Err(_) => return Err(()),
|
||||
};
|
||||
self.other_handler_queue = other_handler.get_command_queue();
|
||||
//TODO self.other_data.initialize(other_handler); // oh come on :/
|
||||
|
||||
self.other_data.initialize(other_handler)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user