pub mod gate;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct IdlFeatures {
pub corba_value_types_full: bool,
pub corba_value_types_extras: bool,
pub corba_repository_ids: bool,
pub corba_import: bool,
pub corba_local_interface: bool,
pub corba_abstract_interface: bool,
pub corba_object_base: bool,
pub corba_oneway_op: bool,
pub corba_context: bool,
pub corba_components: bool,
pub corba_homes: bool,
pub corba_eventtypes: bool,
pub corba_ports: bool,
pub corba_template_modules: bool,
pub corba_native: bool,
pub preprocessor_full: bool,
pub preprocessor_warning_line: bool,
pub vendor_rti: bool,
pub vendor_opensplice: bool,
pub vendor_opensplice_legacy: bool,
pub vendor_cyclonedds: bool,
pub vendor_fastdds: bool,
}
impl Default for IdlFeatures {
fn default() -> Self {
Self::dds_extensible()
}
}
impl IdlFeatures {
#[must_use]
pub const fn none() -> Self {
Self {
corba_value_types_full: false,
corba_value_types_extras: false,
corba_repository_ids: false,
corba_import: false,
corba_local_interface: false,
corba_abstract_interface: false,
corba_object_base: false,
corba_oneway_op: false,
corba_context: false,
corba_components: false,
corba_homes: false,
corba_eventtypes: false,
corba_ports: false,
corba_template_modules: false,
corba_native: false,
preprocessor_full: false,
preprocessor_warning_line: false,
vendor_rti: false,
vendor_opensplice: false,
vendor_opensplice_legacy: false,
vendor_cyclonedds: false,
vendor_fastdds: false,
}
}
#[must_use]
pub const fn all() -> Self {
Self {
corba_value_types_full: true,
corba_value_types_extras: true,
corba_repository_ids: true,
corba_import: true,
corba_local_interface: true,
corba_abstract_interface: true,
corba_object_base: true,
corba_oneway_op: true,
corba_context: true,
corba_components: true,
corba_homes: true,
corba_eventtypes: true,
corba_ports: true,
corba_template_modules: true,
corba_native: true,
preprocessor_full: true,
preprocessor_warning_line: true,
vendor_rti: true,
vendor_opensplice: true,
vendor_opensplice_legacy: true,
vendor_cyclonedds: true,
vendor_fastdds: true,
}
}
#[must_use]
pub const fn dds_basic() -> Self {
Self::none()
}
#[must_use]
pub const fn dds_extensible() -> Self {
let mut f = Self::none();
f.corba_native = true;
f
}
#[must_use]
pub const fn corba_full() -> Self {
Self {
corba_value_types_full: true,
corba_value_types_extras: true,
corba_repository_ids: true,
corba_import: true,
corba_local_interface: true,
corba_abstract_interface: true,
corba_object_base: true,
corba_oneway_op: true,
corba_context: true,
corba_components: true,
corba_homes: true,
corba_eventtypes: true,
corba_ports: true,
corba_template_modules: true,
corba_native: true,
preprocessor_full: true,
preprocessor_warning_line: true,
vendor_rti: false,
vendor_opensplice: false,
vendor_opensplice_legacy: false,
vendor_cyclonedds: false,
vendor_fastdds: false,
}
}
#[must_use]
pub const fn plain_corba() -> Self {
Self {
corba_value_types_full: true,
corba_value_types_extras: true,
corba_repository_ids: true,
corba_import: true,
corba_local_interface: true,
corba_abstract_interface: true,
corba_object_base: true,
corba_oneway_op: true,
corba_context: true,
corba_components: false,
corba_homes: false,
corba_eventtypes: false,
corba_ports: false,
corba_template_modules: false,
corba_native: true,
preprocessor_full: true,
preprocessor_warning_line: false,
vendor_rti: false,
vendor_opensplice: false,
vendor_opensplice_legacy: false,
vendor_cyclonedds: false,
vendor_fastdds: false,
}
}
#[must_use]
pub const fn minimum_corba() -> Self {
Self {
corba_value_types_full: false,
corba_value_types_extras: false,
corba_repository_ids: true,
corba_import: true,
corba_local_interface: true,
corba_abstract_interface: false,
corba_object_base: true,
corba_oneway_op: true,
corba_context: true,
corba_components: false,
corba_homes: false,
corba_eventtypes: false,
corba_ports: false,
corba_template_modules: false,
corba_native: true,
preprocessor_full: true,
preprocessor_warning_line: false,
vendor_rti: false,
vendor_opensplice: false,
vendor_opensplice_legacy: false,
vendor_cyclonedds: false,
vendor_fastdds: false,
}
}
#[must_use]
pub const fn ccm_profile() -> Self {
let mut f = Self::plain_corba();
f.corba_components = true;
f.corba_homes = true;
f.corba_eventtypes = true;
f
}
#[must_use]
pub const fn ccm_with_gis() -> Self {
let mut f = Self::ccm_profile();
f.corba_ports = true;
f.corba_template_modules = true;
f
}
#[must_use]
pub const fn rpc_over_dds() -> Self {
let mut f = Self::dds_extensible();
f.corba_oneway_op = true;
f.preprocessor_full = true;
f
}
#[must_use]
pub const fn opensplice_legacy() -> Self {
let mut f = Self::corba_full();
f.vendor_opensplice_legacy = true;
f.vendor_opensplice = true;
f
}
#[must_use]
pub const fn opensplice_modern() -> Self {
let mut f = Self::dds_extensible();
f.vendor_opensplice = true;
f.preprocessor_full = true;
f
}
#[must_use]
pub const fn rti_connext() -> Self {
let mut f = Self::dds_extensible();
f.vendor_rti = true;
f.preprocessor_full = true;
f
}
#[must_use]
pub const fn cyclonedds() -> Self {
let mut f = Self::dds_extensible();
f.vendor_cyclonedds = true;
f
}
#[must_use]
pub const fn fastdds() -> Self {
let mut f = Self::dds_extensible();
f.vendor_fastdds = true;
f
}
#[must_use]
pub const fn with_vendor_rti(mut self) -> Self {
self.vendor_rti = true;
self
}
#[must_use]
pub const fn with_opensplice_legacy(mut self) -> Self {
self.vendor_opensplice_legacy = true;
self.vendor_opensplice = true;
self
}
#[must_use]
pub const fn with_cyclonedds(mut self) -> Self {
self.vendor_cyclonedds = true;
self
}
#[must_use]
pub const fn with_fastdds(mut self) -> Self {
self.vendor_fastdds = true;
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_is_dds_extensible() {
assert_eq!(IdlFeatures::default(), IdlFeatures::dds_extensible());
}
#[test]
fn none_disables_everything() {
let f = IdlFeatures::none();
assert!(!f.corba_value_types_full);
assert!(!f.corba_components);
assert!(!f.corba_native);
assert!(!f.vendor_rti);
assert!(!f.preprocessor_full);
}
#[test]
fn all_enables_everything() {
let f = IdlFeatures::all();
assert!(f.corba_value_types_full);
assert!(f.corba_components);
assert!(f.corba_template_modules);
assert!(f.vendor_rti);
assert!(f.vendor_opensplice_legacy);
assert!(f.preprocessor_full);
}
#[test]
fn dds_basic_has_no_corba() {
let f = IdlFeatures::dds_basic();
assert!(!f.corba_value_types_full);
assert!(!f.corba_native);
assert!(!f.corba_components);
}
#[test]
fn dds_extensible_has_native_only() {
let f = IdlFeatures::dds_extensible();
assert!(f.corba_native);
assert!(!f.corba_value_types_full);
assert!(!f.corba_components);
assert!(!f.vendor_rti);
}
#[test]
fn corba_full_has_all_corba_no_vendor() {
let f = IdlFeatures::corba_full();
assert!(f.corba_value_types_full);
assert!(f.corba_components);
assert!(f.corba_template_modules);
assert!(f.preprocessor_full);
assert!(!f.vendor_rti);
assert!(!f.vendor_opensplice_legacy);
}
#[test]
fn opensplice_legacy_includes_corba_and_legacy_pragmas() {
let f = IdlFeatures::opensplice_legacy();
assert!(f.corba_value_types_full);
assert!(f.corba_components);
assert!(f.vendor_opensplice_legacy);
assert!(f.vendor_opensplice);
}
#[test]
fn opensplice_modern_is_extensible_plus_pragmas() {
let f = IdlFeatures::opensplice_modern();
assert!(f.corba_native);
assert!(f.vendor_opensplice);
assert!(!f.vendor_opensplice_legacy);
assert!(!f.corba_components);
}
#[test]
fn rti_connext_profile() {
let f = IdlFeatures::rti_connext();
assert!(f.corba_native);
assert!(f.vendor_rti);
assert!(!f.vendor_opensplice);
}
#[test]
fn cyclonedds_profile() {
let f = IdlFeatures::cyclonedds();
assert!(f.corba_native);
assert!(f.vendor_cyclonedds);
assert!(!f.vendor_rti);
}
#[test]
fn fastdds_profile() {
let f = IdlFeatures::fastdds();
assert!(f.corba_native);
assert!(f.vendor_fastdds);
assert!(!f.vendor_opensplice);
}
#[test]
fn additive_with_vendor_rti() {
let f = IdlFeatures::dds_extensible().with_vendor_rti();
assert!(f.vendor_rti);
assert!(f.corba_native);
}
#[test]
fn additive_with_opensplice_legacy_sets_both() {
let f = IdlFeatures::dds_extensible().with_opensplice_legacy();
assert!(f.vendor_opensplice);
assert!(f.vendor_opensplice_legacy);
}
#[test]
fn plain_corba_profile_matches_spec() {
let f = IdlFeatures::plain_corba();
assert!(f.corba_value_types_full);
assert!(f.corba_repository_ids);
assert!(f.corba_native);
assert!(!f.corba_components);
assert!(!f.corba_homes);
assert!(!f.corba_template_modules);
}
#[test]
fn minimum_corba_profile_matches_spec() {
let f = IdlFeatures::minimum_corba();
assert!(!f.corba_value_types_full);
assert!(!f.corba_value_types_extras);
assert!(f.corba_repository_ids);
assert!(f.corba_oneway_op);
assert!(!f.corba_components);
}
#[test]
fn ccm_profile_matches_spec() {
let f = IdlFeatures::ccm_profile();
assert!(f.corba_value_types_full);
assert!(f.corba_components);
assert!(f.corba_homes);
assert!(f.corba_eventtypes);
assert!(!f.corba_ports);
assert!(!f.corba_template_modules);
}
#[test]
fn ccm_with_gis_profile_matches_spec() {
let f = IdlFeatures::ccm_with_gis();
assert!(f.corba_components);
assert!(f.corba_ports);
assert!(f.corba_template_modules);
}
#[test]
fn rpc_over_dds_profile_matches_spec() {
let f = IdlFeatures::rpc_over_dds();
assert!(f.corba_native);
assert!(f.corba_oneway_op);
assert!(!f.corba_components);
}
#[test]
fn plain_dds_profile_matches_spec_exactly() {
let f = IdlFeatures::dds_basic();
assert!(!f.corba_native);
assert!(!f.corba_components);
assert!(!f.corba_value_types_full);
assert!(!f.vendor_rti);
assert!(!f.vendor_cyclonedds);
}
#[test]
fn dds_extensible_excludes_corba_components() {
let f = IdlFeatures::dds_extensible();
assert!(f.corba_native);
assert!(!f.corba_components);
assert!(!f.corba_homes);
assert!(!f.corba_template_modules);
}
}