bbtkExecuter.h

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkExecuter.h,v $
00004   Language:  C++
00005   Date:      $Date: 2008/10/17 08:18:13 $
00006   Version:   $Revision: 1.16 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00040 #ifndef __bbtkExecuter_h__
00041 #define __bbtkExecuter_h__
00042 
00043 #include "bbtkVirtualExec.h"
00044 
00045 #include "bbtkSystem.h"
00046 #include "bbtkComplexBlackBox.h"
00047 #include "bbtkFactory.h"
00048 #include <string>
00049 #include <deque>
00050 
00051 namespace bbtk
00052 {
00053 
00054   class Interpreter;
00055 
00056 
00057   class /*BBTK_EXPORT*/ Executer : public VirtualExec
00058   {
00059     BBTK_OBJECT_INTERFACE(Executer);
00060     typedef VirtualExec Superclass;
00061   public:
00062     static Pointer New();
00063     
00064 
00066     Factory::Pointer GetFactory() { return mFactory; }
00068     //    const Factory::Pointer GetFactory() const { return mFactory; }
00069 
00070 
00072     void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
00073 
00076     void SetNoExecMode(bool b) { mNoExecMode = b; }
00077 
00078     bool GetNoExecMode() const { return mNoExecMode; }
00079 
00081     void SetDialogMode(DialogModeType t) { mDialogMode = t; }
00082 
00083     void SetNoErrorMode(bool b) { mNoErrorMode = b; }
00084 
00085     bool GetNoErrorMode() const { return mNoErrorMode; }
00086 
00087 
00088     //=================================================================
00090     void LoadPackage(const std::string &name );
00091 
00093     void UnLoadPackage(const std::string &name );
00094 
00096     void BeginPackage (const std::string &name );
00097 
00099     void EndPackage ();
00100 
00103     void Define (const std::string &name,
00104                  const std::string& pack,
00105                  const std::string &scriptfilename);
00106 
00109     void SetCurrentFileName (const std::string &name );
00110 
00112     void EndDefine ();
00113 
00115     void Kind(const std::string& kind);
00116 
00118     void Create ( const std::string& boxType, const std::string& boxName);
00119 
00121     void Destroy (const std::string &boxName);
00122 
00124     void Connect (const std::string &boxfrom,
00125                   const std::string &output,
00126                   const std::string &boxto,
00127                   const std::string &input);
00128 
00130     void Execute (const std::string &box);
00131 
00133     void DefineInput (const std::string &name,
00134                       const std::string &box,
00135                       const std::string &input,
00136                       const std::string &help);
00137 
00139     void DefineOutput (const std::string &name,
00140                        const std::string &box,
00141                        const std::string &output,
00142                        const std::string &help);     
00143 
00145     void Set (const std::string &box, 
00146               const std::string &input, 
00147               const std::string &value);
00148 
00150     std::string Get (const std::string &box, 
00151                      const std::string &output);
00152 
00154     void SetWorkspaceName( const std::string& n );
00155 
00157     void Author(const std::string &authorName);
00158 
00160     void Category(const std::string &category);
00161 
00163     void Description(const std::string & d);
00164 
00166     void PrintBoxes();
00167 
00169     std::string ShowGraph(const std::string &nameblackbox, 
00170                           const std::string &detailStr, 
00171                           const std::string &levelStr,
00172                           const std::string &output_file,
00173                           const std::string &custom_header,
00174                           const std::string &custom_title,
00175                           bool system_display = true);
00176 
00178     std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
00179     
00181     void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
00182     
00184     void Reset();
00185 
00187     void SetMessageLevel(const std::string &kind,
00188                          int level);
00189 
00191     void HelpMessages();
00192     
00193 
00194     void Print(const std::string & message);
00195 
00196   //  static const std::string& GetObjectDescription();
00197   //  { static std::string s("Executer"); return s; }
00198 
00199 
00200     ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
00201     { return mRootCBB.lock(); }
00202     Package::Pointer GetUserPackage() 
00203     { return mRootPackage.lock(); }
00204 
00206     ComplexBlackBoxDescriptor::Pointer GetCurrentDescriptor() 
00207     { return mOpenDefinition.back().box; }
00208     
00209 
00210   protected:
00211 
00212   private:
00213 
00214     
00216     //    bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
00217 
00218     //==================================================================
00219     // ATTRIBUTES
00220      
00222     Factory::Pointer mFactory;
00223     
00224  
00229     Package::WeakPointer mRootPackage;
00230     
00234     ComplexBlackBoxDescriptor::WeakPointer mRootCBB;
00235 
00237     struct CBBDefinition
00238     {
00239       ComplexBlackBoxDescriptor::Pointer box;
00240       std::string package;
00241       CBBDefinition(ComplexBlackBoxDescriptor::Pointer d, 
00242                     const std::string& p )
00243         : box(d), package(p) {}
00244     };
00245 
00249     std::deque<CBBDefinition> mOpenDefinition;
00250 
00253     std::deque<Package::WeakPointer> mOpenPackage;
00254 
00256     std::map<std::string,std::string> mInputs;
00257     
00259     bool mNoExecMode;
00260 
00261 
00263     DialogModeType mDialogMode;
00264 
00266     bool mNoErrorMode;
00267 
00268   };
00269 }
00270 #endif

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6