PreviousUpNext

15.4.784  src/lib/graph/readonly.pkg

#  This view make a graph readonly.
#  -- Allen Leung

# Compiled by:
#     src/lib/graph/graphs.lib

###               "Death is more universal than life;
###                everyone dies but not everyone lives."
###
###                                  -- A. Sachs



stipulate
    package odg =  oop_digraph;                                                 # oop_digraph   is from   src/lib/graph/oop-digraph.pkg
herein
    api Read_Only_Graph_View {
        #
        readonly_view:  odg::Digraph(N,E,G) -> odg::Digraph(N,E,G);             # Here N,E,G stand stead for the types of client-package-supplied records associated with (respectively) nodes, edges and graphs.
    };
end;


stipulate
    package odg =  oop_digraph;                                                 # oop_digraph           is from   src/lib/graph/oop-digraph.pkg
herein

    package   read_only_graph_view
    : (weak)  Read_Only_Graph_View                                              # Read_Only_Graph_View          is from   src/lib/graph/readonly.pkg
    {
        fun readonly_view (odg::DIGRAPH graph)
            =
            {   fun unimplemented _
                    =
                    raise exception  odg::READ_ONLY;

                odg::DIGRAPH
                  { name                => graph.name,
                    graph_info          => graph.graph_info,
                    allot_node_id       => unimplemented,                       # This is the opposite of typesafe -- can't we do better? 2011-06-10 CrT XXX SUCKO FIXME.
                    add_node            => unimplemented,
                    add_edge            => unimplemented,
                    remove_node         => unimplemented,
                    set_in_edges        => unimplemented,
                    set_out_edges       => unimplemented,
                    set_entries         => unimplemented,
                    set_exits           => unimplemented,
                    garbage_collect     => unimplemented,
                    nodes               => graph.nodes,
                    edges               => graph.edges,
                    order               => graph.order,
                    size                => graph.size,
                    capacity            => graph.capacity,
                    out_edges           => graph.out_edges,
                    in_edges            => graph.in_edges,
                    next                => graph.next,                          # Should next/prior be before/after? Or?
                    prior               => graph.prior,
                    has_edge            => graph.has_edge,
                    has_node            => graph.has_node,
                    node_info           => graph.node_info,
                    entries             => graph.entries,
                    exits               => graph.exits,
                    entry_edges         => graph.entry_edges,
                    exit_edges          => graph.exit_edges,
                    forall_nodes        => graph.forall_nodes,
                    forall_edges        => graph.forall_edges
#                   fold_nodes          => graph.fold_nodes,
#                   fold_edges          => graph.fold_edges
                  };
            };
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext