X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkFactory.h;h=a686fa4f9debc5e62513d9ecae06c2da7b839eaf;hb=2d2fc4c6349d5040a9f13a240f079e7a1c6687dd;hp=34e435d3082c8e30b12d146686cce34f573bda70;hpb=6c5d7746e8e4cb0b5d6e164b917008a7137910fb;p=bbtk.git diff --git a/kernel/src/bbtkFactory.h b/kernel/src/bbtkFactory.h index 34e435d..a686fa4 100644 --- a/kernel/src/bbtkFactory.h +++ b/kernel/src/bbtkFactory.h @@ -1,20 +1,33 @@ -/*========================================================================= - +/*========================================================================= Program: bbtk Module: $RCSfile: bbtkFactory.h,v $ Language: C++ - Date: $Date: 2008/04/08 06:59:30 $ - Version: $Revision: 1.12 $ - - 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. - + Date: $Date: 2008/10/17 08:18:13 $ + Version: $Revision: 1.16 $ =========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + /** *\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. @@ -29,22 +42,21 @@ #ifndef __bbtkFactory_h__ #define __bbtkFactory_h__ -//#include "bbtkBlackBox.h" #include "bbtkPackage.h" -#include "bbtkDynamicLibraryHandling.h" namespace bbtk { class Executer; + BBTK_FORWARD_DECLARE_POINTER(Executer); - class BBTK_EXPORT Factory + class BBTK_EXPORT Factory : public Object { - + BBTK_OBJECT_INTERFACE(Factory); + typedef Object Superclass; public: + static Pointer New(); - Factory(); - ~Factory(); void GetPackagesList(std::vector&); void LoadPackage( const std::string& name ); @@ -54,20 +66,20 @@ namespace bbtk void HelpBlackBox(const std::string& name, std::string& package, bool full=true ) const; void ShowGraphTypes(const std::string& name) const; - void InsertPackage( Package* ); - void RemovePackage( Package* ); + void InsertPackage( Package::Pointer ); + void RemovePackage( Package::Pointer ); + + Package::Pointer GetPackage(const std::string& name) const; - const Package* GetPackage(const std::string& name) const; - Package* GetPackage(const std::string& name); - BlackBox* NewBlackBox(const std::string& type, + BlackBox::Pointer NewBlackBox(const std::string& type, const std::string& name) const; - BlackBox* NewAdaptor(const DataInfo& typein, + BlackBox::Pointer NewAdaptor(const DataInfo& typein, const DataInfo& typeout, const std::string& name) const; - BlackBox* NewWidgetAdaptor(const DataInfo& typein, + BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein, const DataInfo& typeout, const std::string& name) const; @@ -79,15 +91,22 @@ namespace bbtk const DataInfo& typeout, std::string& adaptor) const; - Connection* NewConnection(BlackBox* from, - const std::string& output, - BlackBox* to, - const std::string& input) 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, @@ -99,11 +118,11 @@ namespace bbtk void CreateHtmlIndex(IndexEntryType type, const std::string& filename); /// Sets the executer who created the factory (if any) - void SetExecuter(Executer *e) { mExecuter = e; } + void SetExecuter(ExecuterPointer e) { mExecuter = e; } /// Gets the executer who created the factory (if any) - Executer* GetExecuter() { return mExecuter; } + ExecuterPointer GetExecuter() { return mExecuter.lock(); } /// Gets the executer who created the factory (if any) - const - const Executer* GetExecuter() const { return mExecuter; } + // const Executer::Pointer GetExecuter() const { return mExecuter.lock(); } private: @@ -113,21 +132,9 @@ namespace bbtk std::string path); public: - /// The structure storing info on a package - class PackageInfoType - { - public : - /// Ctor - PackageInfoType() {} - /// Dtor - ~PackageInfoType() {} - /// The pointer on the package - Package* mPackage; - /// The handler of the dynamic library - DynamicLibraryHandler mDynamicLibraryHandler; - }; + /// The type of map of packages - typedef std::map< std::string, PackageInfoType > PackageMapType; + typedef std::map< std::string, Package::Pointer > PackageMapType; const PackageMapType& GetPackageMap() const { return mPackageMap; } @@ -136,7 +143,7 @@ namespace bbtk PackageMapType mPackageMap; /// The executer which created the factory (if any) - Executer* mExecuter; + ExecuterWeakPointer mExecuter; void CloseAllPackages(); void ClosePackage(PackageMapType::iterator& i); @@ -146,113 +153,6 @@ namespace bbtk - /* - /// SYSTEM METHOD : Global method returning the global factory object pointer - inline Factory*& GlobalFactoryPointer() - { - static Factory* f = 0; - return f; - } - - /// SYSTEM METHOD : Global method returning the global factory object - inline Factory* GetGlobalFactory() - { - if (!GlobalFactoryPointer()) - { - GlobalFactoryPointer() = new Factory; - } - return GlobalFactoryPointer(); - } - - /// SYSTEM METHOD : Deletes the global factory pointer - inline void DeleteGlobalFactory() - { - if (GlobalFactoryPointer()) - { - delete GlobalFactoryPointer(); - } - } - - inline void LoadPackage( const std::string& name ) - { - GetGlobalFactory()->LoadPackage(name); - } - - inline void UnLoadPackage( const std::string& name ) - { - GetGlobalFactory()->UnLoadPackage(name); - } - - inline void PrintPackages(bool details = true, bool adaptors = false) - { - GetGlobalFactory()->PrintPackages(details,adaptors); - } - - inline void HelpPackage(const std::string& name, bool adaptors = false) - { - GetGlobalFactory()->HelpPackage(name,adaptors); - } - - inline void HelpBlackBox(const std::string& name, bool full=true) - { - std::string package; - GetGlobalFactory()->HelpBlackBox(name, package, full); - } - - inline void HelpBlackBox(const std::string& name, std::string& package, - bool full=true - ) - { - GetGlobalFactory()->HelpBlackBox(name, package, full); - } - - - inline void ShowGraphTypes(const std::string& name) - { - GetGlobalFactory()->ShowGraphTypes(name); - } - - inline void InsertPackage( Package* p) - { - GetGlobalFactory()->InsertPackage(p); - } - - inline void RemovePackage( Package* p) - { - GetGlobalFactory()->RemovePackage(p); - } - - inline const Package* GetPackage(const std::string& name) - { - return GetGlobalFactory()->GetPackage(name); - } - - inline BlackBox* NewBlackBox(const std::string& type, - const std::string& name) - { - return GetGlobalFactory()->NewBlackBox(type,name); - } - - inline BlackBox* NewAdaptor(TypeInfo typein, - TypeInfo typeout, - const std::string& name) - { - return GetGlobalFactory()->NewAdaptor(typein,typeout,name); - } - - inline Connection* NewConnection(BlackBox* from, - const std::string& output, - BlackBox* to, - const std::string& input) - { - return GetGlobalFactory()->NewConnection(from,output,to,input); - } - - inline void WriteDotFilePackagesList(FILE *ff) - { - GetGlobalFactory()->WriteDotFilePackagesList(ff); - } - */ }// namespace bbtk