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Routes} from 'routable-component';\nimport {NamedKernelManagerGhostModule} from './named-kernel-manager-ghost-module';\n\n/**\n * ルーティング設定クラスのリスト\n * @type {RoutableComponentRouting[]}\n */\nexport const NamedKernelManagerRoutings = [];\n\n/**\n * コントローラクラスの連想配列\n * @type {Hash<NamedKernelManagerController>}\n */\nexport const NamedKernelManagerControllers = {};\n\n/** Ukagaka baseware named manager */\nexport class NamedKernelManager extends RoutableComponent {\n /**\n * constructor\n * @param {Object} components - Event source\n * @param {NanikaStorage} components.NanikaStorage - storage\n * @param {NamedManager} components.NamedManager - named manager\n * @param {TimerEventSource} components.TimerEventSource - Timer event source\n * @param {RoutableComponentRoutes} [routes] - ルーティング\n * @param {Hash<NamedKernelManagerController>} [controllers_classes] - コントローラ\n */\n constructor(components, routes = new RoutableComponentRoutes(NamedKernelManagerRoutings), controllerClasses = NamedKernelManagerControllers) {\n super(components, routes, controllerClasses);\n this.registerComponent('NamedKernelManager', this);\n\n /** @type {NamedKernel[]} */\n this._namedKernels = {};\n }\n\n /**\n * start manager (emits start event)\n * @return {void}\n */\n async start() {\n this.emit('start');\n }\n\n /**\n * boot named (emits boot event)\n * @param {string} namedId named id\n * @param {string} fromNamedId from named id\n * @return {void}\n */\n async bootNamed(namedId, fromNamedId) {\n this.emit('boot_named', namedId, fromNamedId);\n }\n\n /**\n * close named (emits close event)\n * @param {string} namedId named id\n * @param {string} fromNamedId from named id\n * @return {void}\n */\n async closeNamed(namedId, fromNamedId) {\n this.emit('close_named', namedId);\n }\n\n /**\n * change named (emits change event)\n * @param {string} namedId named id\n * @param {string} fromNamedId from named id\n * @return {void}\n */\n async changeNamed(namedId, fromNamedId) {\n this.emit('change_named', namedId, fromNamedId);\n }\n\n /**\n * close manager (emits close event)\n * @return {void}\n */\n async close() {\n this.emit('close');\n }\n\n /**\n * halt manager (emits halt event)\n * @return {void}\n */\n async halt() {\n this.emit('halt');\n }\n\n profile(newProfile) {\n return this.components.NanikaStorage.base_profile(newProfile);\n }\n\n /**\n * existing named ids\n * @return {Array<string>} named ids\n */\n namedIds() {\n return Object.keys(this._namedKernels);\n }\n\n /**\n * named instance exists or not\n * @param {string} namedId - named id\n * @return {boolean} exists or not\n */\n isKernelExists(namedId) {\n // in や [] 等ではprototypeのものも認識するため\n return this._namedKernels.hasOwnProperty(namedId);\n }\n\n /**\n * named kernel instance\n * @param {string} namedId - named id\n * @return {NamedKernel} named instance\n */\n kernel(namedId) {\n return this.isKernelExists(namedId) ? this._namedKernels[namedId].kernel : null;\n }\n\n /**\n * find named id of a kernel\n * @param {NamedKernel} kernel - named kernel\n * @return {string} named id\n */\n namedId(kernel) {\n return Object.keys(this._namedKernels).find((namedId) => this.kernel(namedId) === kernel);\n }\n\n /**\n * register named kernel\n * @param {string} namedId - named id\n * @param {NamedKernel} kernel - kernel\n * @return {NamedKernel} kernel\n */\n registerKernel(namedId, kernel) {\n if (this.isKernelExists(namedId)) {\n throw new Error(`kernel [${namedId}] already exists`);\n }\n this._namedKernels[namedId] = {kernel};\n this.emit('kernel_registered', namedId);\n return kernel;\n }\n\n /**\n * unregister named kernel\n * @param {string} namedId - named id\n * @return {void}\n */\n unregisterKernel(namedId) {\n if (!this.isKernelExists(namedId)) {\n throw new Error(`kernel [${namedId}] not exists`);\n }\n delete this._namedKernels[namedId];\n this.emit('kernel_unregistered', namedId);\n }\n\n /**\n * send communication\n * @param {string} fromId - from named id\n * @param {string} toId - to named id\n * @param {any} content - communication content\n * @return {Promise<transactionlike>} transaction\n */\n sendCommunication(fromId, toId, content) {\n }\n\n /**\n * send notice\n * @param {string} fromId - from named id\n * @param {string} toId - to named id\n * @param {any} content - communication content\n * @return {Promise<transactionlike>} transaction\n */\n sendNotice(fromId, toId, content) {\n // other close etc\n }\n\n /**\n * install named\n * @param {any} target install target resource (file, url or some)\n * @param {NamedKernel} from who handled the target?\n * @return {Promise<any>}\n */\n async installNamed(target, from) {\n // TODO: 他形式対応\n return await this.installNar(target, from);\n }\n}\n\nmixin(NamedKernelManager, NamedKernelManagerGhostModule);\n\n/**\n * マネージャ用のコントローラ\n * @implements {RoutableComponentController}\n */\nexport class NamedKernelManagerController {\n /**\n * コンストラクタ\n * @param {NamedKernelManager} manager マネージャ\n */\n constructor(manager) {\n this._manager = manager;\n }\n\n /**\n * マネージャ\n * @type {NamedKernelManager}\n */\n get manager() { return this._manager; }\n}\n"]}