1 // File: ModuleBase_FilterFactory.h
2 // Created: 10 Dec 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef ModuleBase_FilterFactory_H
6 #define ModeleBase_SelectionFilterFactory_H
8 #include "ModuleBase.h"
9 #include "ModuleBase_IWorkshop.h"
10 #include "ModuleBase_Filter.h"
12 #include <SelectMgr_ListOfFilter.hxx>
18 * Allows to get a selection filter by the feature identifier and
19 * the attribute identifier (if attribute is validated).
20 * All accessible filters must be registered by the ID string first.
21 * The instance of this factory can be get in the Workshop interface.
22 * Keeps the validator objects alive and just returns one of it by request.
23 * All the needed information is provided to the validator as an argument,
24 * this allows to work with them independently from the feature specific object.
26 class ModuleBase_FilterFactory : public QObject
30 //ModuleBase_FilterFactory();
31 //virtual ~ModuleBase_FilterFactory() {}
35 std::map<std::string, Handle_ModuleBase_Filter> myIDs; ///< map from ID to registered validator
36 /// validators IDs to list of arguments
37 typedef std::map<std::string, std::list<std::string> > AttrValidators;
38 /// validators IDs by feature ID
39 std::map<std::string, AttrValidators> myFeatures;
40 /// validators IDs and arguments by feature and attribute IDs
41 std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
42 /// Stores the registered attributes that leads to the concealment of referenced objects in
43 /// data tree. Map from feature kind to set of attribute IDs.
44 std::map<std::string, std::set<std::string> > myConcealed;
47 /// Registers the instance of the validator by the ID
48 MODULEBASE_EXPORT virtual void registerFilter(const std::string& theID,
49 Handle_ModuleBase_Filter theValidator);
51 /// Assigns validator to the attribute of the feature
52 MODULEBASE_EXPORT virtual void assignFilter(const std::string& theID,
53 const std::string& theFeatureID,
54 const std::string& theAttrID);
56 /// Provides a validator for the attribute, returns NULL if no validator
57 MODULEBASE_EXPORT const SelectMgr_ListOfFilter& filters(const std::string& theFeatureID,
58 const std::string& theAttrID) const;
60 /// Returns registered validator by its Id
61 MODULEBASE_EXPORT virtual const Handle_ModuleBase_Filter validator(const std::string& theID) const;
63 /// Returns true if feature and all its attributes are valid.
64 MODULEBASE_EXPORT virtual bool validate(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
66 /// register that this attribute in feature is not obligatory for the feature execution
67 /// so, it is not needed for the standard validation mechanism
68 virtual void registerNotObligatory(std::string theFeature, std::string theAttribute);
70 /// Returns true if the attribute in feature is not obligatory for the feature execution
71 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
73 /// register that this attribute conceals in the object browser
74 /// all referenced features after execution
75 virtual void registerConcealment(std::string theFeature, std::string theAttribute);
77 /// Returns true that it was registered that attribute conceals the referenced result
78 virtual bool isConcealed(std::string theFeature, std::string theAttribute);
81 void addDefaultValidators(std::list<Handle_ModuleBase_Filter>& theValidators) const;
82 /// Get instance from workshop
84 ModuleBase_FilterFactory();
86 ~ModuleBase_FilterFactory() {}
88 friend class ModuleBase_IWorkshop;
92 #endif //ModuleBase_FilterFactory