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"
55 #include "bbtkUtilities.h"
59 class ComplexBlackBox;
60 typedef boost::shared_ptr<ComplexBlackBox> ComplexBlackBoxPointer;
62 //==========================================================================
63 class BBTK_EXPORT ComplexBlackBoxDescriptor :
64 public bbtk::BlackBoxDescriptor
66 BBTK_OBJECT_INTERFACE(ComplexBlackBoxDescriptor);
67 typedef BlackBoxDescriptor Superclass;
69 friend class ComplexBlackBox;
71 static Pointer New(const std::string& name);
72 /// Sets the factory used
73 void SetFactory(Factory::Pointer f) { mFactory = f; }
74 /// Gets the factory used
75 Factory::Pointer GetFactory() const { return mFactory.lock(); }
77 /// Releases the descriptor
78 // void Release(bool release_package = true);
80 /// Gets the factory used (const)
81 // const Factory* GetFactory() const { return mFactory; }
83 /// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
84 virtual BlackBoxPointer NewBlackBox(const std::string& name);
86 /// Adds a black box to the complex box
87 /// Needs a factory set !
88 void Add ( const std::string& type,
89 const std::string& name
92 /// Removes a black box from the complex box
93 void Remove( const std::string& name, bool remove_connections = true);
95 /// Connects two black boxes of the complex box
96 /// Needs a factory set !
97 void Connect ( const std::string& from,
98 const std::string& output,
99 const std::string& to,
100 const std::string& input
102 /// Defines an input of the complex box
103 void DefineInput ( const std::string& name,
104 const std::string& box,
105 const std::string& input,
106 const std::string& help);
107 /// Defines an output of the complex box
108 void DefineOutput ( const std::string& name,
109 const std::string& box,
110 const std::string& output,
111 const std::string& help);
116 void AddToExecutionList( const std::string& box );
118 ComplexBlackBoxPointer GetPrototype() { return mPrototype; }
119 void PrintBlackBoxes();
121 /// Prints help on the black box
122 void GetHelp(bool full=true) const;
124 /// Writes html formatted help into the output file stream.
125 /// detail and level are used for graphical representation of
126 /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
127 /// output_dir is the directory in which to write auxilliary files
128 /// (.dot/.png/.cmap)
129 void InsertHtmlHelp ( std::ofstream& s,
130 int detail, int level,
131 const std::string& output_dir = "",
132 bool relative_link = false);
134 /// Generates a png image representing the pipeline graph of the
135 /// complex box and writes html code to insert it
136 /// into the output file stream.
138 /// level : depth of nested complex boxes graph development
139 /// (0:only this box level
140 /// output_dir is the directory in which to write the files
141 /// (.dot/.png/.cmap)
142 void InsertHTMLGraph( std::ofstream& s,
143 int detail, int level,
144 const std::string& output_dir = "",
145 bool relative_link = false );
147 void GetBoxesInside (NodeTreeC& tree, int cont);
149 virtual void Check(bool recursive=true) const;
154 /// Default ctor with name is protected
155 ComplexBlackBoxDescriptor(const std::string& name);
160 Factory::WeakPointer mFactory;
161 /// The complex box in which boxes and connections are stored
162 ComplexBlackBoxPointer mPrototype;
165 // class ComplexBlackBoxDescriptor
166 //==========================================================================