/**
 * 注册表基类
 * 统一管理注册表的通用操作
 */

/**
 * 通用注册表基类
 */
export class BaseRegistry<TKey extends string | number | symbol, TValue> {
  protected registry: Record<TKey, TValue> = {} as Record<TKey, TValue>;

  /**
   * 注册配置
   */
  register(key: TKey, value: TValue): void {
    this.registry[key] = value;
  }

  /**
   * 获取配置
   */
  get(key: TKey): TValue | undefined {
    return this.registry[key];
  }

  /**
   * 检查是否已注册
   */
  has(key: TKey): boolean {
    return key in this.registry;
  }

  /**
   * 获取所有已注册的键
   */
  getAllKeys(): TKey[] {
    return Object.keys(this.registry) as TKey[];
  }

  /**
   * 获取注册表大小
   */
  size(): number {
    return Object.keys(this.registry).length;
  }
}

