# Path: fuzzy/doc/structure/dot/dot.py
# def register_handler(class_, handler):
#     _registered_handler[class_] = handler
# 
# def print_dot(obj,out,system,parentname):
#     """Print object obj into output stream out"""
#     for class_ in type(obj).mro():
#         if class_ in _registered_handler.keys():
#             handler = _registered_handler[class_]
#             return handler(obj,out,system,parentname)
#     return ""


from fuzzy.doc.structure.dot.dot import register_handler,print_dot
import fuzzy.operator.Compound
import fuzzy.operator.Const
import fuzzy.operator.Input
import fuzzy.operator.Not
import fuzzy.norm.Norm
import fuzzy.norm.ParametricNorm
import fuzzy.Adjective
import fuzzy.AdjectiveProxy
import fuzzy.Rule
import fuzzy.OutputVariable
import fuzzy.Variable
            opt = " [" + opt + "]"
        out.write("%s%s;\n" % (name,opt))

    def make_connection(self,out,node1,node2,values={}):
        opt = ""
        for option,value in self.connection_style.items():
            if value == None:
                continue
            if opt != "":
                opt += ","
            opt += '%s="%s"' % ( option , (value % values) )
        if opt != "":
            opt = " [" + opt + "]"
        out.write("%s -> %s%s;\n" % (node1,node2,opt))

#########################
class Doc_Compound(DocBase):
    def __init__(self):
        super(Doc_Compound,self).__init__()
        #self.node_style.update(
        #    { "comment":"XXX" }
        #)

    def __call__(self,obj,out,system,parent_name):
        norm_name = print_dot(obj.norm,out,system,parent_name)
        for i in obj.inputs:
            inp_node_name = print_dot(i,out,system,norm_name)
            self.make_connection(out,inp_node_name,norm_name)
        return norm_name


# Path: fuzzy/doc/structure/dot/dot.py
# def register_handler(class_, handler):
#     _registered_handler[class_] = handler
# 
# def print_dot(obj,out,system,parentname):
#     """Print object obj into output stream out"""
#     for class_ in type(obj).mro():
#         if class_ in _registered_handler.keys():
#             handler = _registered_handler[class_]
#             return handler(obj,out,system,parentname)
#     return ""


# Path: fuzzy/doc/structure/dot/handlers.py
from fuzzy.doc.structure.dot.dot import register_handler,print_dot
import fuzzy.operator.Compound
import fuzzy.operator.Const
import fuzzy.operator.Input
import fuzzy.operator.Not
import fuzzy.norm.Norm
import fuzzy.norm.ParametricNorm
import fuzzy.Adjective
import fuzzy.AdjectiveProxy
import fuzzy.Rule
import fuzzy.OutputVariable
import fuzzy.Variable

            opt = " [" + opt + "]"
        out.write("%s%s;\n" % (name,opt))

    def make_connection(self,out,node1,node2,values={}):
        opt = ""
        for option,value in self.connection_style.items():
            if value == None:
                continue
            if opt != "":
                opt += ","
            opt += '%s="%s"' % ( option , (value % values) )
        if opt != "":
            opt = " [" + opt + "]"
        out.write("%s -> %s%s;\n" % (node1,node2,opt))

#########################
class Doc_Compound(DocBase):
    def __init__(self):
        super(Doc_Compound,self).__init__()
        #self.node_style.update(
        #    { "comment":"XXX" }
        #)

    def __call__(self,obj,out,system,parent_name):
        norm_name = print_dot(obj.norm,out,system,parent_name)
        for i in obj.inputs:
            inp_node_name = print_dot(i,out,system,norm_name)
            self.make_connection(out,inp_node_name,norm_name)
        return norm_name


register_handler(fuzzy.operator.Compound.Compound,Doc_Compound())