1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2008-2015 EDF R&D
4 # This file is part of SALOME ADAO module
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.
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 __author__="André Ribes - EDF R&D"
25 class DevelException(Exception):
26 def __init__(self, message):
27 """Canonical constructor"""
28 Exception.__init__(self,message)
31 # ==============================================================================
32 # Interface of an eficas observer (for implementing the subject/observer pattern)
33 # ==============================================================================
35 from enumerate import Enumerate
39 This class specifies the interface of an eficas observer. See example at the
42 def processEficasEvent(self, eficasWrapper, eficasEvent):
44 This function should be implemented in the concrete Observer.
45 @param eficasWrapper the instance of the source EficasWrapper
46 @param eficasEvent the emitted event (instance of EficasEvent)
48 raise DevelException("processEficasEvent not implemented yet")
51 EVENT_TYPES=Enumerate([
61 def __init__(self,eventType,callbackId=None):
63 Creates an eficas event to be used by an EficasWrapper to notify an
66 The eventType depends of the context of creation. It specify the nature
67 of the event inside EficasWrapper that triggers the creation of this instance.
69 The callbackId is an object used by the EficasObserver to map the
70 notification (this received event) with the initial event (callback)
71 This object can be anything and has to be defined through a convention
72 that both the EficasWrapper and the EficasObserver can understand.
73 Typically, the eficas observer set the callback id to the eficas wrapper
74 before running the asynchronous show. Then, when an event is raised by
75 the eficas wrapper toward its observer, it embeds the callback id so that
76 the observer can match the received event to the initial trigger context.
78 @param the eventType to be choosen in the EVENT_TYPES
79 @param callbackId an arbitrary data object
81 if not self.EVENT_TYPES.isValid(eventType):
82 raise DevelException("The event type "+str(eventType)+" is not defined")
84 self.eventType = eventType
85 self.callbackId = callbackId