Created
July 14, 2015 11:36
-
-
Save pranavcode/6ab0469f4b33143a1f5e to your computer and use it in GitHub Desktop.
Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is just a pseudo-code. | |
// | |
// File: common_header.hpp | |
// | |
void current(state_type &variables, state_type &dxdt, const double t, int index, vector<string> var_param_names_from_isf) { | |
// this fucntion has common code | |
// just that the name for variable is acquired from | |
// var_param_names_from_isf vector by accessing its index | |
// e.g. index x - var_param_names_from_isf[x] | |
} | |
// | |
// File: sub_class_1_for_neuron.cpp | |
// | |
#include "common_header.hpp" // includes the common header file | |
class SubClass1 { | |
void current((state_type &variables, state_type &dxdt, const double t, int index) { | |
// fabricate the new vector<string> with this class' | |
// variable and parameter requirements | |
std::vector<string> var_params_i_need = { | |
"parameter1", | |
"variable1", | |
"variable2", | |
... | |
}; | |
// Now call our custom current function from common_header.hpp | |
// with the new parameter to the current() at the end | |
// of the function arguments | |
current(variables, dxdt, t, index, var_params_i_need); | |
} | |
}; | |
// Similarly there can be SubClass2 with same strategy and common current() | |
// call with its own variable and parameter names | |
// Comment on this gist if you have questions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great. This looks like the thing I need. Will get back to you after I try to put this to work.