summaryrefslogtreecommitdiffstats
path: root/src/docvisitor.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-09-27 18:26:20 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-09-27 18:26:20 (GMT)
commitcfdabb54c5bcea38629eb0ec8f207d1306ff0939 (patch)
treecb323c258fe80e0e2422f939d40af66eefdd055e /src/docvisitor.cpp
parent55e15c86717f38c9b510e4287cb0b4f165b8cb10 (diff)
downloadDoxygen-cfdabb54c5bcea38629eb0ec8f207d1306ff0939.zip
Doxygen-cfdabb54c5bcea38629eb0ec8f207d1306ff0939.tar.gz
Doxygen-cfdabb54c5bcea38629eb0ec8f207d1306ff0939.tar.bz2
Refactoring: prepare output generators for multi-threaded use
Diffstat (limited to 'src/docvisitor.cpp')
-rw-r--r--src/docvisitor.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/docvisitor.cpp b/src/docvisitor.cpp
new file mode 100644
index 0000000..664d3ca
--- /dev/null
+++ b/src/docvisitor.cpp
@@ -0,0 +1,58 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1997-2020 by Dimitri van Heesch.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied warranty.
+ * See the GNU General Public License for more details.
+ *
+ * Documents produced by Doxygen are derivative works derived from the
+ * input used in their production; they are not affected by this license.
+ */
+
+
+#include <unordered_map>
+
+#include "parserintf.h"
+#include "docvisitor.h"
+#include "util.h"
+#include "types.h"
+#include "doxygen.h"
+
+struct DocVisitor::Private
+{
+ int id;
+ std::unordered_map< std::string, std::unique_ptr<CodeParserInterface> > parserFactoryMap;
+};
+
+DocVisitor::DocVisitor(int id) : p(std::make_unique<Private>())
+{
+ p->id = id;
+}
+
+DocVisitor::~DocVisitor()
+{
+}
+
+CodeParserInterface &DocVisitor::getCodeParser(const char *extension)
+{
+ std::string ext(extension?extension:"");
+ // for each extension we create a code parser once per visitor, so that
+ // the context of the same parser object is reused thoughout multiple passes for instance
+ // for code fragments shown via dontinclude.
+ auto it = p->parserFactoryMap.find(ext);
+ if (it==p->parserFactoryMap.end())
+ {
+ auto factory = Doxygen::parserManager->getCodeParserFactory(extension);
+ auto result = p->parserFactoryMap.insert(std::make_pair(ext,factory()));
+ it = result.first;
+ }
+ return *it->second.get();
+}
+
+int DocVisitor::id() const
+{
+ return p->id;
+}