| 1 |
UML Model |
|---|
| 2 |
~~~~~~~~~ |
|---|
| 3 |
|
|---|
| 4 |
The UML model that should hold all information. It would be nice if the model |
|---|
| 5 |
looks like the UML MetaModel. In order to keep the model consistent a lot of |
|---|
| 6 |
bi-directional relations have to be made. Those relations have a multiplicity |
|---|
| 7 |
of '0..1', '1', '1..*' or '*'. For simplicity we reduce this to '1' and '*'. |
|---|
| 8 |
|
|---|
| 9 |
For the objects that have a multiplicity of 1 we can simply assign a |
|---|
| 10 |
value to the attribute. If a new value is assigned to the value we can simply |
|---|
| 11 |
replace it. |
|---|
| 12 |
|
|---|
| 13 |
We also need some sort of Sequence object (a 'list-deluxe') that will allow us |
|---|
| 14 |
to add and remove elements from the list. We can use the List object for that, |
|---|
| 15 |
but we should check the object that is added to the list for its type. |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
Signals |
|---|
| 19 |
~~~~~~~ |
|---|
| 20 |
UML elements should emit signals if their state changes. This can be done |
|---|
| 21 |
by means of the misc.signal.Signal class. All what's left is to define a |
|---|
| 22 |
protocol (the arguments that the UML element supplies). |
|---|
| 23 |
|
|---|
| 24 |
The following cases can occur: |
|---|
| 25 |
1. Unidirectional relationships or attributes: |
|---|
| 26 |
a. Set data |
|---|
| 27 |
b. Set data and overwrite old data |
|---|
| 28 |
c. Remove the attribute |
|---|
| 29 |
2. Bidirectional relationships |
|---|
| 30 |
a. multiplicity of '1' |
|---|
| 31 |
b. multiplicity of '*' |
|---|
| 32 |
|
|---|
| 33 |
For non-sequence attributes we can do something like this |
|---|
| 34 |
|
|---|
| 35 |
def signal_handler(attribute_name, old_value, new_value, *custom_args): |
|---|
| 36 |
pass |
|---|
| 37 |
|
|---|
| 38 |
where old_value and new_value is None (or the default value) in case no value |
|---|
| 39 |
was set before. |
|---|
| 40 |
|
|---|
| 41 |
For sequences we can only add and remove values. We can do this with the |
|---|
| 42 |
same amount of attributes, only old_value will be one of 'add' or 'remove' and |
|---|
| 43 |
new_value will contain the value that is added or removed. |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|