]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_FilterFactory.h
Salome HOME
Issue #273: Add copyright string
[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 validator objects alive and just returns one of it by request.
25  * All the needed information is provided to the validator 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  public:
31
32    //ModuleBase_FilterFactory();
33    //virtual ~ModuleBase_FilterFactory() {}
34
35
36  private:
37   std::map<std::string, Handle_ModuleBase_Filter> myIDs;  ///< map from ID to registered validator
38   /// validators IDs to list of arguments
39   typedef std::map<std::string, std::list<std::string> > AttrValidators;
40   /// validators IDs by feature ID
41   std::map<std::string, AttrValidators> myFeatures;
42   /// validators IDs and arguments by feature and attribute IDs
43   std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
44   /// Stores the registered attributes that leads to the concealment of referenced objects in 
45   /// data tree. Map from feature kind to set of attribute IDs.
46   std::map<std::string, std::set<std::string> > myConcealed;
47
48  public:
49   /// Registers the instance of the validator by the ID
50   MODULEBASE_EXPORT virtual void registerFilter(const std::string& theID,
51                                                 Handle_ModuleBase_Filter theValidator);
52
53   /// Assigns validator to the attribute of the feature
54   MODULEBASE_EXPORT virtual void assignFilter(const std::string& theID,
55                                             const std::string& theFeatureID,
56                                             const std::string& theAttrID);
57
58   /// Provides a validator for the attribute, returns NULL if no validator
59   MODULEBASE_EXPORT const SelectMgr_ListOfFilter& filters(const std::string& theFeatureID,
60                                        const std::string& theAttrID) const;
61
62   /// Returns registered validator by its Id
63   MODULEBASE_EXPORT virtual const Handle_ModuleBase_Filter validator(const std::string& theID) const;
64
65   /// Returns true if feature and all its attributes are valid.
66   MODULEBASE_EXPORT virtual bool validate(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
67
68   /// register that this attribute in feature is not obligatory for the feature execution
69   /// so, it is not needed for the standard validation mechanism
70   virtual void registerNotObligatory(std::string theFeature, std::string theAttribute);
71
72   /// Returns true if the attribute in feature is not obligatory for the feature execution
73   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
74
75   /// register that this attribute conceals in the object browser
76   /// all referenced features after execution
77   virtual void registerConcealment(std::string theFeature, std::string theAttribute);
78
79   /// Returns true that it was registered that attribute conceals the referenced result
80   virtual bool isConcealed(std::string theFeature, std::string theAttribute);
81
82 protected:
83   void addDefaultValidators(std::list<Handle_ModuleBase_Filter>& theValidators) const;
84   /// Get instance from workshop
85
86   ModuleBase_FilterFactory();
87
88   ~ModuleBase_FilterFactory() {}
89
90   friend class ModuleBase_IWorkshop;
91
92 };
93
94 #endif //ModuleBase_FilterFactory