Skip to content

Commit

Permalink
Use some re-exports for a cleaner, more convenient public API
Browse files Browse the repository at this point in the history
  • Loading branch information
ndebuhr committed Mar 21, 2021
1 parent ce4919c commit ed4c13f
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/input_modeling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
pub mod random_variable;
pub mod thinning;
pub mod uniform_rng;

pub use thinning::Thinning;
pub use uniform_rng::UniformRNG;
2 changes: 1 addition & 1 deletion src/input_modeling/random_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rand_distr::{Beta, Exp, Gamma, LogNormal, Normal, Triangular, Uniform, Weibu
// Discrete distributions
use rand_distr::{Bernoulli, Geometric, Poisson, WeightedIndex};

use super::uniform_rng::UniformRNG;
use super::UniformRNG;
use crate::utils::error::SimulationError;

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
4 changes: 2 additions & 2 deletions src/models/exclusive_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::random_variable::IndexRandomVariable;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The exclusive gateway splits a process flow into a set of possible paths.
Expand Down
4 changes: 2 additions & 2 deletions src/models/gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The gate model passes or blocks jobs, when it is in the open or closed
Expand Down
6 changes: 3 additions & 3 deletions src/models/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::random_variable::ContinuousRandomVariable;
use crate::input_modeling::thinning::Thinning;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::Thinning;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The generator produces jobs based on a configured interarrival
Expand Down
4 changes: 2 additions & 2 deletions src/models/load_balancer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The load balancer routes jobs to a set of possible process paths, using a
Expand Down
10 changes: 10 additions & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ pub mod processor;
pub mod stochastic_gate;
pub mod storage;

pub use self::exclusive_gateway::ExclusiveGateway;
pub use self::gate::Gate;
pub use self::generator::Generator;
pub use self::load_balancer::LoadBalancer;
pub use self::model::{AsModel, Model};
pub use self::parallel_gateway::ParallelGateway;
pub use self::processor::Processor;
pub use self::stochastic_gate::StochasticGate;
pub use self::storage::Storage;

#[derive(Debug, Clone)]
pub struct ModelMessage {
pub port_name: String,
Expand Down
18 changes: 9 additions & 9 deletions src/models/model.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use enum_dispatch::enum_dispatch;
use serde::{Deserialize, Serialize};

use super::exclusive_gateway::ExclusiveGateway;
use super::gate::Gate;
use super::generator::Generator;
use super::load_balancer::LoadBalancer;
use super::parallel_gateway::ParallelGateway;
use super::processor::Processor;
use super::stochastic_gate::StochasticGate;
use super::storage::Storage;
use super::ExclusiveGateway;
use super::Gate;
use super::Generator;
use super::LoadBalancer;
use super::ModelMessage;
use crate::input_modeling::uniform_rng::UniformRNG;
use super::ParallelGateway;
use super::Processor;
use super::StochasticGate;
use super::Storage;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The overall "wrapper" around a model, complete with the model's ID.
Expand Down
4 changes: 2 additions & 2 deletions src/models/parallel_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The parallel gateway splits a job across multiple processing paths. The
Expand Down
4 changes: 2 additions & 2 deletions src/models/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::random_variable::ContinuousRandomVariable;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The processor accepts jobs, processes them for a period of time, and then
Expand Down
4 changes: 2 additions & 2 deletions src/models/stochastic_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::random_variable::BooleanRandomVariable;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The stochastic gate blocks (drops) or passes jobs, based on a specified
Expand Down
4 changes: 2 additions & 2 deletions src/models/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::f64::INFINITY;

use serde::{Deserialize, Serialize};

use super::model::AsModel;
use super::AsModel;
use super::ModelMessage;
use crate::input_modeling::uniform_rng::UniformRNG;
use crate::input_modeling::UniformRNG;
use crate::utils::error::SimulationError;

/// The storage model stores a value, and responds with it upon request.
Expand Down
5 changes: 2 additions & 3 deletions src/simulator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ use js_sys::Array;
use serde::{Deserialize, Serialize};
use wasm_bindgen::prelude::*;

use crate::input_modeling::uniform_rng::UniformRNG;
use crate::models::model::{AsModel, Model};
use crate::models::ModelMessage;
use crate::input_modeling::UniformRNG;
use crate::models::{AsModel, Model, ModelMessage};
use crate::utils;
use crate::utils::error::SimulationError;

Expand Down

0 comments on commit ed4c13f

Please sign in to comment.