/**
 * @author Martin Karkowski
 * @email m.karkowski@zema.de
 */
import { ILogger } from "js-logger";
import { IAvailableInstancesMsg, ICommunicationBridge, IGenericNopeModule, IInstanceCreationMsg, IInstanceDescriptionMsg, IMapBasedMergeData, INopeConnectivityManager, INopeCore, INopeDispatcherOptions, INopeEventEmitter, INopeModule, INopeModuleDescription, INopeObservable, INopeRpcManager, INopeStatusInfo, TValidAsssignmentChecker, ValidSelectorFunction } from "../../types/nope";
import { INopeInstanceManager, TConstructorCallback, TGenerateWrapperCallback } from "../../types/nope/nopeInstanceManager.interface";
/**
 * Please checkout the Docu of {@link INopeInstanceManager}
 */
export declare class NopeInstanceManager implements INopeInstanceManager {
    options: INopeDispatcherOptions;
    protected _generateEmitter: <T>() => INopeEventEmitter<T>;
    protected _generateObservable: <T>() => INopeObservable<T>;
    protected _defaultSelector: ValidSelectorFunction;
    protected readonly _id: string;
    protected _connectivityManager: INopeConnectivityManager;
    protected _rpcManager: INopeRpcManager;
    protected _core: INopeCore;
    protected _logger: ILogger;
    /**
     * The used Communication interface
     *
     */
    protected readonly _communicator: ICommunicationBridge;
    /**
     * Flag to indicate, that the system is ready.
     *
     * @author M.Karkowski
     * @type {INopeObservable<boolean>}
     * @memberof NopeInstanceManager
     */
    readonly ready: INopeObservable<boolean>;
    /**
     * Element holding the Mapping of the Dispatcher and its instance
     * generators
     *
     * Key = Dispatcher-ID
     * Value = Available Generators
     *
     * @protected
     * @type {Map<
     *     string,
     *     IAvailableInstanceGeneratorsMsg
     *   >}
     * @memberof NopeInstanceManager
     */
    protected _mappingOfRemoteDispatchersAndGenerators: Map<string, string[]>;
    protected _internalWrapperGenerators: Map<string, TGenerateWrapperCallback<INopeModule>>;
    protected _registeredConstructors: Map<string, (...args: any[]) => Promise<IInstanceDescriptionMsg>>;
    protected _instances: Map<string, {
        instance: INopeModule;
        usedBy: Array<string>;
        manual?: boolean;
    }>;
    protected _internalInstances: Set<string>;
    protected _mappingOfRemoteDispatchersAndInstances: Map<string, IAvailableInstancesMsg>;
    protected _externalInstancesNames: Set<string>;
    protected _externalInstances: Map<string, INopeModuleDescription>;
    protected _initializingInstance: Map<string, string>;
    /**
     * Element showing the available services.
     * Its more or less a map, that maps the
     * services with their dispatchers.
     *
     * T = services name.
     * K = dispatcher - ids
     *
     * @author M.Karkowski
     * @type {IMapBasedMergeData<string>}
     * @memberof NopeInstanceManager
     */
    readonly constructors: IMapBasedMergeData<string, // Dispatcher ID
    string[], string, // Dispatcher ID
    string>;
    /**
     * Element showing the available instances.
     * Its more or less a map, that maps the
     * instances with their dispatchers.
     *
     * - `originalKey` = DispatcherID (`string`);
     * - `originalValue` = Available Instance Messages (`IAvailableInstancesMsg`);
     * - `extractedKey` = The name of the Instance (`string`);`
     * - `extractedValue` = instance-description (`INopeModuleDescription`);
     *
     * @author M.Karkowski
     * @type {IMapBasedMergeData<
     *     string,
     *     string,
     *     IAvailableInstancesMsg
     *   >}
     * @memberof NopeInstanceManager
     */
    readonly instances: IMapBasedMergeData<string, // Dispatcher ID
    IAvailableInstancesMsg, // Available Instance Messages
    string, // The name of the Instance?
    INopeModuleDescription>;
    readonly constructorServices: INopeObservable<string[]>;
    /**
     * Contains the identifiers of the instances, which are hosted in the provided dispatcher.
     *
     * @author M.Karkowski
     * @type {INopeObservable<string[]>}
     * @memberof NopeInstanceManager
     */
    readonly internalInstances: INopeObservable<string[]>;
    /**
     * Create the Instance Manager.
     */
    constructor(options: INopeDispatcherOptions, _generateEmitter: <T>() => INopeEventEmitter<T>, _generateObservable: <T>() => INopeObservable<T>, _defaultSelector: ValidSelectorFunction, _id?: string, _connectivityManager?: INopeConnectivityManager, _rpcManager?: INopeRpcManager, _core?: INopeCore);
    /**
     * Update the Available Instances
     *
     * @protected
     * @memberof NopeInstanceManager
     */
    protected _sendAvailableInstances(): Promise<void>;
    /**
     * Internal Function, used to initialize the Dispatcher.
     * It subscribes to the "Messages" of the communicator.
     *
     * @protected
     * @memberof NopeInstanceManager
     */
    protected _init(): Promise<void>;
    /**
     * Helper to get the corresponding Service name
     * @param {string} name  name
     * @param {"constructor" | "dispose"} type The desired type of the requested service name
     * @returns {string} the name.
     */
    getServiceName(name: string, type: "constructor" | "dispose"): string;
    /**
     * Function, that will extract the information of the instance and the
     * the providing dispatcher.
     *
     * @author M.Karkowski
     * @param {string} identifier The identifier of instance
     * @return {*}  {(INopeModuleDescription & { dispatcher: IDispatcherInfo })}
     * @memberof nopeDispatcher
     */
    protected _getInstanceInfo(identifier: string): {
        description: INopeModuleDescription;
        dispatcher: INopeStatusInfo;
    } | undefined;
    /**
     * Helper to remove a dispatcher.
     *
     * @author M.Karkowski
     * @param {string} dispatcher
     * @memberof NopeRpcIn
     */
    removeDispatcher(dispatcher: string): void;
    registerConstructor<I extends INopeModule>(identifier: string, cb: TConstructorCallback<I>): Promise<void>;
    unregisterConstructor(identifier: string): Promise<void>;
    registerInternalWrapperGenerator<I extends INopeModule>(identifier: string, cb: TGenerateWrapperCallback<I>): void;
    unregisterInternalWrapperGenerator(identifier: string): void;
    instanceExists(identifier: string, externalOnly?: boolean): boolean;
    getManagerOfInstance(identifier: string): INopeStatusInfo | undefined;
    getInstanceDescription(instanceIdentifier: string): false | INopeModuleDescription;
    constructorExists(typeIdentifier: string): boolean;
    generateWrapper<I = IGenericNopeModule>(description: Partial<IInstanceCreationMsg>): Promise<I & IGenericNopeModule>;
    createInstance<I = IGenericNopeModule>(description: Partial<IInstanceCreationMsg>, options?: {
        selector?: ValidSelectorFunction;
        assignmentValid?: TValidAsssignmentChecker;
        linkProperties?: boolean;
        linkEvents?: boolean;
    }): Promise<I & IGenericNopeModule>;
    registerInstance<I extends INopeModule>(instance: I): Promise<I>;
    deleteInstance<I extends INopeModule>(instance: I | string, preventSendingUpdate?: boolean, callInstanceDispose?: boolean): Promise<boolean>;
    getInstancesOfType<I extends INopeModule>(type: string): Promise<I[]>;
    reset(): void;
    /**
     * Describes the Data.
     * @returns
     */
    toDescription(): {
        constructors: {
            all: string[];
            internal: string[];
        };
        instances: {
            all: INopeModuleDescription[];
            internal: string[];
        };
    };
    dispose(): Promise<void>;
}
