1 /*=========================================================================
4 Module: $RCSfile: bbtkExecuter.h,v $ $
6 Date: $Date: 2008/02/06 10:53:02 $
7 Version: $Revision: 1.8 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 * \brief class Executer: level 0 of script execution (header)
23 * \class bbtk::Executer
24 * \brief class Executer: level 0 of script execution
27 #ifndef __bbtkExecuter_h__
28 #define __bbtkExecuter_h__
30 #include "bbtkVirtualExec.h"
32 #include "bbtkSystem.h"
33 #include "bbtkComplexBlackBox.h"
34 #include "bbtkFactory.h"
41 class /*BBTK_EXPORT*/ Executer : public VirtualExec
50 // void SetFactory(Factory* f);
55 /// Sets the inputs of the workspace :
56 void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
58 /// Puts the executer in "no exec" mode,
59 /// which creates but does not execute pipelines
60 void SetNoExecMode(bool b) { mNoExecMode = b; }
62 bool GetNoExecMode() const { return mNoExecMode; }
64 /// Sets the mode of dialog of the executer for Root inputs
65 void SetDialogMode(DialogModeType t) { mDialogMode = t; }
67 /// Starts a package block
68 void BeginPackage (const std::string &name );
70 /// Ends a package block
73 /// Starts the definition of a new ComplexBlackBox in package pack
74 /// scriptfilename is the file from which the def is read
75 void Define (const std::string &name,
76 const std::string& pack,
77 const std::string &scriptfilename);
79 /// Sets the file name to use for the current definition
80 /// (Used to set it after the Define command)
81 void SetCurrentFileName (const std::string &name );
83 /// End the definition of a ComplexBlackBox
86 /// Creates a new black box in current complex box
87 void Create ( const std::string& boxType, const std::string& boxName);
89 /// Destroys a black box
90 void Destroy (const std::string &boxName);
92 /// Connects the output boxOutput to the input boxInput
93 void Connect (const std::string &boxfrom,
94 const std::string &output,
95 const std::string &boxto,
96 const std::string &input);
99 /// would 'Execute' be more meaningfull ?
100 void Update (const std::string &box);
102 /// Defines an input of the current complex box
103 void DefineInput (const std::string &name,
104 const std::string &box,
105 const std::string &input,
106 const std::string &help);
108 /// Defines an output of the current complex box
109 void DefineOutput (const std::string &name,
110 const std::string &box,
111 const std::string &output,
112 const std::string &help);
114 /// sets the input of the box with the value
115 void Set (const std::string &box,
116 const std::string &input,
117 const std::string &value);
119 /// gets the output of the box
120 std::string Get (const std::string &box,
121 const std::string &output);
123 /// changes the workspace name
124 void SetWorkspaceName( const std::string& n );
126 ///Adds the authorName to the Box author list
127 void Author(const std::string &authorName);
129 ///Adds the Categories to the Box category list
130 void Category(const std::string &category);
132 /// The description string which explains what does the ComplexBox
133 void Description(const std::string & d);
135 /// prints the list off the boxes of the current box
138 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
139 std::string ShowGraph(const std::string &nameblackbox,
140 const std::string &detailStr,
141 const std::string &levelStr,
142 const std::string &output_file,
143 const std::string &custom_header,
144 const std::string &custom_title,
145 bool system_display = true);
147 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
148 std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
150 /// Description of the actual pipeline
151 void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
155 // static const std::string& GetObjectDescription();
156 // { static std::string s("Executer"); return s; }
162 /// Gets the current working black box
163 ComplexBlackBoxDescriptor* Current()
164 { return mOpenDefinition.back().box; }
166 /// Returns true when we are inside a define/endefine block
167 // bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
169 //==================================================================
173 // Factory* mFactory;
178 /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
179 /// Its name in bbi is 'workspace'
180 ComplexBlackBoxDescriptor* mRoot;
182 /// Struct that stores info on user defined complex black boxes
185 ComplexBlackBoxDescriptor* box;
187 CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
188 : box(d), package(p) {}
191 /// The stack of current working ComplexBlackBox
192 /// (is a stack for nested definitions)
193 /// only contains the root when outside a define/endefine block
194 std::deque<CBBDefinition> mOpenDefinition;
196 /// The stack of current working package
197 /// (is a stack for nested definitions)
198 std::deque<Package*> mOpenPackage;
200 /// flag which is true when we are inside a Define/EndDefine block
203 /// The input values of the Root ComplexBlackBox
204 std::map<std::string,std::string> mInputs;
206 /// no exec mode flag
210 DialogModeType mDialogMode;