Skip to content
Snippets Groups Projects

long-term maintenance improvement for runTime selection tables

Merged Mark OLESEN requested to merge feature-runTimeCompat into develop
Viewing commit 502d3eda
Show latest version
4 files
+ 182
2
Preferences
Compare changes
Files
4
  • - this makes the lookup and use of tables slightly cleaner and
      provides a hook for update (compat) messages
    
      The singleton-style method returns the function pointer directly,
      or nullptr on not-found.
    
      NEW access method (mnemonic: 'ctor' prefix for constructors)
    
      ```
      auto* ctorPtr = dictionaryConstructorTable(modelType);
    
      if (!ctorPtr)
      {
          ...
      }
    
      return autoPtr<myModel>(ctorPtr(dict, ...));
      ```
    
      OLD method, which also still works, but without any compat handling:
    
      ```
      auto ctorIter = dictionaryConstructorTablePtr_->cfind(modelType);
    
      if (!ctorIter.found())
      {
          ...
      }
    
      return autoPtr<myModel>(ctorIter()(dict, ...));
      ```
@@ -76,6 +76,16 @@ Note
Table_##lookup##_(#lookup)
//- Add lookup alias for runTime selection
#define addAliasToRunTimeSelectionTable\
(baseType,thisType,argNames,lookup,other,ver) \
\
/* Add thisType constructor function to the table, find by lookup */ \
baseType::addAlias##argNames##ConstructorToTable<thisType> \
add##thisType##argNames##ConstructorTo##baseType##Table_ \
##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to construction table with typeName as the key.
@@ -99,6 +109,16 @@ Note
Table_##lookup##_(#lookup)
//- Add lookup alias for for runTime selection
#define addAliasTemplateToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup,other,ver) \
\
/* Add thisType constructor function to the table, find by lookup */ \
baseType::addAlias##argNames##ConstructorToTable<thisType<Targ>> \
add##thisType##Targs##argNames##ConstructorTo##baseType##Table_ \
##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Add to construction table with typeName as the key.
@@ -122,6 +142,17 @@ Note
Table_##lookup##_(#lookup)
//- Add lookup alias for for runTime selection
// Use when baseType requires the Targ template argument as well
#define addAliasTemplatedToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup,other,ver) \
\
/* Add the thisType constructor function to the table, find by lookup */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>> \
add##thisType##Targ##argNames##ConstructorTo##baseType##Targ## \
Table_##lookup##_##other##_(#lookup,#other,ver)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif