Salome HOME
d6dfc99636c86803dc9d0fa0613d05bb9ee106e9
[modules/gui.git] / src / TreeData / DataProcessor.hxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Author: Guillaume Boulant (EDF/R&D)
21
22 #ifndef _DATAPROCESSOR_H_
23 #define _DATAPROCESSOR_H_
24
25 #include "TreeData.hxx"
26
27 #include "DataModel.hxx"
28 #include "DataObject.hxx"
29 #include <QStringList>
30 #include <QString>
31
32 #include <vector>
33 typedef std::vector<DataObject *> DataObjectVector;
34
35 //
36 // =================================================================
37 // This class can be used to automize processing on data objects.
38 // The inputs of public functions are list of selected items in the
39 // tree view. The function automize the extraction of associated
40 // DataObject and can automize the processing of these object if the
41 // virtual function processDataObject is implemented.
42 // =================================================================
43 //
44
45 class TREEDATA_EXPORT DataProcessor {
46
47 public:
48   DataProcessor(DataModel * dataModel);
49
50   DataObjectVector * extract(QStringList itemNameIdList);
51   void               process(QStringList itemNameIdList);
52
53   
54 protected:
55   virtual void preprocess(QStringList /*itemNameIdList*/) {
56       // Implement something to be executed at the begining of the process function
57   };
58   virtual void postprocess(QStringList /*itemNameIdList*/) {
59       // Implement something to be executed at the end of the process function
60   };
61   // Implement what must be done with each DataObject during the process function
62   virtual void processDataObject(DataObject * dataObject) = 0;
63
64 private:
65   DataModel * _dataModel;
66 };
67
68 #endif