Classempathy::brain::JSONBrain
brain
Bases
Constructors
Member Functions

Classempathy::brain::JSONBrain

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>.

Bases

Brain

Brain: the controller of lifevents.

Constructors

JSONBrain ( std::__cxx11::string fileName )

Constructor.

fileName

Member Functions

  • override
void
terminate ( )

A basic override function created for handling brain termination due to program abort.

Remember to call superclass while overriding.

Overrides: Brain::terminate
  • protected
  • virtual
createEventFromString ( std::__cxx11::string const name )

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
  • protected
  • virtual
void
executeJson ( std::__cxx11::string const action,
cJSON * json )

Execute a certain JSON action.

action
json
  • protected
  • override
void
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