1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_OperationsFactory_HeaderFile
24 #define HYDROData_OperationsFactory_HeaderFile
26 #include <HYDROData.h>
27 #include <HYDROData_Image.h>
30 class ImageComposer_Operator;
31 class Handle_HYDROData_Document;
33 /**\class HYDROData_OperationsFactory
35 * \brief This class provides the unified management of operations on images.
37 * Object is created as one global instance and allows to register and launch
38 * all registered operations in general way. To register a new operation just
39 * call REGISTER_HYDRO_OPERATION(operation_name) in some method implementation.
40 * This macro will call constructor of this operation (it must inherit
41 * ImageComposer_Operator) and factory will set up arguments and call this
45 class HYDROData_OperationsFactory
49 //! Returns the global factory
50 HYDRODATA_EXPORT static HYDROData_OperationsFactory* Factory();
53 * Registers the operator by the name, used by REGISTER_HYDRO_OPERATION macro
54 * \param theOperator new instance of the operator that will be used for
55 * processing of operation with such kind
57 HYDRODATA_EXPORT static void Register(
58 ImageComposer_Operator* theOperator);
61 * Creates a new Image object in the data structure by the operator data.
62 * \param theDoc document where it must be created
63 * \param theOperator base operator for this Image: will be used in "Update" to recompute the image
64 * \returns created object related to the data structure
66 HYDRODATA_EXPORT Handle(HYDROData_Image) CreateImage(
67 Handle_HYDROData_Document theDoc, const ImageComposer_Operator* theOperator);
70 * Returns the operator, initialized by the properties of theImage
71 * \param theImage data structures object, that contains all arguments
72 * required for creation of operation
73 * \returns NULL if operator type is unknown
75 HYDRODATA_EXPORT ImageComposer_Operator* Operator(
76 Handle(HYDROData_Image) theImage) const;
80 * Returns the appropriate operator by the name
81 * \param theName name of the operator, equals to the operation_name constructor
82 * \returns NULL if operator with such name is not registered yet
84 HYDRODATA_EXPORT ImageComposer_Operator* Operator(const QString theName) const;
88 //! Not public constructor that creates only one, global instance of this factory.
89 HYDROData_OperationsFactory();
92 //! Map that stores all operators, isentified by strings
93 typedef QMap<QString, ImageComposer_Operator*> FactoryOperators;
95 FactoryOperators myOps; ///< all operators stored by a factory
99 * Macro that is used for registered operators, see C++ of this class to see
100 * example of hte registration.
102 #define REGISTER_HYDRO_OPERATION(operation_name) \
103 HYDROData_OperationsFactory::Factory()->Register(new operation_name);