How to create a new component
Everything you need to do is illustrated in this commit: #56dcbe0:
- Create the class header and implementation files:
- Declare your component in Model/essBuildInc/makeESS.h
- Create it in Model/essBuild/makeESS.cxx and define intersections with the other objects in the model.
- Define the variables of your component in Model/essBuild/essVariables.cxx (or more appropriate place depending on the component you are developing).
The first step can be done either manually or with the help of the cl-paster script. In our example the MyClass.h and MyClass.cxx files were generated by running
cl-paster -model essBuild -namespace essSystem -m "Description" MyClass
Add a variable
Now let's add a variable called mainTemp
into our new model. What you need to do is illustrated in #f0a58d2:
- Declare it in the header file Model/essBuildInc/MyClass.h
- Add it into constructors and the populate method in Model/essBuild/MyClass.cxx
- Define the variable in Model/essBuild/essVariables.cxx
When you add many variables, these modifications can be time consuming and error-prone. Therefore you can choose to do the first two steps with the cl-add-variable script:
cl-add-variable -model essBuild -class MyClass -var mainTemp -type double -comment "main temperature" -name "MainTemp" -after mainMat
Note: this script supports the source code style generated by cl-paster, therefore you might have to do minor edits of the style of your code.
Update CMakeLists.txt
Add new files into corresponding CMakeLists.txt
to include them into the build system.
Recompile
Since we have added new files in our model, we need to run cmake
before recompiling, so that make
is aware about these new files:
cmake .
make -j$(nproc)