1 /*=========================================================================
4 Module: $RCSfile: bbtkFactory.h,v $
6 Date: $Date: 2008/04/24 11:49:59 $
7 Version: $Revision: 1.15 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See doc/license.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 *\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.
24 *\brief Can load and unload dynamic libraries containing black boxes packages and create instances of the black boxes registered in the packages loaded.
29 #ifndef __bbtkFactory_h__
30 #define __bbtkFactory_h__
32 #include "bbtkPackage.h"
38 BBTK_FORWARD_DECLARE_POINTER(Executer);
40 class BBTK_EXPORT Factory : public Object
42 BBTK_OBJECT_INTERFACE(Factory);
43 typedef Object Superclass;
48 void GetPackagesList(std::vector<std::string>&);
49 void LoadPackage( const std::string& name );
50 void UnLoadPackage( const std::string& name );
51 void PrintPackages(bool details = true, bool adaptors = false) const;
52 void HelpPackage(const std::string& name, bool adaptors = false) const;
53 void HelpBlackBox(const std::string& name, std::string& package,
54 bool full=true ) const;
55 void ShowGraphTypes(const std::string& name) const;
56 void InsertPackage( Package::Pointer );
57 void RemovePackage( Package::Pointer );
59 Package::Pointer GetPackage(const std::string& name) const;
62 BlackBox::Pointer NewBlackBox(const std::string& type,
63 const std::string& name) const;
65 BlackBox::Pointer NewAdaptor(const DataInfo& typein,
66 const DataInfo& typeout,
67 const std::string& name) const;
69 BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein,
70 const DataInfo& typeout,
71 const std::string& name) const;
73 bool FindAdaptor(const DataInfo& typein,
74 const DataInfo& typeout,
75 std::string& adaptor) const;
77 bool FindWidgetAdaptor(const DataInfo& typein,
78 const DataInfo& typeout,
79 std::string& adaptor) const;
81 bool FindWidgetAdaptor2(const DataInfo& typein,
82 const DataInfo& typeout,
84 std::string& adaptor) const;
86 Connection::Pointer NewConnection(BlackBox::Pointer from,
87 const std::string& output,
89 const std::string& input) const;
91 void WriteDotFilePackagesList(FILE *ff);
95 void CheckPackages() const;
105 void CreateHtmlIndex(IndexEntryType type, const std::string& filename);
107 /// Sets the executer who created the factory (if any)
108 void SetExecuter(ExecuterPointer e) { mExecuter = e; }
109 /// Gets the executer who created the factory (if any)
110 ExecuterPointer GetExecuter() { return mExecuter.lock(); }
111 /// Gets the executer who created the factory (if any) - const
112 // const Executer::Pointer GetExecuter() const { return mExecuter.lock(); }
117 bool DoLoadPackage(std::string libname,
123 /// The type of map of packages
124 typedef std::map< std::string, Package::Pointer > PackageMapType;
126 const PackageMapType& GetPackageMap() const { return mPackageMap; }
129 /// The map of packages
130 PackageMapType mPackageMap;
132 /// The executer which created the factory (if any)
133 ExecuterWeakPointer mExecuter;
135 void CloseAllPackages();
136 void ClosePackage(PackageMapType::iterator& i);