package com.yidianling.router

import com.yidianling.router.app.IAppRouter
import com.yidianling.router.consultant.IConsultantRouter
import com.yidianling.router.course.ICourseRouter
import com.yidianling.router.dynamic.IDynamicRouter
import com.yidianling.router.fm.IFMRouter
import com.yidianling.router.iRouter.BaseRouter
import com.yidianling.router.im.IIMRouter
import com.yidianling.router.phoneCall.IPhoneCallRouter
import com.yidianling.router.tests.ITestsRouter
import com.yidianling.router.user.IUserRouter

/**
 * 模块管理器
 * Created by hgw on 2018/3/15.
 */
object RouterManager {

    private val routerMap: HashMap<RouterEnum, BaseRouter> = HashMap()

    /**
     * 注册module
     */
    fun registerRouter(router : BaseRouter, moudleEnum: RouterEnum){
        routerMap.put(moudleEnum,router)
    }

    // 获取用户模块路由的实例
    fun getUserRouter(): IUserRouter? {
        return routerMap[RouterEnum.USER] as IUserRouter
    }

    fun getImRouter(): IIMRouter {
        return routerMap[RouterEnum.IM] as IIMRouter
    }

    fun getCourseRouter() : ICourseRouter?{
        return routerMap[RouterEnum.COURSE] as ICourseRouter
    }

    fun getConsultantRouter() : IConsultantRouter?{
        return routerMap.get(RouterEnum.CONSULTANT) as IConsultantRouter
    }

    fun getDynamicRouter() : IDynamicRouter?{
        return routerMap.get(RouterEnum.DYNAMIC) as IDynamicRouter
    }

    fun getFMRouter() : IFMRouter?{
        return routerMap.get(RouterEnum.FM) as IFMRouter
    }

    fun getPhoneCallRouter() : IPhoneCallRouter?{
        return routerMap.get(RouterEnum.PHONECALL) as IPhoneCallRouter
    }

    fun getTestsRouter() : ITestsRouter?{
        return routerMap.get(RouterEnum.TESTS) as ITestsRouter
    }

    fun getAppRouter(): IAppRouter? {
        return routerMap[RouterEnum.APP] as IAppRouter
    }

}