]> Creatis software - bbtk.git/blobdiff - samples/SampleInterpreter/bbtkSampleInterpreter.cxx
*** empty log message ***
[bbtk.git] / samples / SampleInterpreter / bbtkSampleInterpreter.cxx
index 91f4ff02eec9b55e07218f2e94babed58f62c73c..6100d5ec6b4148e4345d674d94becde75a43367c 100644 (file)
@@ -31,7 +31,8 @@ int main(int argv, char* argc[])
       std::cout << "Enter a number : ";
       double num = 0;
       std::cin >> num;
-      // Set its input 'In' to 1
+
+      // Set its input 'In' to num
       p->bbSetInput("In",num);
 
       // Execute it
@@ -46,7 +47,22 @@ int main(int argv, char* argc[])
       
       std::cout << num << "+1 = "<<v<<std::endl;
        
-    }
+      //============================================================
+      // Second example : imagine the bbProcessing.bbs script has created
+      // the box "a" of type Processing
+      // Here we simulate it using:
+      I->InterpretLine("new Processing a");
+      // We get a the black box "a" in the workspace:
+      bbtk::BlackBox::Pointer a 
+       = I->GetExecuter()->GetWorkspace()->GetPrototype()->bbGetBlackBox("a");
+      // Then the same as previously...
+      a->bbSetInput("In",num);
+      a->bbExecute();
+      double w = p->bbGetOutput("Out").get<double>();
+      std::cout << "In case you did not understand:"<<std::endl<<num << "+1 = "<<w<<std::endl;
+
+      // That's all !
+   }
   catch (bbtk::Exception e)
     {
       std::cout << "* ERROR : "<<e.GetErrorMessage()<<std::endl;