1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_FilterFactory.h
4 // Created: 10 Dec 2014
5 // Author: Natalia ERMOLAEVA
7 #ifndef ModuleBase_FilterFactory_H
8 #define ModeleBase_SelectionFilterFactory_H
10 #include "ModuleBase.h"
11 #include "ModuleBase_IWorkshop.h"
12 #include "ModuleBase_Filter.h"
14 #include <SelectMgr_ListOfFilter.hxx>
21 * Allows to get a selection filter by the feature identifier and
22 * the attribute identifier (if attribute is validated).
23 * All accessible filters must be registered by the ID string first.
24 * The instance of this factory can be get in the Workshop interface.
25 * Keeps the filter objects alive and just returns one of it by request.
26 * All the needed information is provided to the filter as an argument,
27 * this allows to work with them independently from the feature specific object.
29 class ModuleBase_FilterFactory : public QObject
32 std::map<std::string, ModuleBase_Filter*> myIDs; ///< map from ID to registered filter
33 /// filters IDs to list of arguments
34 typedef std::map<std::string, std::list<std::string> > AttrFilters;
35 /// filters IDs by feature ID
36 std::map<std::string, AttrFilters> myFeatures;
37 /// filters IDs and arguments by feature and attribute IDs
38 std::map<std::string, std::map<std::string, AttrFilters> > myAttrs;
41 /// Registers the instance of the filter by the ID
42 MODULEBASE_EXPORT virtual void registerFilter(const std::string& theID,
43 ModuleBase_Filter* theFilter);
45 /// Assigns filter to the attribute of the feature
46 MODULEBASE_EXPORT virtual void assignFilter(const std::string& theID,
47 const std::string& theFeatureID,
48 const std::string& theAttrID,
49 const std::list<std::string>& theArguments);
51 /// Provides a filter for the attribute, returns NULL if no filter
52 MODULEBASE_EXPORT void filters(const std::string& theFeatureID,
53 const std::string& theAttrID,
54 SelectMgr_ListOfFilter& theFilters) const;
56 /// Returns registered filter by its Id
57 MODULEBASE_EXPORT virtual const ModuleBase_Filter* filter(const std::string& theID) const;
60 ModuleBase_FilterFactory();
62 ~ModuleBase_FilterFactory() {}
64 friend class ModuleBase_IWorkshop;
68 #endif //ModuleBase_FilterFactory