]> Creatis software - bbtk.git/blob - kernel/src/bbtkInterpreterPython.cxx
#3512 clean bbs2 python version
[bbtk.git] / kernel / src / bbtkInterpreterPython.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
8 #  This software is governed by the CeCILL-B license under French law and
9 #  abiding by the rules of distribution of free software. You can  use,
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B
11 #  license as circulated by CEA, CNRS and INRIA at the following URL
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability.
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
24  */
25
26 /*=========================================================================
27 Program:   bbtk
28 Module:    $RCSfile$
29 Language:  C++
30 Date:      $Date$
31 Version:   $Revision$
32 =========================================================================*/
33
34
35 /**
36  *  \file
37  *  \brief Class bbtk::BBPInterpreter
38  */
39
40 #include "bbtkInterpreterPython.h"
41
42 #include "bbtkExecuter.h"
43 #include "bbtkMessageManager.h"
44 #include "bbtkFactory.h"
45 #include "bbtkUtilities.h"
46
47 namespace bbtk
48 {
49
50   //=========================================================================
51     InterpreterPython::Pointer InterpreterPython::New()
52     {
53         return MakePointer( new InterpreterPython() );
54     }
55   //=========================================================================
56
57   //=========================================================================
58     InterpreterPython::InterpreterPython()
59     {
60         bbtk::InterpreterVirtual::Init();
61     }
62   //=========================================================================
63
64   //=========================================================================
65     InterpreterPython::~InterpreterPython()
66     {
67     }
68   //=========================================================================
69
70   //=========================================================================
71   /// Creates a new black box in current complex box
72   void InterpreterPython::commandNew( const std::string& boxType, const std::string& boxName) // virtual
73   {
74       int pos = boxType.find( std::string(":") );
75       std::string boxTypeTmp=boxType;
76       boxTypeTmp.replace(pos,1,"_");
77       // ex:   mCB.New( bbtkBlackBox.std_ConcatString("Box10") )
78       std::string  code("New( "+boxTypeTmp+"('"+boxName+"') )");
79       this->pythonBBTK.push_back(code);
80   }
81   //=========================================================================
82
83   //=========================================================================
84   /// Connects the output boxOutput to the input boxInput
85   void InterpreterPython::commandConnection (const std::string &boxfrom,
86       const std::string &output,
87       const std::string &boxto,
88       const std::string &input)                 // virtual
89   {
90       //ex: mCB.Connection( "Box10" , "Out", "Box11", "In")
91       std::string  code("Connection('"+boxfrom+"','"+output+"','"+boxto+"','"+input+"')");
92       this->pythonBBTK.push_back(code);
93   }
94   //=========================================================================
95
96   //=========================================================================
97   void InterpreterPython::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string  &help)
98   {
99       std::string  code("DECLARE_INPUT('"+name+"','"+box+"."+input+"')");
100       this->pythonBBTK.push_back(code);
101   }
102   //=========================================================================
103
104   //=========================================================================
105   void InterpreterPython::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string  &help)
106   {
107       std::string  code("DECLARE_OUTPUT('"+name+"','"+box+"."+output+"')");
108       this->pythonBBTK.push_back(code);
109   }
110   //=========================================================================
111
112   //=========================================================================
113   /// sets the input of the box with the value
114   void InterpreterPython::commandSet(const std::string &box,const std::string &input,const std::string &value) // virtual
115   {
116       //ex:     mCB.Set("Box10","In2","/hola.mhd")
117       std::string  code("Set('"+box+"','"+input+"','"+value+"')");
118       this->pythonBBTK.push_back(code);
119   }
120   //=========================================================================
121
122   //=========================================================================
123   void InterpreterPython::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual
124   {
125   }
126   //=========================================================================
127
128
129   //=========================================================================
130   void InterpreterPython::commandEndDefine() // virtual
131   {
132   }
133   //=========================================================================
134
135
136   //=========================================================================
137   void InterpreterPython::commandExec(const std::string &word) // virtual
138   {
139       //Ex:     mCB.AddToExecutableLst("Box13")
140       std::string  code("AddToExecutableLst('"+word+"')");
141       this->pythonBBTK.push_back(code);
142   }
143   //=========================================================================
144
145
146   //=========================================================================
147   void InterpreterPython::commandAuthor(const std::string &author)  // virtual
148   {
149   }
150   //=========================================================================
151
152   //=========================================================================
153   void InterpreterPython::commandCategory(const std::string &categorytype)  // virtual
154   {
155   }
156   //=========================================================================
157
158   //=========================================================================
159   void InterpreterPython::commandDescription(const std::string &description)  // virtual
160   {
161   }
162   //=========================================================================
163
164 }  // EO namespace bbtk
165
166 // EOF
167