# 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
        #)

    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())

#########################
class Doc_Const(DocBase):
    def __call__(self,obj,out,system,parent_name):
        prefix = (parent_name+"_") if _XXX else ""
        node_name = prefix + "CONST_" + ID(obj)
        self.make_node(out,node_name,{"label":"%g" % obj.value})
        return node_name

register_handler(fuzzy.operator.Const.Const,Doc_Const())


#########################
class Doc_Input(DocBase):
    def __call__(self,obj,out,system,parent_name):
        #out.write("{rank=min;\n")
        input_name = print_dot(obj.adjective,out,system,parent_name)
        #out.write("}\n")
        return input_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

        #)

    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())

#########################
class Doc_Const(DocBase):
    def __call__(self,obj,out,system,parent_name):
        prefix = (parent_name+"_") if _XXX else ""
        node_name = prefix + "CONST_" + ID(obj)
        self.make_node(out,node_name,{"label":"%g" % obj.value})
        return node_name

register_handler(fuzzy.operator.Const.Const,Doc_Const())


#########################
class Doc_Input(DocBase):
    def __call__(self,obj,out,system,parent_name):
        #out.write("{rank=min;\n")
        input_name = print_dot(obj.adjective,out,system,parent_name)
        #out.write("}\n")
        return input_name


register_handler(fuzzy.operator.Input.Input,Doc_Input())