#ifndef PERMISSIONSUPPORT_H
#define PERMISSIONSUPPORT_H
#include "IPermissionManager.h"

class IPermissionSupport {
public:
    inline void SetPermissionInstance(IPermissionManager& pPermissionManager)
    {
        m_pPermissionManager = &pPermissionManager;
    }
    //! 设置当前拥有的权限
    inline void AddPermmision(int iPermissionId)
    {
        m_iPermissionId = iPermissionId;
    }
    inline bool HasPermission()
    {
        if (m_pPermissionManager) {
            return m_pPermissionManager->HasPermission(m_iPermissionId);
        } else {
            return true;
        }
    }

    inline bool HasFactoryPermission()
    {
        return true;
        if (m_pPermissionManager) {
            return m_pPermissionManager->HasPermission(0);
        } else {
            return true;
        }
    }

    inline std::string GetPermissionName()
    {
        if (m_pPermissionManager) {
            return m_pPermissionManager->GetPermissionName(m_iPermissionId);
        } else {
            return "N/A";
        }
    }

    inline std::string GetPermissionName(int permissionId)
    {
        if (m_pPermissionManager) {
            m_pPermissionManager->GetPermissionName(permissionId);
        }

        return "N/A";
    }

    inline int GetPermissionId(std::string permissionName)
    {
        if (m_pPermissionManager) {
            m_pPermissionManager->GetPermissionId(permissionName);
        }
    }

    inline bool HasPermission(std::string permissioName)
    {
        if (m_pPermissionManager) {
            m_pPermissionManager->HasPermission(permissioName);
        }

        return false;
    }

    inline bool HasPermission(int permissionId)
    {
        if (m_pPermissionManager) {
            m_pPermissionManager->HasPermission(permissionId);
        }

        return false;
    }

	void FreshAuthority() {};

private:
    IPermissionManager *m_pPermissionManager = nullptr;
    int m_iPermissionId = 0;
};

#endif // IPERMISSIONSUPPORT_H
