]> git.tdb.fi Git - builder.git/blobdiff - source/config.h
Add profile templates
[builder.git] / source / config.h
index e5c90de0ce597f5bb14607a0f0b0e49481682202..e35743a3050e5ff1c4c979be8b5b9d5d2c57fcbf 100644 (file)
@@ -6,13 +6,20 @@
 #include <msp/parser/loader.h>
 #include <msp/path/path.h>
 #include <msp/time/timestamp.h>
-#include "option.h"
+#include "misc.h"
 
-typedef std::map<std::string, std::string> 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;
@@ -24,19 +31,35 @@ public:
        };
        typedef std::map<std::string, Option> 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 Msp::Path::Path &); 
+       void select_last_profile();
+       void select_profile(const std::string &);
+       bool update(const StringMap &);
+       void finish();
+       void save() const;
 private:
        class Loader: public Msp::Parser::Loader
        {
+       public:
+               Loader(Config &);
+       private:
+               Config &conf;
+               
+               void option(const std::string &, const std::string &);
        };
-       
-       OptionMap options;
+
+       Package         &package;
+       OptionMap       options;
        Msp::Time::TimeStamp mtime;
+       bool freeze_mtime;
+
+       bool set_option(const std::string &, const std::string &);
+       void load();
 };
 
 #endif