1 /*=========================================================================
3 Module: $RCSfile: bbtkComplexBlackBoxDescriptor.h,v $
5 Date: $Date: 2012/11/14 07:12:00 $
6 Version: $Revision: 1.7 $
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);
110 void AddToExecutionList( const std::string& box );
112 ComplexBlackBoxPointer GetPrototype() { return mPrototype; }
113 void PrintBlackBoxes();
115 /// Prints help on the black box
116 void GetHelp(bool full=true) const;
118 /// Writes html formatted help into the output file stream.
119 /// detail and level are used for graphical representation of
120 /// complex black boxes (see ComplexBlackBox::InsertHTMLGraph)
121 /// output_dir is the directory in which to write auxilliary files
122 /// (.dot/.png/.cmap)
123 void InsertHtmlHelp ( std::ofstream& s,
124 int detail, int level,
125 const std::string& output_dir = "",
126 bool relative_link = false);
128 /// Generates a png image representing the pipeline graph of the
129 /// complex box and writes html code to insert it
130 /// into the output file stream.
132 /// level : depth of nested complex boxes graph development
133 /// (0:only this box level
134 /// output_dir is the directory in which to write the files
135 /// (.dot/.png/.cmap)
136 void InsertHTMLGraph( std::ofstream& s,
137 int detail, int level,
138 const std::string& output_dir = "",
139 bool relative_link = false );
143 virtual void Check(bool recursive=true) const;
148 /// Default ctor with name is protected
149 ComplexBlackBoxDescriptor(const std::string& name);
154 Factory::WeakPointer mFactory;
155 /// The complex box in which boxes and connections are stored
156 ComplexBlackBoxPointer mPrototype;
159 // class ComplexBlackBoxDescriptor
160 //==========================================================================