X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fconfig.h;h=69094b59777027e5e08056ae6e37408b372feb98;hb=ab25857fd626152bc9a2832de82b400c062857e6;hp=1b78e3a4e4d2e8a1168be85f6ec0f78187d60202;hpb=59ac0a44d6edf179c01604c6ced744873213f855;p=builder.git diff --git a/source/config.h b/source/config.h index 1b78e3a..69094b5 100644 --- a/source/config.h +++ b/source/config.h @@ -1,15 +1,32 @@ +/* $Id$ + +This file is part of builder +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef CONFIG_H_ #define CONFIG_H_ #include #include -#include "option.h" +#include +#include +#include +#include "misc.h" -typedef std::map RawOptionMap; +class Package; +/** +Manages configuration for a package. A configuration may have an arbitary +amount of options, as well as a modification time (mtime). +*/ class Config { public: + /** + A single configuration option. + */ struct Option { std::string name; @@ -21,13 +38,35 @@ public: }; typedef std::map OptionMap; + Config(Package &); void add_option(const std::string &, const std::string &, const std::string &); const Option &get_option(const std::string &) const; + const OptionMap &get_options() const { return options; } + const Msp::Time::TimeStamp &get_mtime() const { return mtime; } bool is_option(const std::string &) const; - bool process(const RawOptionMap &); - void load(const std::string &); + void select_last_profile(); + void select_profile(const std::string &); + bool update(const StringMap &); + void finish(); + void save() const; private: - OptionMap options; + class Loader: public Msp::Parser::Loader + { + public: + Loader(Config &); + private: + Config &conf; + + void option(const std::string &, const std::string &); + }; + + Package &package; + OptionMap options; + Msp::Time::TimeStamp mtime; + bool freeze_mtime; + + bool set_option(const std::string &, const std::string &); + void load(); }; #endif