1 #ifndef HYDROData_OperationsFactory_HeaderFile
2 #define HYDROData_OperationsFactory_HeaderFile
5 #include <HYDROData_Image.h>
8 class ImageComposer_Operator;
9 class Handle_HYDROData_Document;
11 /**\class HYDROData_OperationsFactory
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 HYDROData_OperationsFactory
27 //! Returns the global factory
28 HYDRODATA_EXPORT static HYDROData_OperationsFactory* 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 * Returns the operator, initialized by the properties of theImage
49 * \param theImage data structures object, that contains all arguments
50 * required for creation of operation
51 * \returns NULL if operator type is unknown
53 HYDRODATA_EXPORT ImageComposer_Operator* Operator(
54 Handle(HYDROData_Image) theImage) const;
58 * Returns the appropriate operator by the name
59 * \param theName name of the operator, equals to the operation_name constructor
60 * \returns NULL if operator with such name is not registered yet
62 HYDRODATA_EXPORT ImageComposer_Operator* Operator(const QString theName) const;
66 //! Not public constructor that creates only one, global instance of this factory.
67 HYDROData_OperationsFactory();
70 //! Map that stores all operators, isentified by strings
71 typedef QMap<QString, ImageComposer_Operator*> FactoryOperators;
73 FactoryOperators myOps; ///< all operators stored by a factory
77 * Macro that is used for registered operators, see C++ of this class to see
78 * example of hte registration.
80 #define REGISTER_HYDRO_OPERATION(operation_name) \
81 HYDROData_OperationsFactory::Factory()->Register(new operation_name);