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:
@@ -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 >{} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user