tgqe 0.0.1

The Great Qin Empire —— A centralized system for integrating and summarizing common compiler front-end library errors and span error output libraries, with optional Ariadne integration.
/**

 *  - Copyright (c) 星灿长风v(Starwindv) 2026/08/03
 *  - License: BSD-3
 *  - Author: 星灿长风v(StarWindv)
 *  - Location: tgqe/src/modules/singletons.rs
 */
/**

 * ## I. What
 *
 * ### 1.1 Description
 *
 * This module holds the global singletons of this library.
 *
 * - `SourceManager`: the global `TgqeSourceCache` instance.
 * - `ICC` (Imperial Censor-in-Chief): the global `TgqeBus` instance,
 *   which collects, renders and stores error contexts.
 * - `ERROR_COUNTER`: a global counter counting how many errors
 *   have been processed.
 * - `Configure`: the global `TgqeConfig` instance.
 * - `DBManager`: the global `SQLite` manager
 *   (with the `store-to-db` feature).
 */
use crate::base_types::TgqeSourceCache;
#[cfg(feature = "renderer")]
use crate::channel::bus::TgqeBus;
#[cfg(feature = "renderer")]
use std::sync::atomic::AtomicU64;
use std::sync::{LazyLock, Mutex};

#[allow(non_upper_case_globals)]
pub static SourceManager: LazyLock<
    Mutex<TgqeSourceCache>,
> = LazyLock::new(|| {
    Mutex::from(TgqeSourceCache::new())
});

// Imperial Censor-in-Chie
#[cfg(feature = "renderer")]
#[allow(non_upper_case_globals)]
pub static ICC: LazyLock<Mutex<TgqeBus>> =
    LazyLock::new(|| {
        Mutex::new(TgqeBus::new())
    });

#[cfg(feature = "renderer")]
pub static ERROR_COUNTER: AtomicU64 =
    AtomicU64::new(0);

#[cfg(any(
    feature = "renderer",
    feature = "store-to-db"
))]
#[allow(non_upper_case_globals)]
pub(crate) static Configure: LazyLock<
    crate::modules::channel::configure::TgqeConfig,
> = LazyLock::new(crate::modules::channel::configure::TgqeConfig::load);

#[cfg(feature = "store-to-db")]
#[allow(non_upper_case_globals)]
pub static DBManager: LazyLock<
    Mutex<crate::channel::sqlite::SQLite>,
> = LazyLock::new(|| {
    Mutex::new(
        crate::channel::sqlite::SQLite::new(
        ),
    )
});