Salome HOME
can create datasource from tui
[modules/med.git] / src / MEDOP / gui / MEDEventListener_i.cxx
1 // Copyright (C) 2011-2015  CEA/DEN, EDF R&D
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 // Authors : Guillaume Boulant (EDF) - 01/06/2011
21
22 #include "MEDEventListener_i.hxx"
23 #include <Basics_Utils.hxx>
24
25 MEDEventListener_i * MEDEventListener_i::_instance = NULL;
26 MEDEventListener_i * MEDEventListener_i::getInstance() {
27   // _GBO_ we will certainly need to define one EventListener per
28   // DataManager or SALOME study and not one singleton for the whole
29   // session
30   if ( _instance == NULL ) {
31     _instance = new MEDEventListener_i();
32   }
33   return _instance;
34 }
35
36 void MEDEventListener_i::release() {
37   delete _instance;
38 }
39
40 MEDEventListener_i::MEDEventListener_i()
41 {
42   LOG("Creating a MEDEventListener_i instance");
43 }
44 MEDEventListener_i::~MEDEventListener_i()
45 {
46   LOG("Deleting MEDEventListener_i instance");
47 }
48
49 void MEDEventListener_i::processMedEvent(const MEDOP::MedEvent & event) {
50   LOG("Start processing event for field id="<<event.fieldid);
51
52   // This function must be executed as fast as possible because the
53   // CORBA request is a synchronous call. Then we just emit a Qt
54   // signal and exit. The Qt signal should be received by the
55   // WorkspaceController (connect to a slot of WorkspaceController).
56
57   emit medEventSignal(new MEDOP::MedEvent(event));
58 }