src/engine/calculator_engine.cpp
double CalculatorEngine::runOperation(std::string name, double operandA, double operandB)
{
  // Discover the requested operation plugin by name
  PluginEntry *pluginEntry = PluginRegistry::getSharedInstance().get(PLUGIN_OPERATION, name);
  if (!pluginEntry) {
    return -1;
  }

  // Create plugin instance
  Operation *plugin = reinterpret_cast<Operation*>(PluginRegistry::getSharedInstance().loadPlugin(pluginEntry));

  // Execute the plugin
  double result = plugin->execute(operandA, operandB);
#if 0
  json input;
  input["operandA"] = operandA;
  input["operandB"] = operandB;
  json output = plugin->invokeMethod("execute", input);
  double result = output["result"].get<double>();
#endif
  // Destroy plugin instance
  PluginRegistry::getSharedInstance().unloadPlugin(pluginEntry);

  // Finally, return the operation result
  return result;
}
/**
 * Runs the operation identified by the given name, with the two specified
 * operands. This method will call the plugin that corresponds to the given 
 * operation name to actually carry out the task.
 *
 * @param name The operation name
 * @param operandA The first operand
 * @param operandB The second operand
 *
 * @return The operation result
 */
Runs the operation identified by the given name, with the two specified
operands. This method will call the plugin that corresponds to the given
operation name to actually carry out the task.

@param name The operation name
@param operandA The first operand
@param operandB The second operand

@return The operation result
Runs the operation identified by the given name with the two specified operands . This method will call the plugin that corresponds to the given operation name to actually carry out the task . @param name The operation name @param operandA The first operand @param operandB The second operand @return The operation result
double CalculatorEngine::runOperation(std::string name, double operandA, double operandB)
{
  PluginEntry *pluginEntry = PluginRegistry::getSharedInstance().get(PLUGIN_OPERATION, name);
  if (!pluginEntry) {
    return -1;
  }
  Operation *plugin = reinterpret_cast<Operation*>(PluginRegistry::getSharedInstance().loadPlugin(pluginEntry));
  double result = plugin->execute(operandA, operandB);
#if 0
  json input;
  input["operandA"] = operandA;
  input["operandB"] = operandB;
  json output = plugin->invokeMethod("execute", input);
  double result = output["result"].get<double>();
#endif
  PluginRegistry::getSharedInstance().unloadPlugin(pluginEntry);
  return result;
}
double CalculatorEngine :: runOperation ( std :: string name , double operandA , double operandB ) { PluginEntry * pluginEntry = PluginRegistry :: getSharedInstance ( ) . get ( PLUGIN_OPERATION , name ) ; if ( ! pluginEntry ) { return -1 ; } Operation * plugin = reinterpret_cast < Operation * > ( PluginRegistry :: getSharedInstance ( ) . loadPlugin ( pluginEntry ) ) ; double result = plugin -> execute ( operandA , operandB ) ; #if 0 json input ; input [ " " ] = operandA ; input [ " " ] = operandB ; json output = plugin -> invokeMethod ( " " , input ) ; double result = output [ " " ] . get < double > ( ) ; #endif PluginRegistry :: getSharedInstance ( ) . unloadPlugin ( pluginEntry ) ; return result ; }
Runs the operation identified by the given name, with the two specified
 operands.
Runs the operation identified by the given name with the two specified operands .
// Discover the requested operation plugin by name // Create plugin instance // Execute the plugin // Destroy plugin instance // Finally, return the operation result