* \brief Class bbtk::BBPInterpreter
*/
-
#include "bbtkInterpreterPython.h"
#include "bbtkExecuter.h"
}
//=========================================================================
-
-
//=========================================================================
InterpreterPython::InterpreterPython()
{
}
//=========================================================================
-
//=========================================================================
/// Creates a new black box in current complex box
void InterpreterPython::commandNew( const std::string& boxType, const std::string& boxName) // virtual
std::string boxTypeTmp=boxType;
boxTypeTmp.replace(pos,1,"_");
// ex: mCB.New( bbtkBlackBox.std_ConcatString("Box10") )
- std::string code("New( "+boxTypeTmp+"('"+boxName+"') )");
+ std::string code(" self.New( "+boxTypeTmp+"('"+boxName+"') )");
this->pythonBBTK.push_back(code);
}
//=========================================================================
-
//=========================================================================
/// Connects the output boxOutput to the input boxInput
void InterpreterPython::commandConnection (const std::string &boxfrom,
const std::string &input) // virtual
{
//ex: mCB.Connection( "Box10" , "Out", "Box11", "In")
- std::string code("Connection('"+boxfrom+"','"+output+"','"+boxto+"','"+input+"')");
+ std::string code(" self.Connection('"+boxfrom+"','"+output+"','"+boxto+"','"+input+"')");
this->pythonBBTK.push_back(code);
}
//=========================================================================
//=========================================================================
void InterpreterPython::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string &help)
{
+ std::string code(" self.DECLARE_INPUT('"+name+"','"+box+"."+input+"')");
+ this->pythonBBTK.push_back(code);
}
//=========================================================================
//=========================================================================
void InterpreterPython::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string &help)
{
+ std::string code(" self.DECLARE_OUTPUT('"+name+"','"+box+"."+output+"')");
+ this->pythonBBTK.push_back(code);
}
//=========================================================================
-
//=========================================================================
/// sets the input of the box with the value
void InterpreterPython::commandSet(const std::string &box,const std::string &input,const std::string &value) // virtual
{
//ex: mCB.Set("Box10","In2","/hola.mhd")
- std::string code("Set('"+box+"','"+input+"','"+value+"')");
+ std::string code(" self.Set('"+box+"','"+input+"','"+value+"')");
this->pythonBBTK.push_back(code);
}
//=========================================================================
-
//=========================================================================
void InterpreterPython::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual
{
+
+ this->pythonBBTK.push_back(" ");
+ this->pythonBBTK.push_back("from bbtk.bbtkBlackBox import *");
+ this->pythonBBTK.push_back(" ");
+ this->pythonBBTK.push_back("class "+pack+"_"+name+"(ComplexBlackBox):");
+ this->pythonBBTK.push_back(" ");
+ this->pythonBBTK.push_back(" def __init__(self, nameBox):");
+ this->pythonBBTK.push_back(" super().__init__(nameBox)");
+ this->pythonBBTK.push_back(" self.Init()");
+ this->pythonBBTK.push_back(" ");
+ this->pythonBBTK.push_back(" def Init(self):");
+
}
//=========================================================================
void InterpreterPython::commandExec(const std::string &word) // virtual
{
//Ex: mCB.AddToExecutableLst("Box13")
- std::string code("AddToExecutableLst('"+word+"')");
+ std::string code(" self.AddToExecutableLst('"+word+"')");
this->pythonBBTK.push_back(code);
}
//=========================================================================