3 # Copyright (C) 2008-2024 EDF R&D
5 # This file is part of SALOME ADAO module
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 __author__="André Ribes - EDF R&D"
26 class DevelException(Exception):
27 def __init__(self, message):
28 """Canonical constructor"""
29 Exception.__init__(self,message)
32 # ==============================================================================
33 # Interface of an eficas observer (for implementing the subject/observer pattern)
34 # ==============================================================================
36 from .enumerate import Enumerate
40 This class specifies the interface of an eficas observer. See example at the
43 def processEficasEvent(self, eficasWrapper, eficasEvent):
45 This function should be implemented in the concrete Observer.
46 @param eficasWrapper the instance of the source EficasWrapper
47 @param eficasEvent the emitted event (instance of EficasEvent)
49 raise DevelException("processEficasEvent not implemented yet")
52 EVENT_TYPES=Enumerate([
62 def __init__(self,eventType,callbackId=None):
64 Creates an eficas event to be used by an EficasWrapper to notify an
67 The eventType depends of the context of creation. It specify the nature
68 of the event inside EficasWrapper that triggers the creation of this instance.
70 The callbackId is an object used by the EficasObserver to map the
71 notification (this received event) with the initial event (callback)
72 This object can be anything and has to be defined through a convention
73 that both the EficasWrapper and the EficasObserver can understand.
74 Typically, the eficas observer set the callback id to the eficas wrapper
75 before running the asynchronous show. Then, when an event is raised by
76 the eficas wrapper toward its observer, it embeds the callback id so that
77 the observer can match the received event to the initial trigger context.
79 @param the eventType to be choosen in the EVENT_TYPES
80 @param callbackId an arbitrary data object
82 if not self.EVENT_TYPES.isValid(eventType):
83 raise DevelException("The event type "+str(eventType)+" is not defined")
85 self.eventType = eventType
86 self.callbackId = callbackId