Here's the simple rule to parse any file:
Brain * brain=new JSONBrain("myjsonfile.json");
brain->addTo(empathy);//empathy's your app
And the script executes!
How to make a JSON instruction file? See <doc/json_brain_rules>.
Brain |
Brain: the controller of lifevents. |
JSONBrain | ( | std::__cxx11::string | fileName | ) |
Constructor.
fileName |
terminate | ( | ) |
A basic override function created for handling brain termination due to program abort.
Remember to call superclass while overriding.
Suppose you have a JSON action like this:
{"type":"create","create":"cwave","colorRed":0.8}
What you'd want this to do is to create an instance of CWave.
So, empathy::brain::JSONBrain::executeJson receives this JSON action, and asks this method to create an empty instance of CWave. JUST create an empty instance. Nothing more.
name | |
return |
Execute a certain JSON action.
action | |
json |
runLineNumber | ( | std::__cxx11::string | lineID, | |
std::__cxx11::string | callerID | ) |
Any extension of Brain class must override this function. What it does is receive instructions. For example, when the program begins, lineID is "begin" and when you need to play a music, it will be something like "playBeethoven". Your choice.
lineID | |
callerID |