Doxygen
reflist.h
浏览该文件的文档.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2020 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #ifndef REFLIST_H
17 #define REFLIST_H
18 
19 #include <vector>
20 #include <unordered_map>
21 #include <memory>
22 
23 #include "qcstring.h"
24 #include "linkedmap.h"
25 
26 class Definition;
27 class RefList;
28 
29 /** This struct represents an item in the list of references. */
30 class RefItem
31 {
32  public:
33  RefItem(int id,RefList *list) : m_id(id), m_list(list) {}
34 
35  void setText (const QCString &text) { m_text = text; }
36  void setAnchor(const QCString &anchor) { m_anchor = anchor; }
37  void setPrefix(const QCString &prefix) { m_prefix = prefix; }
38  void setName (const QCString &name) { m_name = name; }
39  void setTitle (const QCString &title) { m_title = title; }
40  void setArgs (const QCString &args) { m_args = args; }
41  void setGroup (const QCString &group) { m_group = group; }
42  void setScope (const Definition *scope) { m_scope = scope; }
43 
44  QCString text() const { return m_text; }
45  QCString anchor() const { return m_anchor; }
46  QCString prefix() const { return m_prefix; }
47  QCString name() const { return m_name; }
48  QCString title() const { return m_title; }
49  QCString args() const { return m_args; }
50  QCString group() const { return m_group; }
51  int id() const { return m_id; }
52  RefList *list() const { return m_list; }
53  const Definition *scope() const { return m_scope; }
54 
55  private:
56  int m_id = 0; //!< unique identifier for this item within its list
57  RefList *m_list; //!< list owning this item
58  QCString m_text; //!< text of the item.
59  QCString m_anchor; //!< anchor in the list
60  QCString m_prefix; //!< type prefix for the name
61  QCString m_name; //!< name of the entity containing the reference
62  QCString m_title; //!< display name of the entity
63  QCString m_args; //!< optional arguments for the entity (if function)
64  QCString m_group; //!< group id used to combine item under a single header
65  const Definition *m_scope = 0; //!< scope to use for references.
66 };
67 
68 /** List of cross-referenced items
69  *
70  * This class represents a list of items that are put
71  * at a certain point in the documentation by some special command
72  * and are collected in a list. The items cross-reference the
73  * documentation and the list.
74  *
75  * Examples are the todo list, the test list and the bug list,
76  * introduced by the \\todo, \\test, and \\bug commands respectively.
77  */
78 class RefList
79 {
80  public:
81  /*! Create a list of items that are cross referenced with documentation blocks
82  * @param listName String representing the name of the list.
83  * @param pageTitle String representing the title of the list page.
84  * @param secTitle String representing the title of the section.
85  */
86  RefList(const QCString &listName, const QCString &pageTitle, const QCString &secTitle);
87  bool isEnabled() const;
88 
89  /*! Adds a new item to the list.
90  * @returns A unique id for this item.
91  */
92  RefItem *add();
93 
94  /*! Returns an item given it's id that is obtained with addRefItem()
95  * @param itemId item's identifier.
96  * @returns A pointer to the todo item's structure.
97  */
98  RefItem *find(int itemId);
99 
100  QCString listName() const { return m_listName; }
101  QCString fileName() const { return m_fileName; }
102  QCString pageTitle() const { return m_pageTitle; }
103  QCString sectionTitle() const { return m_secTitle; }
104 
105  void generatePage();
106 
107  private:
108  int m_id = 0;
113  std::vector< std::unique_ptr< RefItem > > m_entries;
114  std::unordered_map< int, RefItem* > m_lookup;
115 };
116 
117 class RefListManager : public LinkedMap<RefList>
118 {
119  public:
121  {
122  static RefListManager rlm;
123  return rlm;
124  }
125 
126  private:
128  RefListManager(const RefListManager &other) = delete;
129  RefListManager &operator=(const RefListManager &other) = delete;
130 };
131 
132 using RefItemVector = std::vector<RefItem*>;
133 
134 #endif
RefItem::title
QCString title() const
Definition: reflist.h:48
RefItem::text
QCString text() const
Definition: reflist.h:44
RefItem::m_anchor
QCString m_anchor
anchor in the list
Definition: reflist.h:59
RefList::m_id
int m_id
Definition: reflist.h:108
RefList::m_secTitle
QCString m_secTitle
Definition: reflist.h:112
RefListManager::instance
static RefListManager & instance()
Definition: reflist.h:120
RefItem::m_title
QCString m_title
display name of the entity
Definition: reflist.h:62
RefItem::setScope
void setScope(const Definition *scope)
Definition: reflist.h:42
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
RefItem::m_id
int m_id
unique identifier for this item within its list
Definition: reflist.h:56
RefItem::setGroup
void setGroup(const QCString &group)
Definition: reflist.h:41
RefItem
This struct represents an item in the list of references.
Definition: reflist.h:30
RefItem::m_prefix
QCString m_prefix
type prefix for the name
Definition: reflist.h:60
RefList::add
RefItem * add()
Definition: reflist.cpp:30
RefItem::m_args
QCString m_args
optional arguments for the entity (if function)
Definition: reflist.h:63
RefListManager::RefListManager
RefListManager()
Definition: reflist.h:127
qcstring.h
RefList::RefList
RefList(const QCString &listName, const QCString &pageTitle, const QCString &secTitle)
Definition: reflist.cpp:24
RefItem::group
QCString group() const
Definition: reflist.h:50
linkedmap.h
RefList::generatePage
void generatePage()
Definition: reflist.cpp:55
RefList::m_entries
std::vector< std::unique_ptr< RefItem > > m_entries
Definition: reflist.h:113
RefItem::setPrefix
void setPrefix(const QCString &prefix)
Definition: reflist.h:37
RefItem::setArgs
void setArgs(const QCString &args)
Definition: reflist.h:40
RefList
List of cross-referenced items
Definition: reflist.h:78
RefList::find
RefItem * find(int itemId)
Definition: reflist.cpp:40
RefItem::setTitle
void setTitle(const QCString &title)
Definition: reflist.h:39
RefItem::scope
const Definition * scope() const
Definition: reflist.h:53
RefItem::setText
void setText(const QCString &text)
Definition: reflist.h:35
RefListManager
Definition: reflist.h:117
RefList::listName
QCString listName() const
Definition: reflist.h:100
RefItem::m_group
QCString m_group
group id used to combine item under a single header
Definition: reflist.h:64
RefItem::m_scope
const Definition * m_scope
scope to use for references.
Definition: reflist.h:65
RefItem::anchor
QCString anchor() const
Definition: reflist.h:45
RefItemVector
std::vector< RefItem * > RefItemVector
Definition: reflist.h:132
RefList::m_listName
QCString m_listName
Definition: reflist.h:109
RefListManager::operator=
RefListManager & operator=(const RefListManager &other)=delete
RefList::m_fileName
QCString m_fileName
Definition: reflist.h:110
RefList::pageTitle
QCString pageTitle() const
Definition: reflist.h:102
RefItem::m_text
QCString m_text
text of the item.
Definition: reflist.h:58
RefList::m_lookup
std::unordered_map< int, RefItem * > m_lookup
Definition: reflist.h:114
RefItem::list
RefList * list() const
Definition: reflist.h:52
RefItem::setName
void setName(const QCString &name)
Definition: reflist.h:38
RefItem::prefix
QCString prefix() const
Definition: reflist.h:46
RefItem::m_list
RefList * m_list
list owning this item
Definition: reflist.h:57
RefList::isEnabled
bool isEnabled() const
Definition: reflist.cpp:46
RefItem::RefItem
RefItem(int id, RefList *list)
Definition: reflist.h:33
LinkedMap
Container class representing a vector of objects with keys.
Definition: linkedmap.h:35
RefItem::args
QCString args() const
Definition: reflist.h:49
RefList::m_pageTitle
QCString m_pageTitle
Definition: reflist.h:111
RefList::sectionTitle
QCString sectionTitle() const
Definition: reflist.h:103
RefItem::id
int id() const
Definition: reflist.h:51
RefItem::m_name
QCString m_name
name of the entity containing the reference
Definition: reflist.h:61
RefItem::name
QCString name() const
Definition: reflist.h:47
RefList::fileName
QCString fileName() const
Definition: reflist.h:101
RefItem::setAnchor
void setAnchor(const QCString &anchor)
Definition: reflist.h:36
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108