1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // modify it under the terms of the GNU Lesser General Public
20 // License as published by the Free Software Foundation; either
21 // version 2.1 of the License, or (at your option) any later version.
23 // This library is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 // Lesser General Public License for more details.
28 // You should have received a copy of the GNU Lesser General Public
29 // License along with this library; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
35 #ifndef HYDROData_OperationsFactory_HeaderFile
36 #define HYDROData_OperationsFactory_HeaderFile
38 #include <HYDROData.h>
39 #include <HYDROData_Image.h>
42 class ImageComposer_Operator;
43 class Handle_HYDROData_Document;
45 /**\class HYDROData_OperationsFactory
47 * \brief This class provides the unified management of operations on images.
49 * Object is created as one global instance and allows to register and launch
50 * all registered operations in general way. To register a new operation just
51 * call REGISTER_HYDRO_OPERATION(operation_name) in some method implementation.
52 * This macro will call constructor of this operation (it must inherit
53 * ImageComposer_Operator) and factory will set up arguments and call this
57 class HYDROData_OperationsFactory
61 //! Returns the global factory
62 HYDRODATA_EXPORT static HYDROData_OperationsFactory* Factory();
65 * Registers the operator by the name, used by REGISTER_HYDRO_OPERATION macro
66 * \param theOperator new instance of the operator that will be used for
67 * processing of operation with such kind
69 HYDRODATA_EXPORT static void Register(
70 ImageComposer_Operator* theOperator);
73 * Creates a new Image object in the data structure by the operator data.
74 * \param theDoc document where it must be created
75 * \param theOperator base operator for this Image: will be used in "Update" to recompute the image
76 * \returns created object related to the data structure
78 HYDRODATA_EXPORT Handle(HYDROData_Image) CreateImage(
79 Handle_HYDROData_Document theDoc, const ImageComposer_Operator* theOperator);
82 * Returns the operator, initialized by the properties of theImage
83 * \param theImage data structures object, that contains all arguments
84 * required for creation of operation
85 * \returns NULL if operator type is unknown
87 HYDRODATA_EXPORT ImageComposer_Operator* Operator(
88 Handle(HYDROData_Image) theImage) const;
92 * Returns the appropriate operator by the name
93 * \param theName name of the operator, equals to the operation_name constructor
94 * \returns NULL if operator with such name is not registered yet
96 HYDRODATA_EXPORT ImageComposer_Operator* Operator(const QString theName) const;
100 //! Not public constructor that creates only one, global instance of this factory.
101 HYDROData_OperationsFactory();
104 //! Map that stores all operators, isentified by strings
105 typedef QMap<QString, ImageComposer_Operator*> FactoryOperators;
107 FactoryOperators myOps; ///< all operators stored by a factory
111 * Macro that is used for registered operators, see C++ of this class to see
112 * example of hte registration.
114 #define REGISTER_HYDRO_OPERATION(operation_name) \
115 HYDROData_OperationsFactory::Factory()->Register(new operation_name);