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 #ifndef HYDROData_OperationsFactory_HeaderFile
20 #define HYDROData_OperationsFactory_HeaderFile
22 #include <HYDROData.h>
23 #include <HYDROData_Image.h>
26 class ImageComposer_Operator;
27 class Handle_HYDROData_Document;
29 /**\class HYDROData_OperationsFactory
31 * \brief This class provides the unified management of operations on images.
33 * Object is created as one global instance and allows to register and launch
34 * all registered operations in general way. To register a new operation just
35 * call REGISTER_HYDRO_OPERATION(operation_name) in some method implementation.
36 * This macro will call constructor of this operation (it must inherit
37 * ImageComposer_Operator) and factory will set up arguments and call this
41 class HYDROData_OperationsFactory
45 //! Returns the global factory
46 HYDRODATA_EXPORT static HYDROData_OperationsFactory* Factory();
49 * Registers the operator by the name, used by REGISTER_HYDRO_OPERATION macro
50 * \param theOperator new instance of the operator that will be used for
51 * processing of operation with such kind
53 HYDRODATA_EXPORT static void Register(
54 ImageComposer_Operator* theOperator);
57 * Creates a new Image object in the data structure by the operator data.
58 * \param theDoc document where it must be created
59 * \param theOperator base operator for this Image: will be used in "Update" to recompute the image
60 * \returns created object related to the data structure
62 HYDRODATA_EXPORT Handle(HYDROData_Image) CreateImage(
63 Handle_HYDROData_Document theDoc, const ImageComposer_Operator* theOperator);
66 * Returns the operator, initialized by the properties of theImage
67 * \param theImage data structures object, that contains all arguments
68 * required for creation of operation
69 * \returns NULL if operator type is unknown
71 HYDRODATA_EXPORT ImageComposer_Operator* Operator(
72 Handle(HYDROData_Image) theImage) const;
76 * Returns the appropriate operator by the name
77 * \param theName name of the operator, equals to the operation_name constructor
78 * \returns NULL if operator with such name is not registered yet
80 HYDRODATA_EXPORT ImageComposer_Operator* Operator(const QString theName) const;
84 //! Not public constructor that creates only one, global instance of this factory.
85 HYDROData_OperationsFactory();
88 //! Map that stores all operators, isentified by strings
89 typedef QMap<QString, ImageComposer_Operator*> FactoryOperators;
91 FactoryOperators myOps; ///< all operators stored by a factory
95 * Macro that is used for registered operators, see C++ of this class to see
96 * example of hte registration.
98 #define REGISTER_HYDRO_OPERATION(operation_name) \
99 HYDROData_OperationsFactory::Factory()->Register(new operation_name);