Salome HOME
Merge branch 'master' into Dev_1.1.0
[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  * \ingroup GUI
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.
28  */
29 class ModuleBase_FilterFactory : public QObject
30 {
31  private:
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;
39
40  public:
41   /// Registers the instance of the filter by the ID
42   MODULEBASE_EXPORT virtual void registerFilter(const std::string& theID,
43                                                 ModuleBase_Filter* theFilter);
44
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);
50
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;
55
56   /// Returns registered filter by its Id
57   MODULEBASE_EXPORT virtual const ModuleBase_Filter* filter(const std::string& theID) const;
58
59 protected:
60   ModuleBase_FilterFactory();
61
62   ~ModuleBase_FilterFactory() {}
63
64   friend class ModuleBase_IWorkshop;
65
66 };
67
68 #endif //ModuleBase_FilterFactory