C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 记录界面大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道如何在我的应用程序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 – 记录界面所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: