C++/Tcl/C++ Interface

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Soumen

    C++/Tcl/C++ Interface

    Hi,

    Not sure if this most appropriate group for this post. But I've seen
    couple of posts related to C++/Tcl in this group. And that makes me
    post this query in this group. Please redirect me to correct group
    if this is not the most appropriate one.

    I'm a newbie in Tcl and Tcl/C++ interfacing. I need to develop a
    prototype for one of our upcoming project.

    I've a shared library which provides Tcl procedures to traverse
    through some graph which is being created upon reading a file
    of specific format. If I load this shared library in Tcl shell and
    call those proc to read the specific file and traverse the graph.

    Graph traversal proc are like:
    * getting neighbor nodes of a given node
    * getting the node name and edge names to/from a node

    Let's name this Tcl library GL (graph lib).

    Now, in my C++ program I need create a duplicate graph since I don't
    have capability read that file directly. So from my C++ code, I need
    to
    create a Tcl channel, send commands through the Tcl channel for GL
    procs and get information from those GL procs to my C++ application
    to build a duplicate graph on my end.

    Could some one provide hints how to go about this? Any pointers to
    existing resource (doc/open source code) will be very helpful.

    Regards,
    ~ Soumen
  • Soumen

    #2
    Re: C++/Tcl/C++ Interface

    On Apr 10, 3:38 pm, Soumen <soume...@gmail .comwrote:
    Hi,
    >
    Not sure if this most appropriate group for this post. But I've seen
    couple of posts related to C++/Tcl in this group. And that makes me
    post this query in this group. Please redirect me to correct group
    if this is not the most appropriate one.
    >
    I'm a newbie in Tcl and Tcl/C++ interfacing. I need to develop a
    prototype for one of our upcoming project.
    >
    I've a shared library which provides Tcl procedures to traverse
    through some graph which is being created upon reading a file
    of specific format. If I load this shared library in Tcl shell and
    call those proc to read the specific file and traverse the graph.
    >
    Graph traversal proc are like:
    * getting neighbor nodes of a given node
    * getting the node name and edge names to/from a node
    >
    Let's name this Tcl library GL (graph lib).
    >
    Now, in my C++ program I need create a duplicate graph since I don't
    have capability read that file directly. So from my C++ code, I need
    to
    create a Tcl channel, send commands through the Tcl channel for GL
    procs and get information from those GL procs to my C++ application
    to build a duplicate graph on my end.
    >
    Could some one provide hints how to go about this? Any pointers to
    existing resource (doc/open source code) will be very helpful.
    >
    Regards,
    ~ Soumen
    Clarifying the requirement further:
    -----------------------------------

    Say there is a text file of specific format. And the shared library
    (GL) is say a standard reader of that specific format. Now, when I
    load this GL.so in tcl shell, and call procedure to read a file of
    the specific format, it internally builds a graph. I've some gl_*
    procedures to traverse that graph.

    Now, my objective is from C++ program, create a tcl channel and send
    commands to read that specific file, to iterate over the graph using
    gl_* procs. Get the required information (o/p of those gl_* tcl procs)
    in the C++ program to mimic the graph of Tcl env in C++ env.

    For example (this is not the exact case) following file is the
    specific format and it represents an adjacency list.

    a ->b ->c
    b ->c
    c -a ->d
    d -a -b

    Now, in the GL.so, I've following Tcl procs:

    gl_read_file ---reads the adjacency list file
    gl_get_nodes ---returns a list of node
    gl_get_node_nam e ---gives node name of Tcl node obj
    gl_get_neighbor _nodes ---gives a Tcl list of adjacent nodes of a
    specified node name (or Tcl node obj)
    gl_get_edge ---gives Tcl edge object connecting two node obj
    gl_get_edge_nam e ---gives the edge name of Tcl edge object
    gl_get_out_edge ---gives list of Tcl edge objects which are outgoing
    edge of specified node.

    Now, in my C++ program I need to create the same graph. But I don't
    have capability of reading this file format. So what I need to do
    create some tcl channel, call required gl_* Tcl proc to create
    the same graph using C++ objects so that later in C++ program
    I can only use the graph in C++ env to do further processing.

    Comment

    Working...