ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
AppConfig.h
Go to the documentation of this file.
1/*$!{
2* Aurora Clang AST Viewer (ACAV)
3*
4* Copyright (c) 2026 Min Liu
5* Copyright (c) 2026 Michael David Adams
6*
7* SPDX-License-Identifier: GPL-2.0-or-later
8*
9* This program is free software; you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by
11* the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License along
20* with this program; if not, see <https://www.gnu.org/licenses/>.
21}$!*/
22
25#pragma once
26
27#include <QDir>
28#include <QSettings>
29#include <QString>
30
31namespace acav {
32
42class AppConfig {
43public:
47 static void initialize(const QString &configFilePath = QString());
48
52 static AppConfig &instance();
53
56 QString getConfigFilePath() const;
57
60 bool reload();
61
65 QString getCacheDirectory(const QString &compilationDatabasePath) const;
66
70 QString getDependenciesFilePath(const QString &compilationDatabasePath) const;
71
76 QString getAstCacheDirectory(const QString &compilationDatabasePath) const;
77
83 QString getAstFilePath(const QString &compilationDatabasePath,
84 const QString &sourceFilePath) const;
85
89 QString getMetadataFilePath(const QString &compilationDatabasePath) const;
90
94 QString getBuildDirectory(const QString &compilationDatabasePath) const;
95
97 bool getCommentExtractionEnabled() const;
98
100 bool getMemoryProfilingEnabled() const;
101
103 QString getCacheRoot() const;
104
106 int getFontSize() const;
107
109 QString getFontFamily() const;
110
113 int getParallelProcessorCount() const;
114
115private:
116 AppConfig(const QString &configFilePath);
117 ~AppConfig() = default;
118
119 // Prevent copying
120 AppConfig(const AppConfig &) = delete;
121 AppConfig &operator=(const AppConfig &) = delete;
122
124 static void createDefaultConfigFile(const QString &path);
125
127 static QString getDefaultConfigPath();
128
129 static AppConfig *instance_;
130
131 QString configFilePath_;
132 QSettings settings_;
133 QString cacheRoot_;
134 bool commentExtractionEnabled_ = true;
135 bool memoryProfilingEnabled_ = false;
136 int fontSize_ = 11;
137 QString fontFamily_;
138 int parallelProcessorCount_ = 0; // 0 = auto-detect
139
140 void loadSettings();
141 QString hashPath(const QString &path) const;
142 void ensureCacheDirectory(const QString &compilationDatabasePath) const;
143};
144
145} // namespace acav
bool reload()
Reload settings from the config file on disk.
QString getAstCacheDirectory(const QString &compilationDatabasePath) const
Get the AST cache directory for a compilation database.
QString getDependenciesFilePath(const QString &compilationDatabasePath) const
Get the dependencies JSON file path for a compilation database.
QString getCacheDirectory(const QString &compilationDatabasePath) const
Get the cache directory for a compilation database.
QString getMetadataFilePath(const QString &compilationDatabasePath) const
Get the metadata JSON file path for a compilation database.
QString getAstFilePath(const QString &compilationDatabasePath, const QString &sourceFilePath) const
Get the AST cache file path for a source file.
QString getCacheRoot() const
Custom cache root directory (default: ~/.cache/acav/).
QString getBuildDirectory(const QString &compilationDatabasePath) const
Get the build directory from cached metadata.
static AppConfig & instance()
Get the singleton instance.
static void initialize(const QString &configFilePath=QString())
Initialize the singleton with a custom config file path.
bool getCommentExtractionEnabled() const
Whether to extract and display comments in AST (default: false).
bool getMemoryProfilingEnabled() const
Whether memory profiling checkpoints are enabled (default: false).
QString getFontFamily() const
Editor/UI font family (default: empty = system default).
int getParallelProcessorCount() const
Number of parallel processors for query-dependencies (default: 0 = auto) 0 means use all available CP...
QString getConfigFilePath() const
Get the path to the currently loaded configuration file.
int getFontSize() const
Editor/UI font size (default: 11).