c – 记录界面

c – 记录界面,第1张

概述我想知道如何在我的应用程序IResource中记录接口.由于我正在编写引擎而不是库,我认为文档应该给出关于如何编写接口实现的指导;这样可以吗? 另外,请您查看我的界面并告诉我评论是否足够清晰? /** Interface that should be implemented by all resources. Implementing this interface is neces 我想知道如何在我的应用程序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中继承的文档功能.虽然您的注释对接口类有效,但它们对于实现该接口的某些类无效.

总结

以上是内存溢出为你收集整理的c – 记录界面全部内容,希望文章能够帮你解决c – 记录界面所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1213722.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存