From eaaa82bd9c1e24a83dcea3857f5fd75d0dfb6de5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 20 Mar 2015 13:21:18 +0200 Subject: New consolidated load/match/build loop --- build/operation | 58 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-) (limited to 'build/operation') diff --git a/build/operation b/build/operation index 3d9c7e0..3469f21 100644 --- a/build/operation +++ b/build/operation @@ -6,8 +6,9 @@ #define BUILD_OPERATION #include -#include #include +#include +#include // reference_wrapper #include @@ -49,11 +50,13 @@ namespace build // Id constants for build-in operations. // const meta_operation_id perform_id = 1; - const meta_operation_id configure_id = 2; - const meta_operation_id disfigure_id = 3; - const operation_id update_id = 1; - const operation_id clean_id = 2; + // The default operation is a special marker that can be used to + // indicate that no operation was explicitly specified by the user. + // + const operation_id default_id = 1; + const operation_id update_id = 2; + const operation_id clean_id = 3; const action_id perform_update_id = (perform_id << 4) | update_id; const action_id perform_clean_id = (perform_id << 4) | clean_id; @@ -101,31 +104,52 @@ namespace build // enum class execution_mode {first, last}; - // Meta/operation tables. + // Meta/operation info. // struct meta_operation_info { const std::string name; - - const std::string& - key () const {return name;} // string_table interface. }; + // Built-in meta-operations. + // + extern meta_operation_info perform; + struct operation_info { const std::string name; const execution_mode mode; - - const std::string& - key () const {return name;} // string_table interface. }; - using meta_operation_table = string_table; - using operation_table = string_table; + // Build-in operations. + // + extern operation_info default_; + extern operation_info update; + extern operation_info clean; + + // Meta/operation tables. + // + using meta_operation_table = string_table< + meta_operation_id, + std::reference_wrapper>; - extern meta_operation_table meta_operations; - extern operation_table operations; + using operation_table = string_table< + operation_id, + std::reference_wrapper>; + + template <> + struct string_table_traits> + { + static const std::string& + key (const meta_operation_info& x) {return x.name;} + }; + + template <> + struct string_table_traits> + { + static const std::string& + key (const operation_info& x) {return x.name;} + }; } #endif // BUILD_OPERATION -- cgit v1.1