X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fappli%2Fbbfy%2Fbbfy.cpp;h=64120471d5fa2883012204fa218108a190ee9356;hb=f303df63e2a2e33d698c974858f288058d980ae4;hp=0c7972ae52f72b2348b36408a71bd0f68eacd3ce;hpb=a26195c366a89795288009cf7e20f11afa494970;p=bbtk.git diff --git a/kernel/appli/bbfy/bbfy.cpp b/kernel/appli/bbfy/bbfy.cpp index 0c7972a..6412047 100644 --- a/kernel/appli/bbfy/bbfy.cpp +++ b/kernel/appli/bbfy/bbfy.cpp @@ -23,7 +23,9 @@ public: 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(); @@ -53,14 +55,16 @@ private: } BoxType; BoxType mType; + bool mIsWidget; std::string mParentBlackBox; std::string mItkParent; std::string mVtkParent; bool mGeneric; std::string mAuthor; std::string mDescription; + std::string mCategory; std::string mPackage; - bool mIsInNamespace; + // bool mIsInNamespace; std::string mNamespace; // int mNbTemplateParam; std::vector mTemplateParam; @@ -87,6 +91,7 @@ private: std::vector mOutput; std::string mProcess; + std::string mCreateWidget; // std::ofstream mFile; @@ -100,10 +105,14 @@ private: //========================================================================== 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; @@ -173,6 +182,8 @@ void bbfy::ParseXML() // Type mGeneric = false; mType = STD; + + if (BB.isAttributeSet("type")) { std::string bbtype = BB.getAttribute("type"); @@ -214,6 +225,21 @@ void bbfy::ParseXML() } } + // 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")) { @@ -227,6 +253,7 @@ void bbfy::ParseXML() throw bbfyException("Error : no tag found (mandatory)"); } GetTextOrClear(BB.getChildNode("package"),mPackage); + */ // Author int i,j; @@ -245,14 +272,24 @@ void bbfy::ParseXML() mDescription += val; } + // Category + for (i=0,j=0; i::iterator i; for (i=mInclude.begin(); i!=mInclude.end(); ++i) { @@ -636,6 +687,14 @@ void bbfy::CreateHeader() 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"; @@ -671,6 +730,9 @@ void bbfy::CreateHeader() // Description mFile << "BBTK_DESCRIPTION(\""<::iterator ioi; @@ -789,7 +856,7 @@ void bbfy::WriteGenericITKFilterHeader() // BO black box description mFile << "BBTK_BEGIN_DESCRIBE_BLACK_BOX(" - << mName << "Generic,bbtk::UserBlackBox);\n"; + << mName << "Generic,bbtk::AtomicBlackBox);\n"; mFile << "BBTK_NAME(\"" << mName <<"\");\n"; // Author @@ -835,7 +902,7 @@ void bbfy::WriteGenericITKFilterHeader() mFile << "template \n" << "void "<()<<\",\"<()\"<bbUpdate();\n" << " this->bbSetOutputOut( new itkImage( f->bbGetOutputOut() ) );\n" << " f->UnRegister();\n" - << " bbtkDebugDecTab(\"Core\",9);\n" + << " bbtkDebugDecTab(\"Kernel\",9);\n" << "}\n\n"; //================================================================= @@ -906,7 +973,7 @@ void bbfy::CreateCode() { // Implementation mFile << "BBTK_USER_BLACK_BOX_IMPLEMENTATION(" - << mName << "Generic,bbtk::UserBlackBox);\n"; + << mName << "Generic,bbtk::AtomicBlackBox);\n"; // Package mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE(" << mPackage << "," @@ -924,33 +991,40 @@ void bbfy::CreateCode() // Implementation mFile << "BBTK_USER_BLACK_BOX_IMPLEMENTATION(" << mName << "," - << mParentBlackBox << ");\n"; - - // Process - if ((mType == STD)||(mProcess.size())) - { - mFile << "void "<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) {