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: 2009/06/08 14:50:03 $
00006   Version:   $Revision: 1.18 $
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 Clear();
00125 
00127     void Connect (const std::string &boxfrom,
00128                   const std::string &output,
00129                   const std::string &boxto,
00130                   const std::string &input);
00131 
00133     void Execute (const std::string &box);
00134 
00136     void DefineInput (const std::string &name,
00137                       const std::string &box,
00138                       const std::string &input,
00139                       const std::string &help);
00140 
00142     void DefineOutput (const std::string &name,
00143                        const std::string &box,
00144                        const std::string &output,
00145                        const std::string &help);     
00146 
00148     void Set (const std::string &box, 
00149               const std::string &input, 
00150               const std::string &value);
00151 
00153     std::string Get (const std::string &box, 
00154                      const std::string &output);
00155 
00157     void SetWorkspaceName( const std::string& n );
00158 
00160     void Author(const std::string &authorName);
00161 
00163     void Category(const std::string &category);
00164 
00166     void Description(const std::string & d);
00167 
00168 
00169 
00170 
00171 
00172 
00174     void PrintHelpListBoxes();
00175 
00177     std::string ShowGraph(const std::string &nameblackbox, 
00178                           const std::string &detailStr, 
00179                           const std::string &levelStr,
00180                           const std::string &output_file,
00181                           const std::string &custom_header,
00182                           const std::string &custom_title,
00183                           bool system_display = true);
00184 
00186     std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true);
00187     
00189     void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
00190     
00191 
00192 
00193 
00194 
00195 
00197     void Reset();
00198 
00200     void SetMessageLevel(const std::string &kind,
00201                          int level);
00202 
00204     void HelpMessages();
00205     
00206 
00207     void Print(const std::string & message);
00208 
00209   //  static const std::string& GetObjectDescription();
00210   //  { static std::string s("Executer"); return s; }
00211 
00212 
00213     ComplexBlackBoxDescriptor::Pointer GetWorkspace() 
00214     { return mRootCBB.lock(); }
00215     Package::Pointer GetUserPackage() 
00216     { return mRootPackage.lock(); }
00217 
00219     ComplexBlackBoxDescriptor::Pointer GetCurrentDescriptor() 
00220     { return mOpenDefinition.back().box; }
00221     
00222 
00223   protected:
00224 
00225   private:
00226 
00227     
00229     //    bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
00230 
00231     //==================================================================
00232     // ATTRIBUTES
00233      
00235     Factory::Pointer mFactory;
00236     
00237  
00242     Package::WeakPointer mRootPackage;
00243     
00247     ComplexBlackBoxDescriptor::WeakPointer mRootCBB;
00248 
00250     struct CBBDefinition
00251     {
00252       ComplexBlackBoxDescriptor::Pointer box;
00253       std::string package;
00254       CBBDefinition(ComplexBlackBoxDescriptor::Pointer d, 
00255                     const std::string& p )
00256         : box(d), package(p) {}
00257     };
00258 
00262     std::deque<CBBDefinition> mOpenDefinition;
00263 
00266     std::deque<Package::WeakPointer> mOpenPackage;
00267 
00269     std::map<std::string,std::string> mInputs;
00270     
00272     bool mNoExecMode;
00273 
00274 
00276     DialogModeType mDialogMode;
00277 
00279     bool mNoErrorMode;
00280 
00281   };
00282 }
00283 #endif

Generated on Thu May 31 14:12:03 2012 for BBTK by  doxygen 1.5.7.1