Imported Upstream version 1.9.8
[platform/upstream/doxygen.git] / src / namespacedef.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 NAMESPACEDEF_H
17 #define NAMESPACEDEF_H
18
19 #include <memory>
20 #include <set>
21
22 #include "definition.h"
23 #include "filedef.h"
24 #include "linkedmap.h"
25 #include "membergroup.h"
26
27 class MemberList;
28 class ClassDef;
29 class ConceptDef;
30 class OutputList;
31 class ClassLinkedRefMap;
32 class ConceptLinkedRefMap;
33 class MemberDef;
34 class NamespaceDef;
35 class NamespaceDefMutable;
36
37 // --- Set of namespaces
38
39 using NamespaceDefSet = std::set<const NamespaceDef*>;
40
41 class NamespaceLinkedMap : public LinkedMap<NamespaceDef>
42 {
43 };
44
45 class NamespaceLinkedRefMap : public LinkedRefMap<const NamespaceDef>
46 {
47   public:
48     void writeDeclaration(OutputList &ol,const QCString &title,
49             bool isConstantGroup=false, bool localName=FALSE);
50     bool declVisible(bool isContantGroup) const;
51 };
52
53 /** An abstract interface of a namespace symbol. */
54 class NamespaceDef : public Definition
55 {
56   public:
57     virtual DefType definitionType() const = 0;
58
59     // ---- getters
60     virtual QCString getOutputFileBase() const = 0;
61     virtual QCString anchor() const = 0;
62     virtual int numDocMembers() const = 0;
63     virtual const LinkedRefMap<NamespaceDef> &getUsedNamespaces() const = 0;
64     virtual const LinkedRefMap<ClassDef> &getUsedClasses() const = 0;
65     virtual QCString displayName(bool=TRUE) const = 0;
66     virtual bool isConstantGroup() const = 0;
67     virtual bool isModule()        const = 0;
68     virtual bool isLibrary() const = 0;
69     virtual bool isInline() const = 0;
70     virtual bool isLinkableInProject() const = 0;
71     virtual bool isLinkable() const = 0;
72     virtual bool isVisibleInHierarchy() const = 0;
73     virtual bool hasDetailedDescription() const = 0;
74     virtual const Definition *findInnerCompound(const QCString &name) const = 0;
75     virtual bool subGrouping() const = 0;
76     virtual MemberList *getMemberList(MemberListType lt) const = 0;
77     virtual const MemberLists &getMemberLists() const = 0;
78     virtual const MemberDef *getMemberByName(const QCString &) const = 0;
79     virtual int countVisibleMembers() const = 0;
80
81     /*! Returns the user defined member groups */
82     virtual const MemberGroupList &getMemberGroups() const = 0;
83
84     /*! Returns the classes contained in this namespace */
85     virtual ClassLinkedRefMap getClasses() const = 0;
86
87     /*! Returns the Slice interfaces contained in this namespace */
88     virtual ClassLinkedRefMap getInterfaces() const = 0;
89
90     /*! Returns the Slice structs contained in this namespace */
91     virtual ClassLinkedRefMap getStructs() const = 0;
92
93     /*! Returns the Slice exceptions contained in this namespace */
94     virtual ClassLinkedRefMap getExceptions() const = 0;
95
96     /*! Returns the namespaces contained in this namespace */
97     virtual NamespaceLinkedRefMap getNamespaces() const = 0;
98
99     /*! Returns the concepts contained in this namespace */
100     virtual ConceptLinkedRefMap getConcepts() const = 0;
101
102     virtual QCString title() const = 0;
103     virtual QCString compoundTypeString() const = 0;
104 };
105
106 class NamespaceDefMutable : public DefinitionMutable, public NamespaceDef
107 {
108   public:
109
110     // --- setters/actions
111     virtual void setMetaData(const QCString &m) = 0;
112     virtual void insertUsedFile(FileDef *fd) = 0;
113     virtual void writeDocumentation(OutputList &ol) = 0;
114     virtual void writeMemberPages(OutputList &ol) = 0;
115     virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const = 0;
116     virtual void writeTagFile(TextStream &) = 0;
117     virtual void insertClass(ClassDef *cd) = 0;
118     virtual void insertConcept(ConceptDef *cd) = 0;
119     virtual void insertNamespace(NamespaceDef *nd) = 0;
120     virtual void insertMember(MemberDef *md) = 0;
121     virtual void computeAnchors() = 0;
122     virtual void countMembers() = 0;
123     virtual void addMembersToMemberGroup() = 0;
124     virtual void distributeMemberGroupDocumentation() = 0;
125     virtual void findSectionsInDocumentation() = 0;
126     virtual void sortMemberLists() = 0;
127     virtual void addInnerCompound(Definition *d) = 0;
128     virtual void addListReferences() = 0;
129     virtual void setFileName(const QCString &fn) = 0;
130     virtual void combineUsingRelations(NamespaceDefSet &visitedNamespace) = 0;
131     virtual void addUsingDirective(NamespaceDef *nd) = 0;
132     virtual void addUsingDeclaration(ClassDef *cd) = 0;
133     virtual void setInline(bool isInline) = 0;
134     virtual void setName(const QCString &name) = 0;
135 };
136
137 /** Factory method to create new NamespaceDef instance */
138 std::unique_ptr<NamespaceDef> createNamespaceDef(const QCString &defFileName,int defLine,int defColumn,
139                  const QCString &name,const QCString &ref=QCString(),
140                  const QCString &refFile=QCString(),const QCString &type=QCString(),
141                  bool isPublished=false);
142
143 /** Factory method to create an alias of an existing namespace. Used for inline namespaces. */
144 std::unique_ptr<NamespaceDef> createNamespaceDefAlias(const Definition *newScope,const NamespaceDef *nd);
145
146
147 // --- Cast functions
148
149 NamespaceDef            *toNamespaceDef(Definition *d);
150 NamespaceDef            *toNamespaceDef(DefinitionMutable *d);
151 const NamespaceDef      *toNamespaceDef(const Definition *d);
152 NamespaceDefMutable     *toNamespaceDefMutable(Definition *d);
153
154 // --- Helpers
155
156 NamespaceDef *getResolvedNamespace(const QCString &key);
157 inline NamespaceDefMutable *getResolvedNamespaceMutable(const QCString &key)
158 {
159   return toNamespaceDefMutable(getResolvedNamespace(key));
160 }
161 bool namespaceHasNestedNamespace(const NamespaceDef *nd);
162 bool namespaceHasNestedConcept(const NamespaceDef *nd);
163 bool namespaceHasNestedClass(const NamespaceDef *nd,bool filterClasses,ClassDef::CompoundType ct);
164
165 //------------------------------------------------------------------------
166
167 #endif