1 #ifndef HYDROOperations_Factory_HeaderFile
2 #define HYDROOperations_Factory_HeaderFile
5 #include <HYDROData_Image.h>
8 class ImageComposer_Operator;
9 class Handle_HYDROData_Document;
11 /**\class HYDROOperations_Factory
13 * \brief This class provides the unified management of operations on images.
15 * Object is created as one global instance and allows to register and launch
16 * all registered operations in general way. To register a new operation just
17 * call REGISTER_HYDRO_OPERATION(operation_name) in some method implementation.
18 * This macro will call constructor of this operation (it must inherit
19 * ImageComposer_Operator) and factory will set up arguments and call this
23 class HYDROOperations_Factory
27 //! Returns the global factory
28 HYDRODATA_EXPORT static HYDROOperations_Factory* Factory();
31 * Registers the operator by the name, used by REGISTER_HYDRO_OPERATION macro
32 * \param theOperator new instance of the operator that will be used for
33 * processing of operation with such kind
35 HYDRODATA_EXPORT static void Register(
36 ImageComposer_Operator* theOperator);
39 * Creates a new Image object in the data structure by the operator data.
40 * \param theDoc document where it must be created
41 * \param theOperator base operator for this Image: will be used in "Update" to recompute the image
42 * \returns created object related to the data structure
44 HYDRODATA_EXPORT Handle(HYDROData_Image) CreateImage(
45 Handle_HYDROData_Document theDoc, const ImageComposer_Operator* theOperator);
48 * Updates an Image object in the data structure. If it is changed,
49 * sets "MustBeUpdated" flag to other depended images.
50 * \param theDoc document of this image (needed to update other images flags)
51 * \param theImage the updated image
53 HYDRODATA_EXPORT void UpdateImage(
54 Handle_HYDROData_Document theDoc, Handle(HYDROData_Image) theImage);
57 * Returns the operator, initialized by the properties of theImage
58 * \param theImage data structures object, that contains all arguments
59 * required for creation of operation
60 * \returns NULL if operator type is unknown
62 HYDRODATA_EXPORT ImageComposer_Operator* Operator(
63 Handle(HYDROData_Image) theImage) const;
68 //! Not public constructor that creates only one, global instance of this factory.
69 HYDROOperations_Factory();
72 * Returns the appropriate operator by the name
73 * \param theName name of the operator, equals to the operation_name constructor
74 * \returns NULL if operator with such name is not registered yet
76 ImageComposer_Operator* Operator(const QString theName) const;
79 * Enables "MustBeUpdated" flag for Images that are depended on "MustBeUpdated" images.
80 * \param theDoc document where this operation is performed
82 void SetMustBeUpdatedImages(Handle_HYDROData_Document theDoc) const;
85 //! Map that stores all operators, isentified by strings
86 typedef QMap<QString, ImageComposer_Operator*> FactoryOperators;
88 FactoryOperators myOps; ///< all operators stored by a factory
92 * Macro that is used for registered operators, see C++ of this class to see
93 * example of hte registration.
95 #define REGISTER_HYDRO_OPERATION(operation_name) \
96 HYDROOperations_Factory::Factory()->Register(new operation_name);