2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkComplexBlackBoxDescriptor.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.8 $
34 =========================================================================*/
39 * \brief Class bbtk::ComplexBlackBoxDescriptor : describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
42 * \class bbtk::ComplexBlackBoxDescriptor
43 * \brief Describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
46 #ifndef __bbtkComplexBlackBoxDescriptor_h__
47 #define __bbtkComplexBlackBoxDescriptor_h__
49 #include "bbtkBlackBoxDescriptor.h"
50 #include "bbtkComplexBlackBoxInputDescriptor.h"
51 #include "bbtkComplexBlackBoxOutputDescriptor.h"
52 #include "bbtkFactory.h"
58 class ComplexBlackBox;
59 typedef boost::shared_ptr<ComplexBlackBox> ComplexBlackBoxPointer;
61 //==========================================================================
62 class BBTK_EXPORT ComplexBlackBoxDescriptor :
63 public bbtk::BlackBoxDescriptor
65 BBTK_OBJECT_INTERFACE(ComplexBlackBoxDescriptor);
66 typedef BlackBoxDescriptor Superclass;
68 friend class ComplexBlackBox;
70 static Pointer New(const std::string& name);
71 /// Sets the factory used
72 void SetFactory(Factory::Pointer f) { mFactory = f; }
73 /// Gets the factory used
74 Factory::Pointer GetFactory() const { return mFactory.lock(); }
76 /// Releases the descriptor
77 // void Release(bool release_package = true);
79 /// Gets the factory used (const)
80 // const Factory* GetFactory() const { return mFactory; }
82 /// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
83 virtual BlackBoxPointer NewBlackBox(const std::string& name);
85 /// Adds a black box to the complex box
86 /// Needs a factory set !
87 void Add ( const std::string& type,
88 const std::string& name
91 /// Removes a black box from the complex box
92 void Remove( const std::string& name, bool remove_connections = true);
94 /// Connects two black boxes of the complex box
95 /// Needs a factory set !
96 void Connect ( const std::string& from,
97 const std::string& output,
98 const std::string& to,
99 const std::string& input
101 /// Defines an input of the complex box
102 void DefineInput ( const std::string& name,
103 const std::string& box,
104 const std::string& input,
105 const std::string& help);
106 /// Defines an output of the complex box
107 void DefineOutput ( const std::string& name,
108 const std::string& box,
109 const std::string& output,
110 const std::string& help);
115 void AddToExecutionList( const std::string& box );
117 ComplexBlackBoxPointer GetPrototype() { return mPrototype; }
118 void PrintBlackBoxes();
120 /// Prints help on the black box
121 void GetHelp(bool full=true) const;
123 /// Writes html formatted help into the output file stream.
124 /// detail and level are used for graphical representation of
125 /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
126 /// output_dir is the directory in which to write auxilliary files
127 /// (.dot/.png/.cmap)
128 void InsertHtmlHelp ( std::ofstream& s,
129 int detail, int level,
130 const std::string& output_dir = "",
131 bool relative_link = false);
133 /// Generates a png image representing the pipeline graph of the
134 /// complex box and writes html code to insert it
135 /// into the output file stream.
137 /// level : depth of nested complex boxes graph development
138 /// (0:only this box level
139 /// output_dir is the directory in which to write the files
140 /// (.dot/.png/.cmap)
141 void InsertHTMLGraph( std::ofstream& s,
142 int detail, int level,
143 const std::string& output_dir = "",
144 bool relative_link = false );
148 virtual void Check(bool recursive=true) const;
153 /// Default ctor with name is protected
154 ComplexBlackBoxDescriptor(const std::string& name);
159 Factory::WeakPointer mFactory;
160 /// The complex box in which boxes and connections are stored
161 ComplexBlackBoxPointer mPrototype;
164 // class ComplexBlackBoxDescriptor
165 //==========================================================================