1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2021 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 MEMBERGROUP_H
17 #define MEMBERGROUP_H
18 
19 #include <vector>
20 #include <map>
21 #include <memory>
22 
23 #include "types.h"
24 #include "reflist.h"
25 
26 #define DOX_NOGROUP -1
27 
28 class MemberList;
29 class MemberDef;
30 class ClassDef;
31 class NamespaceDef;
32 class FileDef;
33 class GroupDef;
34 class OutputList;
35 class Definition;
36 class DefinitionMutable;
37 class RefItem;
38 class TextStream;
39 
40 /** A class representing a group of members. */
41 class MemberGroup
42 {
43   public:
44     //MemberGroup();
45     MemberGroup(const Definition *container,int id,const QCString &header,
46                 const QCString &docs,const QCString &docFile,int docLine,MemberListContainer con);
47    ~MemberGroup();
header()48     QCString header() const { return grpHeader; }
groupId()49     int groupId() const { return grpId; }
50     void insertMember(const MemberDef *md);
51     void setAnchors();
52     void writePlainDeclarations(OutputList &ol,bool inGroup,
53                const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd,
54                int indentLevel, const ClassDef *inheritedFrom,const QCString &inheritId) const;
55     void writeDeclarations(OutputList &ol,
56                const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd,
57                bool showInline=FALSE) const;
58     void writeDocumentation(OutputList &ol,const QCString &scopeName,
59                const Definition *container,bool showEnumValues,bool showInline) const;
60     void writeDocumentationPage(OutputList &ol,const QCString &scopeName,
61                const DefinitionMutable *container) const;
62     void writeTagFile(TextStream &);
63     void addGroupedInheritedMembers(OutputList &ol,const ClassDef *cd,
64                MemberListType lt,
65                const ClassDef *inheritedFrom,const QCString &inheritId) const;
66     void setAnonymousEnumType();
67 
documentation()68     const QCString &documentation() const { return doc; }
allMembersInSameSection()69     bool allMembersInSameSection() const { return inSameSection; }
70     void addToDeclarationSection();
71     void countDecMembers();
72     void countDocMembers();
73     int countGroupedInheritedMembers(MemberListType lt);
74     void distributeMemberGroupDocumentation();
75     void findSectionsInDocumentation(const Definition *d);
76     int numDecMembers() const;
77     int numDecEnumValues() const;
78     int numDocMembers() const;
79     int numDocEnumValues() const;
80     const Definition *container() const;
81 
82     int countInheritableMembers(const ClassDef *inheritedFrom) const;
83     void addListReferences(Definition *d);
84     void setRefItems(const RefItemVector &sli);
members()85     const MemberList &members() const { return *memberList.get(); }
86     QCString anchor() const;
87 
docFile()88     QCString docFile() const { return m_docFile; }
docLine()89     int docLine() const { return m_docLine; }
90 
91   private:
92     const Definition *m_container;
93     std::unique_ptr<MemberList> memberList;      // list of all members in the group
94     MemberList *inDeclSection = 0;
95     int grpId = 0;
96     QCString grpHeader;
97     QCString fileName;           // base name of the generated file
98     QCString doc;
99     bool inSameSection = true;
100     QCString m_docFile;
101     int m_docLine;
102     RefItemVector m_xrefListItems;
103 };
104 
105 class MemberGroupRefList : public std::vector<MemberGroup *>
106 {
107 };
108 
109 class MemberGroupList : public std::vector< std::unique_ptr<MemberGroup> >
110 {
111 };
112 
113 /** Data collected for a member group */
114 struct MemberGroupInfo
115 {
116   void setRefItems(const RefItemVector &sli);
117   QCString header;
118   QCString doc;
119   QCString docFile;
120   int docLine = -1;
121   QCString compoundName;
122   RefItemVector m_sli;
123 };
124 
125 using MemberGroupInfoMap = std::unordered_map< int,std::unique_ptr<MemberGroupInfo> >;
126 
127 #endif
128