From 2dafc1ae4c63f1d0d6b4926dfd28b8d74b0a4b1f Mon Sep 17 00:00:00 2001 From: Karamaz0V1 Date: Tue, 3 Apr 2018 19:28:17 +0200 Subject: [PATCH] Node structure --- ld2dap/Filter.py | 20 ++++++++++++++++++++ ld2dap/Input.py | 22 ++++++++++++++++++++++ ld2dap/Node.py | 23 +++++++++++++++++++++++ ld2dap/Output.py | 30 ++++++++++++++++++++++++++++++ ld2dap/test.py | 25 +++++++++++++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 ld2dap/Filter.py create mode 100644 ld2dap/Input.py create mode 100644 ld2dap/Node.py create mode 100644 ld2dap/Output.py create mode 100644 ld2dap/test.py diff --git a/ld2dap/Filter.py b/ld2dap/Filter.py new file mode 100644 index 0000000..01cb13e --- /dev/null +++ b/ld2dap/Filter.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# \file Filter.py +# \brief TODO +# \author Florent Guiotte +# \version 0.1 +# \date 03 avril 2018 +# +# TODO details + +from Input import Input +from Output import Output + +class Filter(Input, Output): + def __init__(self): + super().__init__('Filter') + + def _run(self): + print('ima not virtual!') + diff --git a/ld2dap/Input.py b/ld2dap/Input.py new file mode 100644 index 0000000..e3cf792 --- /dev/null +++ b/ld2dap/Input.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# \file Input.py +# \brief TODO +# \author Florent Guiotte +# \version 0.1 +# \date 03 avril 2018 +# +# TODO details + +from Node import Node + +class Input(Node): + def __init__(self, name='__CHILD__'): + super().__init__('Input:{}'.format(name)) + self.outputs = list() + + def register(self, output): + self.outputs.append(output) + + def run(self): + print('IMA INPUT N I RUNIN') diff --git a/ld2dap/Node.py b/ld2dap/Node.py new file mode 100644 index 0000000..4ccad9f --- /dev/null +++ b/ld2dap/Node.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# \file Node.py +# \brief TODO +# \author Florent Guiotte +# \version 0.1 +# \date 03 avril 2018 +# +# TODO details + + +class Node: + def __init__(self, name='A NODE HAS NO NAME'): + self.name = name + + def __str__(self): + return ("Node:{}".format(self.name)) + + def _run(self): + raise NotImplementedError('This method is virtual') + + def run(self): + return self._run() diff --git a/ld2dap/Output.py b/ld2dap/Output.py new file mode 100644 index 0000000..007e695 --- /dev/null +++ b/ld2dap/Output.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# \file Output.py +# \brief TODO +# \author Florent Guiotte +# \version 0.1 +# \date 03 avril 2018 +# +# TODO details + +from Node import Node +from Input import Input + +class Output(Node): + def __init__(self, name='__CHILD__'): + super().__init__('Output:{}'.format(name)) + self.__dict__['input'] = None + + def __setattr__(self, name, value): + if name == 'input': + self._input(value) + else: + self.__dict__[name] = value + + def _input(self, inode): + if not isinstance(inode, (Input)): + raise NotImplementedError('{} is not an Input'.format(inode)) + self.__dict__['input'] = inode + + diff --git a/ld2dap/test.py b/ld2dap/test.py new file mode 100644 index 0000000..ba2bb55 --- /dev/null +++ b/ld2dap/test.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# \file test.py +# \brief TODO +# \author Florent Guiotte +# \version 0.1 +# \date 03 avril 2018 +# +# TODO details + +from Node import Node +from Filter import Filter +from Input import Input + +def main(): + n = Filter() + f = Filter() + print(n) + n.run() + print(n.input) + n.input = f + print(n.input) + +if __name__ == '__main__': + main()