加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 记录界面

发布时间:2020-12-16 09:35:12 所属栏目:百科 来源:网络整理
导读:我想知道如何在我的应用程序IResource中记录接口.由于我正在编写引擎而不是库,我认为文档应该给出关于如何编写接口实现的指导;这样可以吗? 另外,请您查看我的界面并告诉我评论是否足够清晰? /** Interface that should be implemented by all resources. I
我想知道如何在我的应用程序IResource中记录接口.由于我正在编写引擎而不是库,我认为文档应该给出关于如何编写接口实现的指导;这样可以吗?

另外,请您查看我的界面并告诉我评论是否足够清晰?

/**
    Interface that should be implemented by all resources. Implementing
    this interface is necessary for compatibility with the ResourceManager
    class template.

    note Documentation of this interface includes guidelines on how
    implementations should be written.

    see ResourceManager
                                                                              */
class IResource
{
  public:
    /**
        Loads resource data from a file. If data is already loaded,the function should return immediately.

        throw std::exception Should throw on any failure to load the
        resource. If the resource is already loaded,don't throw,just
        return (as previously indicated).

        note Access to this function should also be provided directly
        from a constructor. That constructor should catch any exceptions
        and throw them further to its caller.
                                                                              */
    virtual void loadFromFile(const std::string& file) = 0 ;
    /**
        All general guidelines from loadFromFile() also apply to this
        function. Additionally,the resource should not take possession of
        the buffer; the buffer should be safe to delete after loading.
                                                                              */
    virtual void loadFromMemory(const char* buffer,std::size_t size) = 0;
    /**
        Frees the data currently held by the resource object. Should
        return immeditelly if no data is loaded.
                                                                              */
    virtual void free() = 0;
    virtual bool isLoaded() const = 0;
};

编辑:打开相关讨论.

主要是在Johann Gerell’s answer的评论部分中的对话,我在programmers.stackexchange上打开了一个相当冗长的线程.你可以在这里查看:
> Single-responsibility and custom data types

解决方法

你已经很好地记录了这个意图,这是一个非常好的开始.

缺少一些东西:

>你没有记录参数.它们是自我显而易见的,但我可能有点迂腐(同样适用于doxygen).> isLoaded做了什么?>关闭doxygen中继承的文档功能.虽然您的注释对接口类有效,但它们对于实现该接口的某些类无效.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读