# Path: sydpy/_component.py
# class Component(object, metaclass=GlobconfComponentMeta):
#     """Component class is the base class for all objects that are part of the user 
#     object hierarchy.    
#     """
#     
#     def __init__(self, name, parent):
#         """Instantiate a new component
#         
#         name    -- The name of the new component
#         parent  -- The reference to the parent component
#         """
#         self.parent = parent
#         self.name = name
#         
#         self.components = {}
#         
#         if parent is not None:
#             parent.add(self)
#             
#     def __repr__(self):
#         return self.qualified_name
#     
#     def inst(self, cls, name=None, **config):
#         """Create a new subcomponent.
#         
#         cls     -- A class object, or a string representing a path to the class
#                     path.to.the.class.ClassName
#         name    -- Name of the subcomponent 
#         
#         Reference to this Component object is automatically passes.
#         """
#         if isinstance(cls, str):
#             if name is None:
#                 name = cls
#                 
#             comp = factory(cls)(name, self, **config)
#         else:
#             if name is None:
#                 name = cls.__name__
#                 
#             comp = cls(name, self, **config)
# 
#         return comp
#             
#     def add(self, comp):
#         """Add a new subcomponent to the component dictionary."""
#         self.components[comp.name] = comp
#     
#     def find(self, qualified_name):
#         """Retreive the component from the hierarchy by its qualified name
#         
#         Required arguments:
#             qualified_name    - The qualified name of component to find
#             
#         Return values:
#             (comp, path)      - Either the found component and empty string, or
#                                 the component furthest down the path and the
#                                 remaining of the path that could not be traced
#         """
#         if qualified_name[0] == '/':
#             if self.parent is not None:
#                 return self.parent.find(qualified_name)
#             else:
#                 return self.find(qualified_name[1:])
#         elif qualified_name[0:3] == '../':
#             return self.parent.find(qualified_name[3:])
#         elif qualified_name[0:2] == './':
#             return self.find(qualified_name[2:])
#         else:
#             slash_pos = qualified_name.find('/')
# 
#             if slash_pos == -1:
#                 if qualified_name not in self.components:
#                     return (self, qualified_name)                
#                 else:
#                     return (self.components[qualified_name], '')
#             else:
#                 comp_name = qualified_name[:slash_pos-1]
#                 rest_path = qualified_name[slash_pos+1:]
# 
#                 if comp_name not in self.components:
#                     return (self, qualified_name)                
#                 else:
#                     return self.components[comp_name].find(rest_path)
# 
#     def __getattr__(self, name):
#         if name in self.components:
#             return self.components[name]
#         else:
#             raise AttributeError
#         
#     def __getitem__(self, key):
#         return self.components[key]
# 
# Path: sydpy/intfs/_intf.py
# class IntfDir(Enum):
#     master = 1
#     slave = 2
# 
#     
#     def reverse(self):
#         if self.value == IntfDir.master.value:
#             return IntfDir.slave
#         else:
#             return IntfDir.master


from sydpy._component import Component
from sydpy.intfs._intf import IntfDir
#  This file is part of sydpy.
# 
#  Copyright (C) 2014-2015 Bogdan Vukobratovic
#
#  sydpy is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU Lesser General Public License as 
#  published by the Free Software Foundation, either version 2.1 
#  of the License, or (at your option) any later version.
# 
#  sydpy is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
# 
#  You should have received a copy of the GNU Lesser General 
#  Public License along with sydpy.  If not, see 
#  <http://www.gnu.org/licenses/>.

"""Module that implements the Channel class."""


class Channel(Component):
    """Instances of this class allow the information they carry to be read
    and written in various interfaces (by various protocols)"""
    
    def __init__(self, name, parent, trace = True):
        self.slaves = []
        self.master = None
        self.traces = []
        self._tracing = trace

# Path: sydpy/_component.py
# class Component(object, metaclass=GlobconfComponentMeta):
#     """Component class is the base class for all objects that are part of the user 
#     object hierarchy.    
#     """
#     
#     def __init__(self, name, parent):
#         """Instantiate a new component
#         
#         name    -- The name of the new component
#         parent  -- The reference to the parent component
#         """
#         self.parent = parent
#         self.name = name
#         
#         self.components = {}
#         
#         if parent is not None:
#             parent.add(self)
#             
#     def __repr__(self):
#         return self.qualified_name
#     
#     def inst(self, cls, name=None, **config):
#         """Create a new subcomponent.
#         
#         cls     -- A class object, or a string representing a path to the class
#                     path.to.the.class.ClassName
#         name    -- Name of the subcomponent 
#         
#         Reference to this Component object is automatically passes.
#         """
#         if isinstance(cls, str):
#             if name is None:
#                 name = cls
#                 
#             comp = factory(cls)(name, self, **config)
#         else:
#             if name is None:
#                 name = cls.__name__
#                 
#             comp = cls(name, self, **config)
# 
#         return comp
#             
#     def add(self, comp):
#         """Add a new subcomponent to the component dictionary."""
#         self.components[comp.name] = comp
#     
#     def find(self, qualified_name):
#         """Retreive the component from the hierarchy by its qualified name
#         
#         Required arguments:
#             qualified_name    - The qualified name of component to find
#             
#         Return values:
#             (comp, path)      - Either the found component and empty string, or
#                                 the component furthest down the path and the
#                                 remaining of the path that could not be traced
#         """
#         if qualified_name[0] == '/':
#             if self.parent is not None:
#                 return self.parent.find(qualified_name)
#             else:
#                 return self.find(qualified_name[1:])
#         elif qualified_name[0:3] == '../':
#             return self.parent.find(qualified_name[3:])
#         elif qualified_name[0:2] == './':
#             return self.find(qualified_name[2:])
#         else:
#             slash_pos = qualified_name.find('/')
# 
#             if slash_pos == -1:
#                 if qualified_name not in self.components:
#                     return (self, qualified_name)                
#                 else:
#                     return (self.components[qualified_name], '')
#             else:
#                 comp_name = qualified_name[:slash_pos-1]
#                 rest_path = qualified_name[slash_pos+1:]
# 
#                 if comp_name not in self.components:
#                     return (self, qualified_name)                
#                 else:
#                     return self.components[comp_name].find(rest_path)
# 
#     def __getattr__(self, name):
#         if name in self.components:
#             return self.components[name]
#         else:
#             raise AttributeError
#         
#     def __getitem__(self, key):
#         return self.components[key]
# 
# Path: sydpy/intfs/_intf.py
# class IntfDir(Enum):
#     master = 1
#     slave = 2
# 
#     
#     def reverse(self):
#         if self.value == IntfDir.master.value:
#             return IntfDir.slave
#         else:
#             return IntfDir.master


# Path: sydpy/_channel.py
from sydpy._component import Component
from sydpy.intfs._intf import IntfDir

#  This file is part of sydpy.
# 
#  Copyright (C) 2014-2015 Bogdan Vukobratovic
#
#  sydpy is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU Lesser General Public License as 
#  published by the Free Software Foundation, either version 2.1 
#  of the License, or (at your option) any later version.
# 
#  sydpy is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
# 
#  You should have received a copy of the GNU Lesser General 
#  Public License along with sydpy.  If not, see 
#  <http://www.gnu.org/licenses/>.

"""Module that implements the Channel class."""


class Channel(Component):
    """Instances of this class allow the information they carry to be read
    and written in various interfaces (by various protocols)"""
    
    def __init__(self, name, parent, trace = True):
        self.slaves = []
        self.master = None
        self.traces = []
        self._tracing = trace

        Component.__init__(self, name, parent)