mirror of https://gitlab.com/pamhyr/pamhyr2
38 lines
884 B
Python
38 lines
884 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from copy import copy
|
|
from tools import trace, timer
|
|
|
|
from Model.InitialConditions.InitialConditions import InitialConditions
|
|
|
|
class InitialConditionsDict(object):
|
|
def __init__(self, status = None):
|
|
super(InitialConditionsDict, self).__init__()
|
|
|
|
self._status = status
|
|
|
|
self._reach = {}
|
|
|
|
def __len__(self):
|
|
return len(self._reach)
|
|
|
|
def is_defined(self, reach):
|
|
return reach in self._reach
|
|
|
|
def get(self, reach):
|
|
if reach in self._reach:
|
|
return self._reach[reach]
|
|
|
|
new = self.new(reach)
|
|
self.set(reach, new)
|
|
return new
|
|
|
|
def set(self, reach, new):
|
|
self._reach[reach] = new
|
|
self._status.modified()
|
|
|
|
def new(self, reach):
|
|
new = InitialConditions(reach = reach, status = self._status)
|
|
self.set(reach, new)
|
|
return new
|