Make the two Create() methods more parallel.
This commit is contained in:
parent
5bd491bd74
commit
607622e8f8
|
@ -484,20 +484,25 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
|||
const std::vector<LIB_PIN*>& aPins,
|
||||
REPORTER* aReporter )
|
||||
{
|
||||
TYPE type = aBaseModel ? aBaseModel->GetType() : TYPE::NONE;
|
||||
std::unique_ptr<SIM_MODEL> model;
|
||||
|
||||
// A null base model means the model wasn't found in the library, so create a fallback
|
||||
if( aBaseModel )
|
||||
{
|
||||
TYPE type = aBaseModel->GetType();
|
||||
|
||||
if( !aBaseModel || dynamic_cast<const SIM_MODEL_SPICE_FALLBACK*>( aBaseModel ) )
|
||||
if( dynamic_cast<const SIM_MODEL_SPICE_FALLBACK*>( aBaseModel ) )
|
||||
model = std::make_unique<SIM_MODEL_SPICE_FALLBACK>( type );
|
||||
else if( dynamic_cast< const SIM_MODEL_RAW_SPICE*>( aBaseModel ) )
|
||||
model = std::make_unique<SIM_MODEL_RAW_SPICE>();
|
||||
else
|
||||
model = Create( type );
|
||||
|
||||
if( aBaseModel )
|
||||
model->SetBaseModel( *aBaseModel );
|
||||
}
|
||||
else // No base model means the model wasn't found in the library, so create a fallback
|
||||
{
|
||||
model = std::make_unique<SIM_MODEL_SPICE_FALLBACK>( TYPE::NONE );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -518,25 +523,30 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
|||
const std::vector<T>& aFields,
|
||||
REPORTER* aReporter )
|
||||
{
|
||||
TYPE type = ReadTypeFromFields( aFields, aReporter );
|
||||
|
||||
// If the model has a specified type, it takes priority over the type of its base class.
|
||||
if( type == TYPE::NONE && aBaseModel )
|
||||
type = aBaseModel->GetType();
|
||||
|
||||
std::unique_ptr<SIM_MODEL> model;
|
||||
|
||||
// A null base model means the model wasn't found in the library, so create a fallback
|
||||
if( aBaseModel )
|
||||
{
|
||||
TYPE type = aBaseModel->GetType();
|
||||
|
||||
if( !aBaseModel || dynamic_cast<const SIM_MODEL_SPICE_FALLBACK*>( aBaseModel ) )
|
||||
// No REPORTER here; we're just checking to see if we have an override
|
||||
if( ReadTypeFromFields( aFields, nullptr ) != TYPE::NONE )
|
||||
type = ReadTypeFromFields( aFields, nullptr );
|
||||
|
||||
if( dynamic_cast<const SIM_MODEL_SPICE_FALLBACK*>( aBaseModel ) )
|
||||
model = std::make_unique<SIM_MODEL_SPICE_FALLBACK>( type );
|
||||
else if( dynamic_cast< const SIM_MODEL_RAW_SPICE*>( aBaseModel ) )
|
||||
model = std::make_unique<SIM_MODEL_RAW_SPICE>();
|
||||
else
|
||||
model = Create( type );
|
||||
|
||||
if( aBaseModel )
|
||||
model->SetBaseModel( *aBaseModel );
|
||||
}
|
||||
else // No base model means the model wasn't found in the library, so create a fallback
|
||||
{
|
||||
TYPE type = ReadTypeFromFields( aFields, aReporter );
|
||||
model = std::make_unique<SIM_MODEL_SPICE_FALLBACK>( type );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue