Program: bbtk
Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:15 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2009/02/11 11:35:20 $
+ Version: $Revision: 1.12 $
=========================================================================*/
/* ---------------------------------------------------------------------
if (!mInterpreter) mInterpreter =bbtk::Interpreter::New();
mInterpreter->SetCommandLine(true);
std::stringstream* buf = new std::stringstream;
+ *buf << "exec freeze_no_error" << std::endl;
*buf << "message max 0" << std::endl;
*buf << "include *" << std::endl;
mInterpreter->InterpretBuffer(buf);
--- /dev/null
+# Find bbtk
+
+# Set 'FIND_PACKAGE_VERBOSE' to have information on the packages found
+SET(FIND_PACKAGE_VERBOSE 1)
+# Find
+FIND_PACKAGE(BBTK)
+# Use if found
+IF(BBTK_FOUND)
+INCLUDE(${BBTK_USE_FILE})
+ENDIF(BBTK_FOUND)
+
+SET(SAMPLE bbtkSampleInterpreter)
+
+# main
+ADD_EXECUTABLE(${SAMPLE} ${SAMPLE})
+# Link with bbtk
+TARGET_LINK_LIBRARIES(${SAMPLE} ${BBTK_LIBRARIES})
+
+
+# Configure the script bbProcessing.bbs to binary dir so that the
+# sample find it !
+CONFIGURE_FILE(bbProcessing.bbs
+ ${EXECUTABLE_OUTPUT_PATH}/bbProcessing.bbs
+ COPYONLY)
--- /dev/null
+# Defines the pipeline used by SampleInterpreter
+# Here simply adds 1 to a double
+load std
+define Processing
+ new Add a
+ set a.In2 1
+
+ # create the input : plug it in a.In1
+ input In a.In1 "Input number"
+ # create the output : get it from a.Out
+ output Out a.Out "Output number"
+
+ # executing the complex box executes a
+ exec a
+endefine
--- /dev/null
+//=========================================================================
+// How to create and use a script defined black box
+//=========================================================================
+
+//=========================================================================
+#include <bbtkInterpreter.h>
+//=========================================================================
+
+//=========================================================================
+int main(int argv, char* argc[])
+{
+ // To track all ...
+ // bbtk::MessageManager::SetMessageLevel("all",9);
+
+ try
+ {
+ // Create an interpreter
+ bbtk::Interpreter::Pointer I = bbtk::Interpreter::New();
+
+ // We tell the interpreter to throw exceptions on error
+ I->SetThrow(true);
+
+ // Interpret the file supposed to define a box called 'Processing'
+ I->InterpretFile("bbProcessing.bbs");
+
+ // Create an instance 'p' of the 'Processing' box
+ bbtk::BlackBox::Pointer p
+ = I->GetExecuter()->GetFactory()->NewBlackBox("Processing","p");
+
+ // Prompt the user
+ std::cout << "Enter a number : ";
+ double num = 0;
+ std::cin >> num;
+ // Set its input 'In' to 1
+ p->bbSetInput("In",num);
+
+ // Execute it
+ p->bbExecute();
+
+ // Print out the output 'Out':
+ // 1) We get the output with the generic bbGetOutput method.
+ // 2) It returns a bbtk::Data which can store any data type
+ // 3) We get the value of the data as a double using get<TYPE>()
+ // (because we know it's a double !)
+ double v = p->bbGetOutput("Out").get<double>();
+
+ std::cout << num << "+1 = "<<v<<std::endl;
+
+ }
+ catch (bbtk::Exception e)
+ {
+ std::cout << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
+ return 1;
+ }
+ return 0;
+
+
+ // To get the list of bbtk object still allocated after main ends
+ // bbtk::StaticInitTime::PrintObjectListInfo = true;
+ // bbtk::MessageManager::SetMessageLevel("object",1);
+}
+//=========================================================================