1 /*=========================================================================
3 Module: $RCSfile: bbtkComplexBlackBoxDescriptor.h,v $
5 Date: $Date: 2008/10/17 08:18:12 $
6 Version: $Revision: 1.6 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
34 * \brief Class bbtk::ComplexBlackBoxDescriptor : describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
37 * \class bbtk::ComplexBlackBoxDescriptor
38 * \brief Describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
41 #ifndef __bbtkComplexBlackBoxDescriptor_h__
42 #define __bbtkComplexBlackBoxDescriptor_h__
44 #include "bbtkBlackBoxDescriptor.h"
45 #include "bbtkComplexBlackBoxInputDescriptor.h"
46 #include "bbtkComplexBlackBoxOutputDescriptor.h"
47 #include "bbtkFactory.h"
53 class ComplexBlackBox;
54 typedef boost::shared_ptr<ComplexBlackBox> ComplexBlackBoxPointer;
56 //==========================================================================
57 class BBTK_EXPORT ComplexBlackBoxDescriptor :
58 public bbtk::BlackBoxDescriptor
60 BBTK_OBJECT_INTERFACE(ComplexBlackBoxDescriptor);
61 typedef BlackBoxDescriptor Superclass;
63 friend class ComplexBlackBox;
65 static Pointer New(const std::string& name);
66 /// Sets the factory used
67 void SetFactory(Factory::Pointer f) { mFactory = f; }
68 /// Gets the factory used
69 Factory::Pointer GetFactory() const { return mFactory.lock(); }
71 /// Releases the descriptor
72 // void Release(bool release_package = true);
74 /// Gets the factory used (const)
75 // const Factory* GetFactory() const { return mFactory; }
77 /// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
78 virtual BlackBoxPointer NewBlackBox(const std::string& name);
80 /// Adds a black box to the complex box
81 /// Needs a factory set !
82 void Add ( const std::string& type,
83 const std::string& name
86 /// Removes a black box from the complex box
87 void Remove( const std::string& name, bool remove_connections = true);
89 /// Connects two black boxes of the complex box
90 /// Needs a factory set !
91 void Connect ( const std::string& from,
92 const std::string& output,
93 const std::string& to,
94 const std::string& input
96 /// Defines an input of the complex box
97 void DefineInput ( const std::string& name,
98 const std::string& box,
99 const std::string& input,
100 const std::string& help);
101 /// Defines an output of the complex box
102 void DefineOutput ( const std::string& name,
103 const std::string& box,
104 const std::string& output,
105 const std::string& help);
108 /// Sets the name of the script file from which it is defined
109 void SetScriptFileName(const std::string& n) { mScriptFileName = n; }
110 /// Gets the name of the script file from which it is defined
111 std::string GetScriptFileName() const { return mScriptFileName; }
114 void AddToExecutionList( const std::string& box );
116 ComplexBlackBoxPointer GetPrototype() { return mPrototype; }
117 void PrintBlackBoxes();
119 /// Prints help on the black box
120 void GetHelp(bool full=true) const;
122 /// Writes html formatted help into the output file stream.
123 /// detail and level are used for graphical representation of
124 /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
125 /// output_dir is the directory in which to write auxilliary files
126 /// (.dot/.png/.cmap)
127 void InsertHtmlHelp ( std::ofstream& s,
128 int detail, int level,
129 const std::string& output_dir = "",
130 bool relative_link = false);
132 /// Generates a png image representing the pipeline graph of the
133 /// complex box and writes html code to insert it
134 /// into the output file stream.
136 /// level : depth of nested complex boxes graph development
137 /// (0:only this box level
138 /// output_dir is the directory in which to write the files
139 /// (.dot/.png/.cmap)
140 void InsertHTMLGraph( std::ofstream& s,
141 int detail, int level,
142 const std::string& output_dir = "",
143 bool relative_link = false );
147 virtual void Check(bool recursive=true) const;
152 /// Default ctor with name is protected
153 ComplexBlackBoxDescriptor(const std::string& name);
157 Factory::WeakPointer mFactory;
158 /// The complex box in which boxes and connections are stored
159 ComplexBlackBoxPointer mPrototype;
160 /// The name of the script file from which it was created
161 std::string mScriptFileName;
164 // class ComplexBlackBoxDescriptor
165 //==========================================================================