Salome HOME
66543cf7d9912f6316aa81a2e2ecd186e8ccb5ab
[modules/smesh.git] / src / SMESH / SMESH_subMeshEventListener.hxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 // File      : SMESH_subMeshEventListener.hxx
25 // Created   : Mon Nov 13 10:45:49 2006
26 // Author    : Edward AGAPOV (eap)
27
28
29 #ifndef SMESH_subMeshEventListener_HeaderFile
30 #define SMESH_subMeshEventListener_HeaderFile
31
32 #include <list>
33
34 class  SMESH_subMesh;
35 class  SMESH_Hypothesis;
36 struct SMESH_subMeshEventListenerData;
37
38 // ------------------------------------------------------------------
39 /*!
40  * \brief A base for objects reacting on submesh events
41  */
42 // ------------------------------------------------------------------
43
44 class SMESH_subMeshEventListener {
45 public:
46   /*!
47    * \brief Do something on a certain event
48    * \param event - algo_event or compute_event itself (of SMESH_subMesh)
49    * \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh)
50    * \param subMesh - the submesh where the event occures
51    * \param data - listener data stored in the subMesh
52    * \param hyp - hypothesis, if eventType is algo_event
53    * 
54    * The base implementation translates CLEAN event to the subMesh stored
55    * in the listener data
56    */
57   virtual void ProcessEvent(const int          event,
58                             const int          eventType,
59                             SMESH_subMesh*     subMesh,
60                             SMESH_subMeshEventListenerData* data,
61                             SMESH_Hypothesis*  hyp = 0);
62 };
63
64 // ------------------------------------------------------------------
65 /*!
66  * \brief Data specific for EventListener and to be stored in a submesh
67  */
68 // ------------------------------------------------------------------
69
70 struct SMESH_subMeshEventListenerData
71 {
72   //!< to recognize data type
73   int myType;
74   //!< generally: submeshes depending on the one storing this data
75   std::list<SMESH_subMesh*> mySubMeshes;
76  //!< subMesh where data
77
78   /*!
79    * \brief Create a default listener data.
80    * \param dependentSM - subMesh to store
81    * \param type - data type
82    * \retval SMESH_subMeshEventListenerData* - a new listener data
83    *
84    * See SMESH_subMeshEventListener::ProcessEvent() to know how the default
85    * listener uses it
86    */
87   static SMESH_subMeshEventListenerData* MakeData(SMESH_subMesh* dependentSM,
88                                                   const int      type = 0)
89   {
90     SMESH_subMeshEventListenerData* data = new SMESH_subMeshEventListenerData;
91     data->mySubMeshes.push_back( dependentSM );
92     data->myType = type;
93     return data;
94   }
95 };
96
97
98 #endif