-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontroller.py
42 lines (33 loc) · 1.48 KB
/
controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
import mvc_observer
class Controller(mvc_observer.MVCObserver):
"""
The Controller class is the parent class of the specific controller observers which are part of the Model-View-Controller (MVC) Architecture and inherit from this class. This class inherits from the more general MVCObserver class and extend its functionalities. Controllers are implementing the interaction between the user and the application. Those observers can register with the model to receive notification events.
"""
_view = None
def __init__(self):
""" Constructor of Controller and default values will be initialised. """
# call constructor of parent class
mvc_observer.MVCObserver.__init__(self)
self._model = None
self._view = None
def __init__(self, model = None, view = None):
""" Constructor of Controller and values will be set. """
# call constructor of parent class
mvc_observer.MVCObserver.__init__(self)
self._model = model
self._view = view
# register view
if self._view != None and self._model != None:
self._model.add(self._view)
@property
def view(self):
""" Return view (MVCObserver-Object). """
return self._view
@view.setter
def view(self, v):
""" Set view (MVCObserver-Object). """
self._view = v
# register view
if self._view != None and self._model != None:
self._model.add(self._view)