Doxygen
Loading...
Searching...
No Matches
reflist.h
Go to the documentation of this file.
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#include "construct.h"
26
27class Definition;
28class RefList;
29
30/** This struct represents an item in the list of references. */
32{
33 public:
34 RefItem(int id,RefList *list) : m_id(id), m_list(list) {}
35
36 void setText (const QCString &text) { m_text = text; }
37 void setAnchor(const QCString &anchor) { m_anchor = anchor; }
38 void setPrefix(const QCString &prefix) { m_prefix = prefix; }
39 void setName (const QCString &name) { m_name = name; }
40 void setTitle (const QCString &title) { m_title = title; }
41 void setArgs (const QCString &args) { m_args = args; }
42 void setGroup (const QCString &group) { m_group = group; }
43 void setScope (const Definition *scope) { m_scope = scope; }
44
45 QCString text() const { return m_text; }
46 QCString anchor() const { return m_anchor; }
47 QCString prefix() const { return m_prefix; }
48 QCString name() const { return m_name; }
49 QCString title() const { return m_title; }
50 QCString args() const { return m_args; }
51 QCString group() const { return m_group; }
52 int id() const { return m_id; }
53 RefList *list() const { return m_list; }
54 const Definition *scope() const { return m_scope; }
55
56 private:
57 int m_id = 0; //!< unique identifier for this item within its list
58 RefList *m_list; //!< list owning this item
59 QCString m_text; //!< text of the item.
60 QCString m_anchor; //!< anchor in the list
61 QCString m_prefix; //!< type prefix for the name
62 QCString m_name; //!< name of the entity containing the reference
63 QCString m_title; //!< display name of the entity
64 QCString m_args; //!< optional arguments for the entity (if function)
65 QCString m_group; //!< group id used to combine item under a single header
66 const Definition *m_scope = nullptr; //!< scope to use for references.
67};
68
69/** List of cross-referenced items
70 *
71 * This class represents a list of items that are put
72 * at a certain point in the documentation by some special command
73 * and are collected in a list. The items cross-reference the
74 * documentation and the list.
75 *
76 * Examples are the todo list, the test list and the bug list,
77 * introduced by the \\todo, \\test, and \\bug commands respectively.
78 */
80{
81 public:
82 /*! Create a list of items that are cross referenced with documentation blocks
83 * @param listName String representing the name of the list.
84 * @param pageTitle String representing the title of the list page.
85 * @param secTitle String representing the title of the section.
86 */
87 RefList(const QCString &listName, const QCString &pageTitle, const QCString &secTitle);
88 bool isEnabled() const;
89
90 /*! Adds a new item to the list.
91 * @returns A unique id for this item.
92 */
93 RefItem *add();
94
95 /*! Returns an item given it's id that is obtained with addRefItem()
96 * @param itemId item's identifier.
97 * @returns A pointer to the todo item's structure.
98 */
99 RefItem *find(int itemId);
100
101 QCString listName() const { return m_listName; }
102 QCString fileName() const { return m_fileName; }
103 QCString pageTitle() const { return m_pageTitle; }
104 QCString sectionTitle() const { return m_secTitle; }
105
106 void generatePage();
107
108 private:
109 int m_id = 0;
110 QCString m_listName;
111 QCString m_fileName;
112 QCString m_pageTitle;
113 QCString m_secTitle;
114 std::vector< std::unique_ptr< RefItem > > m_entries;
115 std::unordered_map< int, RefItem* > m_lookup;
116};
117
118class RefListManager : public LinkedMap<RefList>
119{
120 public:
122 {
123 static RefListManager rlm;
124 return rlm;
125 }
126
127 private:
128 RefListManager() = default;
129 ~RefListManager() = default;
131};
132
133using RefItemVector = std::vector<RefItem*>;
134
135#endif
The common base class of all entity definitions found in the sources.
Definition definition.h:76
Container class representing a vector of objects with keys.
Definition linkedmap.h:36
QCString group() const
Definition reflist.h:51
QCString text() const
Definition reflist.h:45
RefItem(int id, RefList *list)
Definition reflist.h:34
const Definition * scope() const
Definition reflist.h:54
void setTitle(const QCString &title)
Definition reflist.h:40
QCString args() const
Definition reflist.h:50
QCString m_name
name of the entity containing the reference
Definition reflist.h:62
int id() const
Definition reflist.h:52
void setAnchor(const QCString &anchor)
Definition reflist.h:37
void setArgs(const QCString &args)
Definition reflist.h:41
RefList * m_list
list owning this item
Definition reflist.h:58
QCString m_args
optional arguments for the entity (if function)
Definition reflist.h:64
QCString m_prefix
type prefix for the name
Definition reflist.h:61
QCString m_text
text of the item.
Definition reflist.h:59
void setText(const QCString &text)
Definition reflist.h:36
QCString m_anchor
anchor in the list
Definition reflist.h:60
QCString name() const
Definition reflist.h:48
QCString prefix() const
Definition reflist.h:47
QCString m_title
display name of the entity
Definition reflist.h:63
RefList * list() const
Definition reflist.h:53
void setGroup(const QCString &group)
Definition reflist.h:42
void setPrefix(const QCString &prefix)
Definition reflist.h:38
const Definition * m_scope
scope to use for references.
Definition reflist.h:66
void setName(const QCString &name)
Definition reflist.h:39
QCString m_group
group id used to combine item under a single header
Definition reflist.h:65
QCString title() const
Definition reflist.h:49
QCString anchor() const
Definition reflist.h:46
void setScope(const Definition *scope)
Definition reflist.h:43
int m_id
unique identifier for this item within its list
Definition reflist.h:57
List of cross-referenced items.
Definition reflist.h:80
std::unordered_map< int, RefItem * > m_lookup
Definition reflist.h:115
QCString m_listName
Definition reflist.h:110
void generatePage()
Definition reflist.cpp:55
QCString m_secTitle
Definition reflist.h:113
std::vector< std::unique_ptr< RefItem > > m_entries
Definition reflist.h:114
RefList(const QCString &listName, const QCString &pageTitle, const QCString &secTitle)
Definition reflist.cpp:24
QCString pageTitle() const
Definition reflist.h:103
QCString m_pageTitle
Definition reflist.h:112
QCString sectionTitle() const
Definition reflist.h:104
int m_id
Definition reflist.h:109
QCString listName() const
Definition reflist.h:101
QCString m_fileName
Definition reflist.h:111
RefItem * add()
Definition reflist.cpp:30
QCString fileName() const
Definition reflist.h:102
RefItem * find(int itemId)
Definition reflist.cpp:40
bool isEnabled() const
Definition reflist.cpp:46
~RefListManager()=default
RefListManager()=default
static RefListManager & instance()
Definition reflist.h:121
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
std::vector< RefItem * > RefItemVector
Definition reflist.h:133