#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Applications/VisualDataFlow/Factory.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2002, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVLDF_DFFACTORY_HEADER #define RAVLDF_DFFACTORY_HEADER 1 //! rcsid="$Id: Factory.hh,v 1.2 2002/08/08 16:03:10 craftit Exp $" //! lib=RavlVDF //! author="Charles Galambos" //! docentry="Ravl.Applications.VDF" //! date="2/8/2002" //! file="Ravl/Applications/VisualDataFlow/Factory.hh" #include "Ravl/Text/ConfigFile.hh" #include "Ravl/DF/DFObject.hh" #include "Ravl/GUI/Pixmap.hh" #include "Ravl/Calls.hh" #include "Ravl/Hash.hh" namespace RavlDFN { using namespace RavlN; using namespace RavlGUIN; //! userlevel=Develop //: Factory base class. class FactoryBodyC : public RCBodyVC { public: FactoryBodyC(const StringC &nName); //: Constructor. FactoryBodyC(const StringC &nName,const PixmapC &pm); //: Constructor. FactoryBodyC(const StringC &nName,const PixmapC &pm,const CallFunc0C &func); //: Constructor. FactoryBodyC(ConfigFileC &cfg); //: Constructor. bool Load(ConfigFileC &cfg); //: Load configuration from a file. const StringC &Name() const { return name; } //: Get name of object. PixmapC Icon() const; //: Get an icon for the object. virtual DFObjectC Create(); //: Create a new object. CallFunc0C &CreateFunction() { return func; } //: Access create function. const DListC Section() const { return section; } //: Section for factory. const DListC Section(const StringC §ion); //: Set section. // Expects a . seperated string. protected: HashC nameMapping; // IO Name mappings. StringC name; PixmapC icon; CallFunc0C func; DListC section; }; //! userlevel=Normal //: Factory base class. class FactoryC : public RCHandleC { public: FactoryC() {} //: Default constructor. // Creates an invalid handle. FactoryC(const StringC &name) : RCHandleC(*new FactoryBodyC(name)) {} //: Create a no-op factory. FactoryC(const StringC &name,const PixmapC &pixmap) : RCHandleC(*new FactoryBodyC(name,pixmap)) {} //: Create a no-op factory. FactoryC(const StringC &nName,const PixmapC &pm,const CallFunc0C &func) : RCHandleC(*new FactoryBodyC(nName,pm,func)) {} //: Constructor. FactoryC(ConfigFileC &cfg) : RCHandleC(*new FactoryBodyC(cfg)) {} //: Init from configuration. protected: FactoryC(FactoryBodyC &bod) : RCHandleC(bod) {} //: Body constructor. FactoryBodyC &Body() { return RCHandleC::Body(); } //: Access body. const FactoryBodyC &Body() const { return RCHandleC::Body(); } //: Access body. public: bool Load(ConfigFileC &cfg) { return Load(cfg); } //: Load configuration from a file. const StringC &Name() const { return Body().Name(); } //: Get name of object. PixmapC Icon() const { return Body().Icon(); } //: Get an icon for the object. DFObjectC Create() { return Body().Create(); } //: Create a new object. CallFunc0C &CreateFunction() { return Body().CreateFunction(); } //: Access create function. const DListC Section() const { return Body().Section(); } //: Section for factory. const DListC Section(const StringC §ion) { return Body().Section(section); } //: Set section. // Expects a . seperated string. friend class FactoryBodyC; }; } #endif