/** Creates an instance of an algorithm and sets the properties provided * * @param algName :: The name of the algorithm required * @param propertiesArray :: A single string containing properties in the * form "Property1=Value1;Property2=Value2;..." * @param version :: The version of the algorithm * @return A pointer to the created algorithm * WARNING! DO NOT DELETE THIS POINTER, because it is owned * by a shared pointer in the AlgorithmManager. * * @throw NotFoundError Thrown if algorithm requested is not registered * @throw std::invalid_argument Thrown if properties string is ill-formed */ IAlgorithm* FrameworkManagerImpl::createAlgorithm(const std::string& algName,const std::string& propertiesArray, const int& version) { // Use the previous method to create the algorithm IAlgorithm *alg = AlgorithmManager::Instance().create(algName,version).get();//createAlgorithm(algName); alg->setProperties(propertiesArray); return alg; }
/** * Execute an algorithm * @param nlhs :: The number of parameters on the left-hand side of the equals * @param plhs :: The data on the left-hand side of the equals * @param nrhs :: The number of parameters in the Matlab function call * @param prhs :: The data from the Matlab function call * @returns An integer indicating success/failure */ int RunAlgorithm(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { try { char buffer[256]; uint64_t *data = (uint64_t *)mxGetData(prhs[0]); IAlgorithm *alg = (IAlgorithm *)data[0]; mxGetString(prhs[1], buffer, sizeof(buffer)); alg->setProperties(buffer); alg->execute(); plhs[0] = mxCreateString(""); return 0; } catch (std::exception &e) { mexErrMsgTxt(e.what()); return 1; } }