... | ... | @@ -64,8 +64,48 @@ Create the Common Data Model C++ Condition |
|
|
Now we are ready to create the C++ files specific to this condition class.
|
|
|
The easiest thing to do is to create copies of [engine/cdm/cpp/patient/conditions/SEChronicAnemia.h](https://gitlab.kitware.com/physiology/engine/blob/master/cdm/cpp/patient/conditions/SEChronicAnemia.h) and [engine/cdm/cpp/patient/conditions/SEAcuteStress.cpp](https://gitlab.kitware.com/physiology/engine/blob/master/cdm/cpp/patient/conditions/SEChronicAnemia.cpp) files and rename them to SE``your_condition_name``.h/.cpp Then replace the string ``AcuteStress`` with the name of your condition, then create the properties to match your condition protobuf structure. Note the naming convention is to start each file and class name with ``SE``
|
|
|
|
|
|
Add the Common Data Model Action to the Condition Manager
|
|
|
---------------------------------------------------------
|
|
|
Add the Common Data Model Condition to the Condition Base Class
|
|
|
---------------------------------------------------------------
|
|
|
The Condition base class is responsible for translating the condition object to and from the AnyCondition object. Each condition base class will have a Load and Unload method you will need to add code to. The following files are those condition base classes:
|
|
|
|
|
|
* [Environment Condition](https://gitlab.kitware.com/physiology/engine/blob/master/cdm/cpp/system/environment/conditions/SEEnvironmentCondition.cpp)
|
|
|
* [Patient Condition](https://gitlab.kitware.com/physiology/engine/blob/master/cdm/cpp/patient/conditions/SEPatientCondition.cpp)
|
|
|
|
|
|
In our example, for adding a patient condition we will add the following code
|
|
|
|
|
|
```cpp
|
|
|
// Add the header
|
|
|
#include "patient/conditions/SEMyNewCondition.h"
|
|
|
|
|
|
// Update the Load method
|
|
|
SEPatientCondition* SEPatientCondition::Load(const cdm::AnyPatientConditionData& any, SESubstanceManager& subMgr)
|
|
|
{
|
|
|
switch (any.Condition_case())
|
|
|
{
|
|
|
case cdm::AnyPatientConditionData::ConditionCase::kMyNewCondition:
|
|
|
{
|
|
|
SEMyNewCondition* c = new SEMyNewCondition();
|
|
|
SEMyNewCondition::Load(any.mynewcondition(), *c);
|
|
|
return c;
|
|
|
}
|
|
|
...
|
|
|
|
|
|
// Update the Unload Method
|
|
|
// Note we will want the cast/if block to be alphabetical order
|
|
|
cdm::AnyPatientConditionData* SEPatientCondition::Unload(const SEPatientCondition& action)
|
|
|
{
|
|
|
cdm::AnyPatientConditionData* any = new cdm::AnyPatientConditionData();
|
|
|
const SEMyNewCondition* mnc= dynamic_cast<const SEMyNewCondition*>(&action);
|
|
|
if (mnc!= nullptr)
|
|
|
{
|
|
|
any->set_allocated_mynewcondition(SEMyNewCondition::Unload(*mnc));
|
|
|
return any;
|
|
|
}
|
|
|
...
|
|
|
```
|
|
|
|
|
|
Add the Common Data Model Condition to the Condition Manager
|
|
|
------------------------------------------------------------
|
|
|
The condition manager contains different classes to organize the collection of conditions associated with the engine. Since there are so few conditions, there is only one manager for managing environment and patient conditions (unlike the action manager).
|
|
|
|
|
|
* [Condition Manager](https://gitlab.kitware.com/physiology/engine/blob/master/cdm/cpp/scenario/SEConditionManager.h.cpp)
|
... | ... | |