Supplement argument consistency checking.

With the need to start handling the supplemental argument,
I'll need a hook for those handlers to slip in their checks
that nothing is wrong.
This commit is contained in:
2024-04-28 02:05:04 -04:00
parent cd8312ebc1
commit 47c227943b
2 changed files with 11 additions and 0 deletions
+8
View File
@@ -79,6 +79,8 @@ namespace Planets ::detail:: Generate_m
Generator::~Generator()= default;
void Generator::checkSupplementRequirements( const std::optional< std::string > & ) {}
// All of the default C++ generator functions forward to the
// plain C default impls. The idea is that you derive your
@@ -273,6 +275,12 @@ namespace Planets ::detail:: Generate_m
throw std::runtime_error{ mesg };
}
std::cerr << "Performing supplementary argument checks for `" << star.supplement
<< "`..." << std::endl;
const auto name= star.supplement;
auto gen= registry().at( name ).get();
gen->checkSupplementRequirements( star.supArg ? star.supArg : std::optional< std::string >{} );
}
}
}
+3
View File
@@ -123,6 +123,7 @@ void SetupGeneratorForSolarSystem( STAR_DESC *desc, SOLARSYS_STATE *state );
#include <memory>
#include <string>
#include <optional>
namespace Planets ::detail:: Generate_m
{
@@ -168,6 +169,8 @@ namespace Planets ::detail:: Generate_m
PLANET_DESC *world, COUNT whichNode )= 0;
virtual bool pickupLife( SolarSystem *solarSys,
PLANET_DESC *world, COUNT whichNode )= 0;
virtual void checkSupplementRequirements( const std::optional< std::string > & ); // Normally does nothing.
};
class exports::DefaultGenerator