class bbfy
{
public:
- bbfy(const std::string& filename, const std::string& output_path = "",
+ bbfy(const std::string& filename,
+ const std::string& package = "PACKAGE_NAME",
+ const std::string& output_path = "",
bool verbose = false);
void CreateBlackBox();
}
BoxType;
BoxType mType;
+ bool mIsWidget;
std::string mParentBlackBox;
std::string mItkParent;
std::string mVtkParent;
std::string mDescription;
std::string mCategory;
std::string mPackage;
- bool mIsInNamespace;
+ // bool mIsInNamespace;
std::string mNamespace;
// int mNbTemplateParam;
std::vector<std::string> mTemplateParam;
std::vector<IO> mOutput;
std::string mProcess;
+ std::string mCreateWidget;
//
std::ofstream mFile;
//==========================================================================
bbfy::bbfy(const std::string& filename,
+ const std::string& package,
const std::string& output_path,
bool verbose)
{
mFilename = filename;
+ mPackage = package;
+ mNamespace = "bb" + mPackage;
+
mOutputPath = output_path;
mVerbose = verbose;
// Type
mGeneric = false;
mType = STD;
+
+
if (BB.isAttributeSet("type"))
{
std::string bbtype = BB.getAttribute("type");
}
}
+ // Is a widget box ?
+ if (BB.isAttributeSet("widget"))
+ {
+ mIsWidget = true;
+ mParentBlackBox = "bbtk::WxBlackBox";
+ mInclude.push_back("bbtkWxBlackBox.h");
+ }
+ else
+ {
+ mIsWidget = false;
+ mParentBlackBox = "bbtk::AtomicBlackBox";
+ mInclude.push_back("bbtkAtomicBlackBox.h");
+ }
+
+ /*
// Parent black box
if (!BB.nChildNode("parentblackbox"))
{
throw bbfyException("Error : no <package> tag found (mandatory)");
}
GetTextOrClear(BB.getChildNode("package"),mPackage);
+ */
// Author
int i,j;
}
// Namespace
+ /*
mIsInNamespace = false;
if (BB.nChildNode("namespace"))
{
mIsInNamespace = true;
GetTextOrClear(BB.getChildNode("namespace"),mNamespace);
}
-
+ */
+
// UserConstructor body
if (BB.nChildNode("constructor"))
{
// Process
- // Process tag given ?
+ // process tag given ?
if (BB.nChildNode("process"))
{
GetTextOrClear(BB.getChildNode("process"),mProcess);
}
+ // CreateWidget
+ // createwidget tag given ?
+ if (BB.nChildNode("createwidget"))
+ {
+ GetTextOrClear(BB.getChildNode("createwidget"),mCreateWidget);
+ }
}
//==========================================================================
//==========================================================================
void bbfy::BeginNamespace()
{
- if (mIsInNamespace)
- {
- mFile << "namespace "<<mNamespace <<"\n{\n\n";
- }
+ // if (mIsInNamespace)
+ // {
+ mFile << "namespace "<<mNamespace <<"\n{\n\n";
+ // }
}
//==========================================================================
//==========================================================================
void bbfy::EndNamespace()
{
- if (mIsInNamespace)
- {
- mFile << "}\n// EO namespace "<<mNamespace<<"\n\n";
- }
+ // if (mIsInNamespace)
+ // {
+ mFile << "}\n// EO namespace "<<mNamespace<<"\n\n";
+ // }
}
//==========================================================================
throw bbfyException(mess);
}
+ // If is widget
+ mFile << "#ifdef _USE_WXWIDGETS_\n";
+
+ // Prevent multiple inclusions
+ std::string included("__bb");
+ included += mPackage + mName + "_h_INCLUDED__";
+ mFile << "#ifndef " << included <<"\n";
+ mFile << "#define " << included <<"\n";
// Includes
- mFile << "#include \"bbtkAtomicBlackBox.h\"\n";
+ // mFile << "#include \"bbtkAtomicBlackBox.h\"\n";
std::vector<std::string>::iterator i;
for (i=mInclude.begin(); i!=mInclude.end(); ++i)
{
mFile << " BBTK_PROCESS(vtkParent::Update);\n" ;
}
+ // CreateWidget
+ if (mIsWidget)
+ {
+ mFile << " BBTK_CREATE_WIDGET(DoCreateWidget);\n" ;
+ mFile << " void DoCreateWidget();\n";
+ }
+
+
// EO black box declaration
mFile << "};\n\n";
// EO namespace
EndNamespace();
+
+ // Prevent multiple inclusions
+ mFile << "#endif // " << included <<"\n";
+ // If is widget
+ mFile << "#endif // _USE_WXWIDGETS_\n";
// EOF
mFile << "\n";
// Implementation
mFile << "BBTK_USER_BLACK_BOX_IMPLEMENTATION("
<< mName << ","
- << mParentBlackBox << ");\n";
-
- // Process
- if ((mType == STD)||(mProcess.size()))
- {
- mFile << "void "<<mName<<"::DoProcess()\n{\n";
- mFile << mProcess << "\n";
- mFile << "}\n";
- }
+ << mParentBlackBox << ");\n";
+ }
+ // Process
+ if ((mType == STD)||(mProcess.size()))
+ {
+ mFile << "void "<<mName<<"::DoProcess()\n{\n";
+ mFile << mProcess << "\n";
+ mFile << "}\n";
+ }
+ // CreateWidget
+ if (mIsWidget)
+ {
+ mFile << "void "<<mName<<"::DoCreateWidget()\n{\n";
+ mFile << mCreateWidget << "\n";
+ mFile << "}\n";
}
+
// User constr / copy constr / destr implementation
mFile <<"void "<<mName<<"::bbUserConstructor()"<<std::endl;
mFile << "{"<<std::endl;
int main(int argc, char **argv)
{
- if (argc<2 || argc>4)
+ if (argc<2 || argc>5)
{
- std::cerr << "usage : "<< argv[0] <<" xml_file [output_path] [-q]" << std::endl;
+ std::cerr << "usage : "<< argv[0] <<" xml_file [package_name] [output_path] [-q]" << std::endl;
return 1;
}
try
{
+ std::string package("PACKAGE_NAME");
std::string output_path("");
bool verbose = true;
- if (argc>2) output_path = argv[2];
- if (argc>3) verbose = false;
+ if (argc>2) package = argv[2];
+ if (argc>3) output_path = argv[3];
+ if (argc>4) verbose = false;
- bbfy B(argv[1],output_path,verbose);
+ bbfy B(argv[1],package,output_path,verbose);
}
catch (bbfyException e)
{