/*========================================================================= Program: bbtk Module: $RCSfile: bbtkFactory.h,v $ Language: C++ Date: $Date: 2008/04/18 12:59:15 $ Version: $Revision: 1.14 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** *\file *\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. */ /** *\class bbtk::Factory *\brief Can load and unload dynamic libraries containing black boxes packages and create instances of the black boxes registered in the packages loaded. * */ #ifndef __bbtkFactory_h__ #define __bbtkFactory_h__ #include "bbtkPackage.h" namespace bbtk { class Executer; BBTK_FORWARD_DECLARE_POINTER(Executer); class BBTK_EXPORT Factory : public Object { BBTK_OBJECT_INTERFACE(Factory); typedef Object Superclass; public: static Pointer New(); void GetPackagesList(std::vector&); void LoadPackage( const std::string& name ); void UnLoadPackage( const std::string& name ); void PrintPackages(bool details = true, bool adaptors = false) const; void HelpPackage(const std::string& name, bool adaptors = false) const; void HelpBlackBox(const std::string& name, std::string& package, bool full=true ) const; void ShowGraphTypes(const std::string& name) const; void InsertPackage( Package::Pointer ); void RemovePackage( Package::Pointer ); Package::Pointer GetPackage(const std::string& name) const; BlackBox::Pointer NewBlackBox(const std::string& type, const std::string& name) const; BlackBox::Pointer NewAdaptor(const DataInfo& typein, const DataInfo& typeout, const std::string& name) const; BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein, const DataInfo& typeout, const std::string& name) const; bool FindAdaptor(const DataInfo& typein, const DataInfo& typeout, std::string& adaptor) const; bool FindWidgetAdaptor(const DataInfo& typein, const DataInfo& typeout, std::string& adaptor) const; bool FindWidgetAdaptor2(const DataInfo& typein, const DataInfo& typeout, std::string& widget, std::string& adaptor) const; Connection::Pointer NewConnection(BlackBox::Pointer from, const std::string& output, BlackBox::Pointer to, const std::string& input) const; void WriteDotFilePackagesList(FILE *ff); void Reset(); void CheckPackages() const; typedef enum { Packages, Categories, Initials, Adaptors } IndexEntryType; void CreateHtmlIndex(IndexEntryType type, const std::string& filename); /// Sets the executer who created the factory (if any) void SetExecuter(ExecuterPointer e) { mExecuter = e; } /// Gets the executer who created the factory (if any) ExecuterPointer GetExecuter();// { return mExecuter.lock(); } /// Gets the executer who created the factory (if any) - const // const Executer::Pointer GetExecuter() const { return mExecuter.lock(); } private: bool DoLoadPackage(std::string libname, std::string pkgname, std::string path); public: /// The type of map of packages typedef std::map< std::string, Package::Pointer > PackageMapType; const PackageMapType& GetPackageMap() const { return mPackageMap; } private: /// The map of packages PackageMapType mPackageMap; /// The executer which created the factory (if any) ExecuterWeakPointer mExecuter; void CloseAllPackages(); void ClosePackage(PackageMapType::iterator& i); }; // class Factory }// namespace bbtk #endif