非常复杂的软件的合理配置方法?

发布于 2024-10-18 17:33:08 字数 566 浏览 0 评论 0原文

我们正在编写一个 C++ 程序,它需要高度可配置(在启动时)。 现在我们有一个基本 XML 文件,其中包含多个配置变量,以及具有更多配置变量的其他 XML 文件的文件名。总而言之,我们有一棵包含大约 10 个 XML 文件的树,以及一些带有其他内容的二进制文件格式。

我们现在正处于一个变得极其混乱的地步:由于文件是相互链接的,因此很难找到实际解析了哪些文件以及需要编辑哪些配置或要设置哪些路径。

除了互连的 XML 文件之外,还有其他更好的方法来实现复杂软件的配置吗?

我不想放弃这种方法的一个优点是,从配置的一个部分切换到另一部分相对容易。例如,我们有两个不同机器人的两个配置文件,要在我们使用的机器人之间切换,我们只需从基本 XML 文件链接正确的文件即可。

编辑 一些可能的想法可能是:

  • 切换到使用数据库?这将是高度可配置的,但不那么人类可读。
  • 像 Firefox 的 about:config 这样的结构?
  • 一个巨大的平面 .ini 文件并且只需要处理复制内容?不是一个选择,这会更麻烦
  • ......

We are writing a C++ program, that needs to be highly configurable (at start time).
Right now we have a base XML file, which contains several configuration variables, and filenames of other XML files with more configuration variables. All in all, we have a tree of about 10 XML files, and several binaries file formats with some other content.

We are now at a point where it is getting extremely messy: Since the files are interlinked, it is difficult to find which files are actually parsed and which configuration needs to be edited or which paths to be set.

Are there any better ways to implement a configuration for a complex piece of software except interlinked XML files?

One advantage of this approach that I'd hate to loose, is that it is relatively easy to switch from one part of the configuration to another. For example we have two configuration files for two different Robots, and to switch between which robot we are using we simply link the correct file from the base XML file.

EDIT
Some possible ideas might be:

  • Switch to using a database? This would be highly configurable but is not as human-readable.
  • Some structure like firefox's about:config?
  • One huge flat .ini file and just deal with copying stuff around? not an option, this would be even more cumbersome
  • ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无人问我粥可暖 2024-10-25 17:33:09

Lua 是为配置而设计的。

Lua was designed for configuration.

酷遇一生 2024-10-25 17:33:09

如果您使用 C++,则可以使用

http://www.boost .org/doc/libs/1_45_0/doc/html/program_options.html
增强程序选项。

它允许您将配置存储在文件中并可互换地使用命令行参数。

If you are using C++ you can use

http://www.boost.org/doc/libs/1_45_0/doc/html/program_options.html
Boost Program Options.

It allows you to store configs in files and use command line args interchangeably.

梦毁影碎の 2024-10-25 17:33:09

我主要来自 Java 和 .NET 世界,但完全理解拥有如此多的配置文件、不同的环境和共享配置参数所带来的痛苦。作为前一家公司的一个解决方案,我们开始构建一些对我们有很大帮助的东西,它允许配置继承、模板化和强类型配置值以及配置的审核和访问控制。

我们很快就会将我们的解决方案作为托管配置管理服务发布。如果您有兴趣,请在 http://woot.configchief.com 注册测试版

I mostly come from Java and .NET world but can totally understand the pain it involves to have so many configuration files, different envrionments and shared configuration parameters. As one solution for a previous company we started building something which helped us a lot by allowing configuration inheritence, templating and strongly types configuration values as well as auditing and access control for configuration.

We are releasing our solution as a hosted configuration management service soon. If you are interested, signup for a beta at http://woot.configchief.com

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文