Topic: Preferring string constants to enums
In many places oofem uses enums externally (i.e as values in input files), and possible also saves them in context files as so on.
This makes it hard to ever have binary compability, and forces users to put in awkward constants into input files.
I think it would be much preferable to use constant strings in most places
I propose changing
enum LinSystSolverType {
ST_Direct = 0,
ST_IML = 1,
ST_Spooles= 2,
ST_Petsc = 3,
ST_DSS = 4,
ST_Feti = 5
};to
typedef const char * LinSystSolverType; // Optional?
LinSystSolverType ST_Direct = "direct";
LinSystSolverType ST_IML = "iml";
LinSystSolverType ST_Spooles = "spooles";
LinSystSolverType ST_Petsc = "petsc";
LinSystSolverType ST_DSS = "dss";
LinSystSolverType ST_Feti = "feti";It is more flexible, and more intuitive to use.
The downside is backwards compability with existing scripts and such, but I still think this is worthwhile.
Special case:
In particular, one enum has been used for this a lot, and causes quite some problems; InputFieldType
Right now, all the macros support 2 inputs, one enum and one string, and for a long time, the enum has been ignored.
I rather recently introduced DynamicInputRecord, which actually made use of the enums, but I regret this choice.
I suggest we get rid of the enum, and just introduce a typedef (possible also a namespace)
typedef const char * InputFieldType;
namespace IFT {
Element_nodes = "nodes";
...
}This would make it possible to create a dynamic input record, than save it to a file, e.g. building a pre-processor helper library for creating OOFEM input files.
Since these IFT-enums are used in-code only, there is no downside to changing this enum to string literals (no backwards compability to brake here).