SUBDIRS(bbCreatePackage)
-# Utility that creates the file architecture for a new user package
-SUBDIRS(bbCreateBlackBox)
+# Utility that creates a new user black box
+SUBDIRS(bbCreateBlackBox)
-# Installs bbCreatePackage.bat/.sh
-# used to creates the file architecture for a new user package
+# Installs bbCreateBlackBox.bat/.sh
+# used to creates a new black box source file (xml or C++)
-# go to data which install the input data to the script
-#SUBDIRS(data)
-
-# Sets the data install path
-
-# Relative path to the data used by bbCreatePackage from data root folder
+# Relative path to the data used by bbCreateBlackBox from data root folder
SET(bbCreateBlackBox_DATA_REL_PATH_FROM_DATA kernel/bbCreateBlackBox)
-# Configure / Install the empty package structure used by bbCreatePackage
+# Configure / Install the template xml files used by bbCreateBlackBox
# Copy it into build tree
FILE(GLOB_RECURSE LST_FILE_VOID_CREATE_PACKAGE RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/xml-templates *.xml )
FOREACH( iLST ${LST_FILE_VOID_CREATE_PACKAGE})
DESTINATION ${BBTK_DATA_INSTALL_PATH}/${bbCreateBlackBox_DATA_REL_PATH_FROM_DATA}
)
-# Configure / Install the script bbCreatePackage
+# Configure / Install the script bbCreateBlackBox
SET(bbCreateBlackBox_DATA_REL_PATH_FROM_BIN ../${BBTK_DATA_REL_PATH}/${bbCreateBlackBox_DATA_REL_PATH_FROM_DATA})
FILE(TO_NATIVE_PATH ${bbCreateBlackBox_DATA_REL_PATH_FROM_BIN} bbCreateBlackBox_DATA_REL_PATH_FROM_BIN)
IF(WIN32)
-@echo off
-
-echo creates the file architecture for a new blackbox
-
-
-if %0%5==%0 goto ERROR01
-
-
-rem bbCreatePackage path
-set BINPATH=%~dp0
-rem Input data path
-set INPUT="%BINPATH%\@bbCreateBlackBox_DATA_REL_PATH_FROM_BIN@\xml-templates"
-
-set OUTPUT=%1
-set PACK=%2
-set BLACKBOX=%3
-set TYPE=%4
-set FORMAT=%5
-set AUTHOR=%6
-set DESCRIPTION=%7
-set FILENAME=bb%PACK%%BLACKBOX%
-
-echo output= %OUTPUT%
-echo bin = %BINPATH%
-echo input = %INPUT%
-echo pack = %PACK%
-echo blackbox = %BLACKBOX%
-echo type = %TYPE%
-echo format = %FORMAT%
-echo author = %AUTHOR%
-echo description = %DESCRIPTION%
-echo filename = %FILENAME%
-
-echo "** Creating new black box '%BLACKBOX%' xml/c++ in folder '%OUTPUT%'"
-
-echo Creating XML file..
-echo copy %INPUT%\%type%-template.xml %OUTPUT%\%FILENAME%.xml
-copy %INPUT%\%type%-template.xml %OUTPUT%\%FILENAME%.xml_tmp
-%BINPATH%\bbSed %OUTPUT%\%FILENAME%.xml_tmp __BLACKBOXNAME__ %BLACKBOX% > %OUTPUT%\%FILENAME%_1.xml
-%BINPATH%\bbSed %OUTPUT%\%FILENAME%_1.xml __AUTHOR__ %AUTHOR% > %OUTPUT%\%FILENAME%_2.xml
-%BINPATH%\bbSed %OUTPUT%\%FILENAME%_2.xml __DESCRIPTION__ %DESCRIPTION% > %OUTPUT%\%FILENAME%.xml_tmp
-del %OUTPUT%\%FILENAME%_1.xml
-del %OUTPUT%\%FILENAME%_2.xml
-
-
-IF %FORMAT%==XML GOTO module_XML
-IF %FORMAT%==C++ GOTO module_C++
-
-goto ERROR03
-
-:module_XML
- IF EXIST %OUTPUT%\%FILENAME%.xml GOTO ERROR02
- move %OUTPUT%\%FILENAME%.xml_tmp %OUTPUT%\%FILENAME%.xml
-goto END
-
-:module_C++
- IF EXIST %OUTPUT%\%FILENAME%.cxx GOTO ERROR02
- echo %BINPATH%\bbfy %OUTPUT%\%FILENAME%.xml_tmp %PACK% %OUTPUT%
- %BINPATH%\bbfy %OUTPUT%\%FILENAME%.xml_tmp %PACK% %OUTPUT%\
- del %OUTPUT%\%FILENAME%.xml_tmp
-goto END
-
-
-
-:ERROR01
-echo -----------------------------------------------------------------------------
-echo bbCreateBlackBox.bat "<dir-path> <package-name> <blackbox-name> <type> <format> [author] [description] "
-echo type:
-echo std
-echo VTK_ImageAlgorithm
-echo VTK_PolyDataAlgorithm
-echo widget
-echo format:
-echo XML
-echo C++
-echo -----------------------------------------------------------------------------
-goto END
-
-:ERROR02
-echo "ERROR : File '%OUTPUT%\%FILENAME%' %FORMAT% already exists !"
-del %OUTPUT%\%FILENAME%.xml_tmp
-goto end
-
-:ERROR03
-echo "ERROR : format not match '%FORMAT%' "
-del %OUTPUT%\%FILENAME%.xml_tmp
-goto end
-
-
-:END
+#!/bin/bash
+# creates the file architecture for a new user package
+
+if [ $# -lt 5 ]
+ then
+ echo "usage : bbCreateBlackBox <dir-path> <package-name> <blackbox-name> <type> <format> [author] [description] [category]"
+ echo " type: "
+ echo " std "
+ echo " VTK_ImageAlgorithm "
+ echo " VTK_PolyDataAlgorithm "
+ echo " widget "
+ echo " format: "
+ echo " XML "
+ echo " C++ "
+#bbCreateBox <template-xml-file-name> <box-name> <package-name> [author] [description] [category]"
+ exit
+fi
+
+# bbCreatePackage path
+TMP=$(which $0|rev)
+BINPATH=$(echo ${TMP#*/}|rev)
+#INPUT=$1
+
+OUTPUT_DIR=$1
+PACKAGE=$2
+BOX=$3
+TYPE=$4
+FORMAT=$5
+AUTHOR=$6
+DESCRIPTION=$7
+CATEGORY=$8
+# Input template file
+INPUT=${BINPATH}/@bbCreateBlackBox_DATA_REL_PATH_FROM_BIN@/xml-templates/${TYPE}-template.xml
+FILENAME=bb${PACKAGE}${BOX}
+
+echo "output dir = " $OUTPUT_DIR
+echo "box name = " $BOX
+echo "package = " $PACKAGE
+echo "author = " $AUTHOR
+echo "description = " $DESCRIPTION
+echo "category = " $CATEGORY
+echo "type = " $TYPE
+echo "input = " $INPUT
+
+
+echo "** Creating new black box '$BOX' in folder '$OUTPUT_DIR'"
+
+if [ -f ${OUTPUT_DIR}/${FILENAME}.xml ]
+ then
+ echo "Error : ${OUTPUT_DIR}/${FILENAME}.xml already exists"
+ exit
+fi
+
+echo " - Creating ${FILENAME}.xml"
+
+sed s,__BLACKBOXNAME__,"${BOX}", < ${INPUT} | sed s/__AUTHOR__/"${AUTHOR}"/ | sed s{__DESCRIPTION__{"${DESCRIPTION}"{ | sed s/__CATEGORY__/"${CATEGORY}"/ > ${OUTPUT_DIR}/${FILENAME}.xml
+
+if [ ${FORMAT}="C++" ]
+ then
+ if [ -f ${OUTPUT_DIR}/${FILENAME}.h ]
+ then
+ echo "Error : ${OUTPUT_DIR}/${FILENAME}.h already exists"
+ exit
+ fi
+ echo " - Creating ${FILENAME}.h/cxx"
+ ${BINPATH}/bbfy ${OUTPUT_DIR}/${FILENAME}.xml ${PACKAGE} ${OUTPUT_DIR}/ -q
+ echo " - Deleting ${FILENAME}.xml"
+ rm ${OUTPUT_DIR}/${FILENAME}.xml
+fi
+
+echo "Done !"
-<?xml version="1.0" encoding="iso-8859-1"?>
-
+<!--==========================================================================
+ STARTS THE DESCRIPTION OF THE BLACK BOX -->
<blackbox name="__BLACKBOXNAME__">
+<!--=======================================================================-->
+ <!--========================================================================
+ THE BOX DOCUMENTATION -->
<author>__AUTHOR__</author>
<description>__DESCRIPTION__</description>
- <category>__CategoryBlackBox__</category>
+ <category>__CATEGORY__</category>
+ <!--=====================================================================-->
+
+ <!--========================================================================
+ #include directives to be put in the .h generated
+ There must be one tag per file to include
+ Here we include the standard header iostream.h -->
+ <include><PRE>
+ iostream.h
+ </PRE></include>
+ <!--=====================================================================-->
- <input name="In1" type="double" description="First number to add"/>
- <input name="In2" type="double" description="Second number to add"/>
- <output name="Out" type="double" description="Result"/>
+ <!--========================================================================
+ INPUTS/OUTPUTS DECLARATION -->
+ <!-- Declares an input with name 'In', type 'double'
+ and description 'First input' -->
+ <input name="In" type="double" description="First input"/>
+
+ <!-- Declares an output with name 'Out', type 'double'
+ and description 'First output' -->
+ <output name="Out" type="double" description="First output"/>
+ <!--=====================================================================-->
+ <!--========================================================================
+ THE PROCESSING METHOD BODY :
+ Here simpy copies the value of the input 'In' to the output 'Out'
+ And prints out the value
+ INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+ void bbSet{Input|Output}NAME(const TYPE&)
+ const TYPE& bbGet{Input|Output}NAME() const
+ Where :
+ * NAME is the name of the input/output
+ (the one provided in the attribute 'name' of the tag 'input')
+ * TYPE is the C++ type of the input/output
+ (the one provided in the attribute 'type' of the tag 'input') -->
<process><PRE>
- bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
+ bbSetOutputOut( bbGetInputIn() );
+ std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
</PRE></process>
-
+ <!--=====================================================================-->
+
+ <!--========================================================================
+ CONSTRUCTORS / DESTRUCTORS (OPTIONAL)
+ THE CONSTRUCTION METHOD BODY :
+ Here initializes the input 'In' to 0
+ This is also where you should allocate the output pointers -->
<constructor><PRE>
- bbSetInputIn1(0);
- bbSetInputIn2(0);
- bbSetOutputOut(0);
+ bbSetInputIn(0);
</PRE></constructor>
+ <!-- THE COPY-CONSTRUCTION METHOD BODY :
+ Here does nothing
+ But this is where you should allocate the output pointers if any
+ and copy the pointed values (to avoid bug caused by multiple references)-->
+ <copyconstructor><PRE>
+ </PRE></copyconstructor>
+ <!-- THE DESTRUCTION METHOD BODY :
+ Here does nothing
+ but this is where you should desallocate the output pointers if any -->
+ <destructor><PRE>
+ </PRE></destructor>
+ <!--=====================================================================-->
+<!--=======================================================================-->
+<!-- END OF BLACK BOX DESCRIPTION -->
</blackbox>
-
+<!--=======================================================================-->