#![deny(missing_docs)]
#![allow(dead_code, unused_assignments)]
#[macro_use]
extern crate log;
pub use libreda_db;
use libreda_db as db;
use db::layout::prelude::*;
mod base_types;
mod reader;
mod writer;
use base_types::*;
use crate::base_types::Repetition;
use std::io::{Read, Write};
pub use writer::OASISWriterConfig;
pub use libreda_db::prelude::{LayoutBase, LayoutEdit, LayoutStreamReader, LayoutStreamWriter};
#[derive(Clone, Default, Debug)]
pub struct OASISStreamReader {}
impl OASISStreamReader {
pub fn new() -> Self {
OASISStreamReader {}
}
}
#[derive(Clone, Default, Debug)]
pub struct OASISStreamWriter {
config: OASISWriterConfig
}
impl OASISStreamWriter {
pub fn with_config(config: OASISWriterConfig) -> Self{
Self {config}
}
}
impl LayoutStreamReader for OASISStreamReader {
type Error = OASISReadError;
fn read_layout<R: Read, L: LayoutEdit<Coord=SInt>>(&self, r: &mut R, layout: &mut L) -> Result<(), Self::Error> {
reader::read_layout(r, layout)
}
}
impl LayoutStreamWriter for OASISStreamWriter {
type Error = OASISWriteError;
fn write_layout<W: Write, L: LayoutBase<Coord=SInt>>(&self, w: &mut W, layout: &L) -> Result<(), Self::Error> {
writer::write_layout(w, layout, &self.config)
}
}
#[derive(Copy, Clone, Debug)]
enum XYMode {
Absolute,
Relative,
}
impl Default for XYMode {
fn default() -> Self {
XYMode::Absolute
}
}
#[derive(Debug, Clone)]
pub(crate) enum NameOrRef {
Name(String),
NameRef(UInt),
}
#[derive(Debug)]
struct Modal<C> {
repetition: Option<Repetition>,
placement_x: SInt,
placement_y: SInt,
placement_cell: Option<C>,
layer: Option<UInt>,
datatype: Option<UInt>,
textlayer: Option<UInt>,
texttype: Option<UInt>,
text_x: SInt,
text_y: SInt,
text_string: Option<String>,
geometry_x: SInt,
geometry_y: SInt,
xy_mode: XYMode,
geometry_w: Option<UInt>,
geometry_h: Option<UInt>,
polygon_point_list: Option<PointList>,
path_halfwidth: Option<UInt>,
path_point_list: Option<PointList>,
path_start_extension: Option<SInt>,
path_end_extension: Option<SInt>,
ctrapezoid_type: Option<()>,
circle_radius: Option<()>,
last_property_name: Option<NameOrRef>,
last_value_list: Option<Vec<PropertyValue>>,
}
impl<C> Default for Modal<C> {
fn default() -> Self {
Self {
repetition: None,
placement_x: Default::default(),
placement_y: Default::default(),
placement_cell: None,
layer: None,
datatype: None,
textlayer: None,
texttype: None,
text_x: Default::default(),
text_y: Default::default(),
text_string: None,
geometry_x: Default::default(),
geometry_y: Default::default(),
xy_mode: Default::default(),
geometry_w: None,
geometry_h: None,
polygon_point_list: None,
path_halfwidth: None,
path_point_list: None,
path_start_extension: None,
path_end_extension: None,
ctrapezoid_type: None,
circle_radius: None,
last_property_name: None,
last_value_list: None
}
}
}
impl<C> Modal<C> {
fn reset(&mut self) -> () {
let reset = Self::default();
*self = reset;
}
}