/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2022-04-01 15:07:56
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-04-11 10:57:16
 */
#ifndef __ISNS_MODEL_HPP_
#define __ISNS_MODEL_HPP_

#include <string.h>
#include <unistd.h>
#include <string>
#include <vector>
#include <iostream>
#include "private/ins_module_private.hpp"

using namespace std;

namespace ins{
    class ModelCenter:private NonCopyable 
    {
    private:
        ModelCenter(){}
    public:
        using Ptr = std::shared_ptr<ModelCenter>;
        
        ~ModelCenter(){}

        /**
         * @description: 注册
         * @param {string} ModelName
         * @param {Ptr&} ptr
         * @return {*}
         */        
        static int8_t Register(std::string ModelName);

        /**
         * @description: 注销
         * @param {string} ModelName
         * @return {*}
         */        
        static int8_t Cancel(std::string ModelName);

        /**
         * @description: 获取getModels
         * @param {*}
         * @return {*}
         */        
        static vector<std::string> getModels();
    };

    class Module: private NonCopyable 
    {
    public:
        using Ptr = std::shared_ptr<Module>;

        Module(std::string name): name_(name) {
            ins::ModelCenter::Register(name);
        }
        
        virtual ~Module(){
            ins::ModelCenter::Cancel(name_);
        }

        /**
         * @description: 初始化
         * @param {*}
         * @return {*}
         */        
        virtual int8_t Init() = 0;

        /**
         * @description: 销毁
         * @param {*}
         * @return {*}
         */        
        virtual void Destroy() = 0;

        /**
         * @description: 是否正常
         * @param {*}
         * @return {*}
         */        
        virtual bool isNormally() = 0;

        /**
         * @description: 返回名字
         * @param {*}
         * @return {*}
         */        
        virtual std::string getName(){
            return this->name_;
        }

        
    
    protected:
        bool valid = false;
        std::string name_;
    }; 
};


#endif