summaryrefslogtreecommitdiffstats
path: root/src/definition.h
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-11-05 17:53:20 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-11-09 18:47:45 (GMT)
commit075229e586b391c3ec7ad79597aaeae392ca64e5 (patch)
tree2ad99929371727ad0811a55e597fa81a70ba43a7 /src/definition.h
parent6922d5d63d77c8f640c58e9c68a9955f9f0aa9a7 (diff)
downloadDoxygen-075229e586b391c3ec7ad79597aaeae392ca64e5.zip
Doxygen-075229e586b391c3ec7ad79597aaeae392ca64e5.tar.gz
Doxygen-075229e586b391c3ec7ad79597aaeae392ca64e5.tar.bz2
Refactoring: Introduce immutable and mutable interfaces
Split Definition/ClassDef/NamespaceDef/MemberDef into a immutable and mutable part Aliases are immutable, other symbols are stored using an immutable interface but can be made mutable explicitly by dynamic casting.
Diffstat (limited to 'src/definition.h')
-rw-r--r--src/definition.h38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/definition.h b/src/definition.h
index ee5c428..94c95b8 100644
--- a/src/definition.h
+++ b/src/definition.h
@@ -40,6 +40,7 @@ class GroupDef;
class GroupList;
class SectionInfo;
class Definition;
+class DefinitionMutable;
class FTextStream;
/** Data associated with a detailed description. */
@@ -94,6 +95,8 @@ class Definition
TypeDir = 7
};
+ static DefinitionMutable *make_mutable(const Definition *);
+
//-----------------------------------------------------------------------------------
// ---- getters -----
//-----------------------------------------------------------------------------------
@@ -284,6 +287,25 @@ class Definition
virtual QCString pathFragment() const = 0;
//-----------------------------------------------------------------------------------
+ // --- cookie storage ----
+ //-----------------------------------------------------------------------------------
+ virtual void setCookie(Cookie *cookie) const = 0;
+ virtual Cookie *cookie() const = 0;
+
+ //-----------------------------------------------------------------------------------
+ // --- symbol name ----
+ //-----------------------------------------------------------------------------------
+ virtual void _setSymbolName(const QCString &name) = 0;
+ virtual QCString _symbolName() const = 0;
+
+ // ---------------------------------
+ virtual ~Definition() = default;
+};
+
+class DefinitionMutable : virtual public Definition
+{
+ public:
+ //-----------------------------------------------------------------------------------
// ---- setters -----
//-----------------------------------------------------------------------------------
@@ -358,22 +380,12 @@ class Definition
virtual void writeDocAnchorsToTagFile(FTextStream &) const = 0;
virtual void writeToc(OutputList &ol, const LocalToc &lt) const = 0;
- //-----------------------------------------------------------------------------------
- // --- cookie storage ----
- //-----------------------------------------------------------------------------------
- virtual void setCookie(Cookie *cookie) const = 0;
- virtual Cookie *cookie() const = 0;
-
- //-----------------------------------------------------------------------------------
- // --- symbol name ----
- //-----------------------------------------------------------------------------------
- virtual void _setSymbolName(const QCString &name) = 0;
- virtual QCString _symbolName() const = 0;
- // ---------------------------------
- virtual ~Definition() = default;
};
+inline DefinitionMutable *Definition::make_mutable(const Definition *def)
+{ return dynamic_cast<DefinitionMutable*>(const_cast<Definition*>(def)); }
+
/** Reads a fragment from file \a fileName starting with line \a startLine
* and ending with line \a endLine. The result is returned as a string
* via \a result. The function returns TRUE if successful and FALSE