diff options
author | Josh Blum | 2009-09-05 00:45:14 -0700 |
---|---|---|
committer | Josh Blum | 2009-09-05 00:45:14 -0700 |
commit | 58cebfd63726dc2082ab31681afcd78e25c36132 (patch) | |
tree | 680777d7ea8117e420c599177d76394e0efa00c3 /grc/base/Block.py | |
parent | d80add605536891da950126b25b16ab89d8e7cae (diff) | |
download | gnuradio-58cebfd63726dc2082ab31681afcd78e25c36132.tar.gz gnuradio-58cebfd63726dc2082ab31681afcd78e25c36132.tar.bz2 gnuradio-58cebfd63726dc2082ab31681afcd78e25c36132.zip |
Implement a recursive validation api in the base Element class.
The rewrite and validate methods will invoke themselves on the child elements.
The error messages are now a super-list of element and child error messages.
As a side-effect, this cleans up code in base Block and Flowgraph class.
Diffstat (limited to 'grc/base/Block.py')
-rw-r--r-- | grc/base/Block.py | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/grc/base/Block.py b/grc/base/Block.py index fc501205f..cb21c3958 100644 --- a/grc/base/Block.py +++ b/grc/base/Block.py @@ -132,28 +132,6 @@ class Block(Element): """ self.get_param('_enabled').set_value(str(enabled)) - def rewrite(self): - """ - Rewrite critical structures. - Call rewrite on all sub elements. - """ - Element.rewrite(self) - for elem in self.get_ports() + self.get_params(): elem.rewrite() - - def validate(self): - """ - Validate the block. - All ports and params must be valid. - All checks must evaluate to true. - Validate the params, ports, and the connections to this block. - """ - Element.validate(self) - for c in self.get_params() + self.get_ports() + self.get_connections(): - c.validate() - if not c.is_valid(): - for msg in c.get_error_messages(): - self.add_error_message('>>> %s:\n\t%s'%(c, msg)) - def __str__(self): return 'Block - %s - %s(%s)'%(self.get_id(), self.get_name(), self.get_key()) def get_id(self): return self.get_param('id').get_value() @@ -163,6 +141,7 @@ class Block(Element): def get_category(self): return self._category def get_doc(self): return '' def get_ports(self): return self.get_sources() + self.get_sinks() + def get_children(self): return self.get_ports() + self.get_params() def get_block_wrapper_path(self): return self._block_wrapper_path ############################################## |