UNPKG

@mlightcad/data-model

Version:

The data-model package provides the core classes for interacting with AutoCAD's database and entities. This package mimics AutoCAD ObjectARX's AcDb (Database) classes and implements the drawing database structure that AutoCAD developers are familiar with.

118 lines 4.25 kB
import { AcDbLayoutManager } from '../object/layout/AcDbLayoutManager'; /** * Returns the singleton instance of the host application services. * * This function provides access to the global AcDbHostApplicationServices instance * that manages various services for host applications at runtime. * * @returns The singleton instance of AcDbHostApplicationServices * @example * ```typescript * const services = acdbHostApplicationServices(); * const database = services.workingDatabase; * ``` */ export function acdbHostApplicationServices() { return AcDbHostApplicationServices.instance; } /** * The AcDbHostApplicationServices class provides various services to host applications at runtime. * * This class implements the singleton pattern and manages: * - Working database reference * - Layout manager instance * - Other application-wide services * * @example * ```typescript * const services = acdbHostApplicationServices(); * services.workingDatabase = new AcDbDatabase(); * const layoutManager = services.layoutManager; * ``` */ var AcDbHostApplicationServices = /** @class */ (function () { /** * Private constructor to enforce singleton pattern. * Initializes the layout manager. */ function AcDbHostApplicationServices() { /** The current working database instance */ this._workingDatabase = null; this._layoutManager = new AcDbLayoutManager(); } Object.defineProperty(AcDbHostApplicationServices.prototype, "workingDatabase", { /** * Gets the current working database. * * The working database is the primary database that the application * is currently operating on. This must be set before it can be accessed. * * @returns The current working database * @throws {Error} When the working database has not been set * @example * ```typescript * const services = acdbHostApplicationServices(); * try { * const db = services.workingDatabase; * // Use the database * } catch (error) { * console.error('Working database not set'); * } * ``` */ get: function () { if (this._workingDatabase == null) { throw new Error('The current working database must be set before using it!'); } else { return this._workingDatabase; } }, /** * Sets the working database. * * This method sets the database that will be used as the current working database * for the application. This database will be returned by the workingDatabase getter. * * @param database - The database to make the new working database * @example * ```typescript * const services = acdbHostApplicationServices(); * const db = new AcDbDatabase(); * services.workingDatabase = db; * ``` */ set: function (database) { this._workingDatabase = database; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbHostApplicationServices.prototype, "layoutManager", { /** * Gets the layout manager instance. * * The layout manager is responsible for managing layout objects in the application. * This is a singleton instance that is created when the AcDbHostApplicationServices * is instantiated. * * @returns The layout manager instance * @example * ```typescript * const services = acdbHostApplicationServices(); * const layoutManager = services.layoutManager; * // Use the layout manager * ``` */ get: function () { return this._layoutManager; }, enumerable: false, configurable: true }); /** The singleton instance of AcDbHostApplicationServices */ AcDbHostApplicationServices.instance = new AcDbHostApplicationServices(); return AcDbHostApplicationServices; }()); export { AcDbHostApplicationServices }; //# sourceMappingURL=AcDbHostApplicationServices.js.map