1 /*=========================================================================
3 Module: $RCSfile: bbtkFactory.h,v $
5 Date: $Date: 2008/10/17 08:18:13 $
6 Version: $Revision: 1.16 $
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 * ------------------------------------------------------------------------ */
33 *\brief Class bbtk::Factory : can load and unload dynamic libraries containing black boxes packages and create instances of the black boxes registered in the packages loaded.
37 *\brief Can load and unload dynamic libraries containing black boxes packages and create instances of the black boxes registered in the packages loaded.
42 #ifndef __bbtkFactory_h__
43 #define __bbtkFactory_h__
45 #include "bbtkPackage.h"
51 BBTK_FORWARD_DECLARE_POINTER(Executer);
53 class BBTK_EXPORT Factory : public Object
55 BBTK_OBJECT_INTERFACE(Factory);
56 typedef Object Superclass;
61 void GetPackagesList(std::vector<std::string>&);
62 void LoadPackage( const std::string& name );
63 void UnLoadPackage( const std::string& name );
64 void PrintPackages(bool details = true, bool adaptors = false) const;
65 void HelpPackage(const std::string& name, bool adaptors = false) const;
66 void HelpBlackBox(const std::string& name, std::string& package,
67 bool full=true ) const;
68 void ShowGraphTypes(const std::string& name) const;
69 void InsertPackage( Package::Pointer );
70 void RemovePackage( Package::Pointer );
72 Package::Pointer GetPackage(const std::string& name) const;
75 BlackBox::Pointer NewBlackBox(const std::string& type,
76 const std::string& name) const;
78 BlackBox::Pointer NewAdaptor(const DataInfo& typein,
79 const DataInfo& typeout,
80 const std::string& name) const;
82 BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein,
83 const DataInfo& typeout,
84 const std::string& name) const;
86 bool FindAdaptor(const DataInfo& typein,
87 const DataInfo& typeout,
88 std::string& adaptor) const;
90 bool FindWidgetAdaptor(const DataInfo& typein,
91 const DataInfo& typeout,
92 std::string& adaptor) const;
94 bool FindWidgetAdaptor2(const DataInfo& typein,
95 const DataInfo& typeout,
97 std::string& adaptor) const;
99 Connection::Pointer NewConnection(BlackBox::Pointer from,
100 const std::string& output,
101 BlackBox::Pointer to,
102 const std::string& input) const;
104 void WriteDotFilePackagesList(FILE *ff);
108 void CheckPackages() const;
118 void CreateHtmlIndex(IndexEntryType type, const std::string& filename);
120 /// Sets the executer who created the factory (if any)
121 void SetExecuter(ExecuterPointer e) { mExecuter = e; }
122 /// Gets the executer who created the factory (if any)
123 ExecuterPointer GetExecuter() { return mExecuter.lock(); }
124 /// Gets the executer who created the factory (if any) - const
125 // const Executer::Pointer GetExecuter() const { return mExecuter.lock(); }
130 bool DoLoadPackage(std::string libname,
136 /// The type of map of packages
137 typedef std::map< std::string, Package::Pointer > PackageMapType;
139 const PackageMapType& GetPackageMap() const { return mPackageMap; }
142 /// The map of packages
143 PackageMapType mPackageMap;
145 /// The executer which created the factory (if any)
146 ExecuterWeakPointer mExecuter;
148 void CloseAllPackages();
149 void ClosePackage(PackageMapType::iterator& i);