0
我已經寫了一個相當簡單的類的文檔,但我覺得它不夠清楚。我應該改變什麼嗎?此文檔缺少任何內容嗎?
/**
Pointer class that wraps resources loaded through the ResourceManager.
The manager is notified to increase or decrease the reference count of
a resource, as a ResourcePtr gets copied, created, or deleted.
If a resource has a reference count of zero, the ResourceManager will
delete it. The reference count of a resource is the same as the number
of ResourcePtr objects that reference it.
\see ResourceManager
*/
template<class T>
class ResourcePtr
{
public:
/**
Default constructor. Creates an empty ResourcePtr that does not
reference any resource.
*/
ResourcePtr();
/**
Copy constructor. Create a copy and increase the reference count
of the resource referenced by the ResourcePtr being copied, if any.
*/
ResourcePtr(const ResourcePtr<T>& other);
/**
Destroy the ResourcePtr and release one reference to the resource
it points to, if any. The resource is deleted if there are no more
ResourcePtr objects that reference it.
*/
~ResourcePtr();
/**
Access the resource inside the ResourcePtr.
\return Pointer to the resource or null if ResourcePtr is empty.
*/
const T* get() const;
/**
Arrow operator. Provided for convenience to access members of
the resource class directly, without having to first call get().
An assertion failure occurs if the ResourcePtr is empty.
*/
const T* operator->() const;
/**
Assignment operator. Release the resource currently pointing to,
if any. Copy the data from the other ResourcePtr and increase
the reference count of the resource it points to, if any.
*/
ResourcePtr<T>& operator=(const ResourcePtr<T>& other);
private:
friend class ResourceManager<T>;
typename std::list<typename
ResourceManager<T>::ResourceWrapper*>::iterator iter_;
};
我也認爲意圖應該是相當明顯的,但我遵循boost :: shared_ptr的文檔,他們在那裏記錄所有這些東西。由於斷言,可能唯一留下來的是'operator->'的註釋。也許也是班上的一個。你怎麼看? – 2011-06-11 14:17:38
是的,我只想評論這個課程。另外,我並不喜歡自動生成的文檔(我認爲你打算製作),因爲我從來沒有真正遇到過這麼多的用途。 – 2011-06-11 14:20:35
我真的不知道我是否會從此生成任何文檔。我只是想,如果在寫完一個模塊之後,我還會爲它編寫文檔。 Doxygen標籤在那裏,因爲我喜歡他們使評論更加結構化。 – 2011-06-11 14:24:20