]> git.tdb.fi Git - builder.git/blobdiff - source/lib/builder.h
Allow new component types to be registered at runtime
[builder.git] / source / lib / builder.h
index e06cec34e73c6efbea21f1dee7a5839d15ef7e96..6dc29f098d2a22a714594c4dab1262de2a65df72 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <map>
 #include <string>
+#include <msp/core/module.h>
 #include <msp/datafile/loader.h>
 #include <msp/fs/path.h>
 #include "architecture.h"
 #include "config.h"
 #include "logger.h"
 #include "packagemanager.h"
+#include "sourcepackage.h"
 #include "target.h"
 #include "toolchain.h"
 #include "virtualfilesystem.h"
 
 class FileTarget;
 class Package;
-class SourcePackage;
+class Plugin;
 
 /**
 This class ties everything else together.  It also contains code for loading
@@ -44,7 +46,20 @@ private:
        };
 
 private:
+       struct LoadedPlugin
+       {
+               Msp::FS::Path path;
+               Msp::Module *module = nullptr;
+               Plugin *plugin = nullptr;
+
+               LoadedPlugin() = default;
+               LoadedPlugin(LoadedPlugin &&);
+               ~LoadedPlugin();
+       };
+
+       std::vector<LoadedPlugin> plugins;
        PackageManager package_manager;
+       SourcePackage::ComponentRegistry component_registry;
 
        Architecture native_arch;
        Architecture *current_arch = 0;
@@ -66,7 +81,12 @@ public:
        Builder();
        ~Builder();
 
+       void load_plugins();
        PackageManager &get_package_manager() { return package_manager; }
+       SourcePackage::ComponentRegistry &get_component_registry() { return component_registry; }
+
+       template<typename F>
+       void call_plugins(F) const;
 
        void set_architecture(const std::string &);
        const Architecture &get_current_arch() const { return *current_arch; }
@@ -110,4 +130,11 @@ public:
        int do_create_makefile();
 };
 
+template<typename F>
+void Builder::call_plugins(F func) const
+{
+       for(const LoadedPlugin &p: plugins)
+               func(*p.plugin);
+}
+
 #endif