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