#![allow(unused_variables)]
#![allow(missing_docs)]
use crate::prelude::PropertyValue;
use crate::traits::{IdType, IdTypeMT};
use std::borrow::Borrow;
use std::hash::Hash;
#[portrait::make]
pub trait HierarchyIds {
type CellId: IdType;
type CellInstId: IdType;
}
#[portrait::make]
pub trait HierarchyBaseMT:
HierarchyBase<CellId = Self::CellIdMT, CellInstId = Self::CellInstIdMT> + Sync
{
type CellIdMT: IdTypeMT;
type CellInstIdMT: IdTypeMT;
}
impl<H> HierarchyBaseMT for H
where
H: HierarchyBase + Sync,
H::CellId: Send + Sync,
H::CellInstId: Send + Sync,
{
type CellIdMT = H::CellId;
type CellInstIdMT = H::CellInstId;
}
#[portrait::make(import(crate::prelude::PropertyValue))]
pub trait HierarchyBase: HierarchyIds {
type NameType: Eq
+ Hash
+ From<String>
+ Into<String>
+ Clone
+ Borrow<String>
+ Borrow<str>
+ PartialOrd
+ Ord
+ std::fmt::Display
+ std::fmt::Debug;
fn cell_by_name(&self, name: &str) -> Option<Self::CellId>;
fn cell_instance_by_name(
&self,
parent_cell: &Self::CellId,
name: &str,
) -> Option<Self::CellInstId>;
fn cell_name(&self, cell: &Self::CellId) -> Self::NameType;
fn cell_instance_name(&self, cell_inst: &Self::CellInstId) -> Option<Self::NameType>;
fn parent_cell(&self, cell_instance: &Self::CellInstId) -> Self::CellId;
fn template_cell(&self, cell_instance: &Self::CellInstId) -> Self::CellId;
fn for_each_cell<F>(&self, f: F)
where
F: FnMut(Self::CellId);
fn each_cell_vec(&self) -> Vec<Self::CellId> {
let mut v = Vec::new();
self.for_each_cell(|c| v.push(c));
v
}
fn each_cell(&self) -> Box<dyn Iterator<Item = Self::CellId> + '_> {
Box::new(self.each_cell_vec().into_iter())
}
fn for_each_cell_instance<F>(&self, cell: &Self::CellId, f: F)
where
F: FnMut(Self::CellInstId);
fn each_cell_instance_vec(&self, cell: &Self::CellId) -> Vec<Self::CellInstId> {
let mut v = Vec::new();
self.for_each_cell_instance(cell, |c| v.push(c));
v
}
fn each_cell_instance(
&self,
cell: &Self::CellId,
) -> Box<dyn Iterator<Item = Self::CellInstId> + '_> {
Box::new(self.each_cell_instance_vec(cell).into_iter())
}
fn for_each_cell_dependency<F>(&self, cell: &Self::CellId, f: F)
where
F: FnMut(Self::CellId);
fn each_cell_dependency_vec(&self, cell: &Self::CellId) -> Vec<Self::CellId> {
let mut v = Vec::new();
self.for_each_cell_dependency(cell, |c| v.push(c));
v
}
fn each_cell_dependency<'a>(
&'a self,
cell: &Self::CellId,
) -> Box<dyn Iterator<Item = Self::CellId> + 'a> {
Box::new(self.each_cell_dependency_vec(cell).into_iter())
}
fn num_cell_dependencies(&self, cell: &Self::CellId) -> usize {
let mut counter = 0;
self.for_each_cell_dependency(cell, |_| counter += 1);
counter
}
fn for_each_dependent_cell<F>(&self, cell: &Self::CellId, f: F)
where
F: FnMut(Self::CellId);
fn each_dependent_cell_vec(&self, cell: &Self::CellId) -> Vec<Self::CellId> {
let mut v = Vec::new();
self.for_each_dependent_cell(cell, |c| v.push(c));
v
}
fn each_dependent_cell<'a>(
&'a self,
cell: &Self::CellId,
) -> Box<dyn Iterator<Item = Self::CellId> + 'a> {
Box::new(self.each_dependent_cell_vec(cell).into_iter())
}
fn num_dependent_cells(&self, cell: &Self::CellId) -> usize {
let mut counter = 0;
self.for_each_dependent_cell(cell, |_| counter += 1);
counter
}
fn for_each_cell_reference<F>(&self, cell: &Self::CellId, f: F)
where
F: FnMut(Self::CellInstId);
fn each_cell_reference_vec(&self, cell: &Self::CellId) -> Vec<Self::CellInstId> {
let mut v = Vec::new();
self.for_each_cell_reference(cell, |c| v.push(c));
v
}
fn each_cell_reference(
&self,
cell: &Self::CellId,
) -> Box<dyn Iterator<Item = Self::CellInstId> + '_> {
Box::new(self.each_cell_reference_vec(cell).into_iter())
}
fn num_cell_references(&self, cell: &Self::CellId) -> usize {
let mut counter = 0;
self.for_each_cell_reference(cell, |_| counter += 1);
counter
}
fn num_child_instances(&self, cell: &Self::CellId) -> usize;
fn num_cells(&self) -> usize;
fn get_chip_property(&self, key: &Self::NameType) -> Option<PropertyValue> {
None
}
fn get_cell_property(
&self,
cell: &Self::CellId,
key: &Self::NameType,
) -> Option<PropertyValue> {
None
}
fn get_cell_instance_property(
&self,
inst: &Self::CellInstId,
key: &Self::NameType,
) -> Option<PropertyValue> {
None
}
}
#[portrait::make(import(crate::prelude::PropertyValue))]
pub trait HierarchyEdit: HierarchyBase {
fn create_cell(&mut self, name: Self::NameType) -> Self::CellId;
fn remove_cell(&mut self, cell_id: &Self::CellId);
fn create_cell_instance(
&mut self,
parent_cell: &Self::CellId,
template_cell: &Self::CellId,
name: Option<Self::NameType>,
) -> Self::CellInstId;
fn remove_cell_instance(&mut self, inst: &Self::CellInstId);
fn rename_cell_instance(&mut self, inst: &Self::CellInstId, new_name: Option<Self::NameType>);
fn rename_cell(&mut self, cell: &Self::CellId, new_name: Self::NameType);
fn set_chip_property(&mut self, key: Self::NameType, value: PropertyValue) {}
fn set_cell_property(
&mut self,
cell: &Self::CellId,
key: Self::NameType,
value: PropertyValue,
) {
}
fn set_cell_instance_property(
&mut self,
inst: &Self::CellInstId,
key: Self::NameType,
value: PropertyValue,
) {
}
}