Back to index

texmacs  1.0.7.15
Functions
connect.hpp File Reference
#include "tm_link.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool connection_declared (string name)
tree connection_info (string name, string session)
tree connection_handlers (string name)
string connection_start (string name, string session, bool again=false)
void connection_write (string name, string session, string s)
void connection_write (string name, string session, tree t)
tree connection_read (string name, string session, string channel="output")
void connection_interrupt (string name, string session)
void connection_stop (string name, string session)
void connection_stop_all ()
int connection_status (string name, string session)
tree connection_eval (string name, string session, string s)
tree connection_eval (string name, string session, tree t)
tree connection_cmd (string name, string session, string s)

Function Documentation

tree connection_cmd ( string  name,
string  session,
string  s 
)

Definition at line 368 of file connection.cpp.

                                                         {
  // cout << "Command " << name << ", " << session << ", " << cmd << LF;
  string s= as_string (call ("format-command", name, cmd));
  tree r= connection_eval (name, session, s);
  if (is_func (r, DOCUMENT, 1)) r= r[0];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool connection_declared ( string  name)

Definition at line 205 of file connection.cpp.

                                  {
  return as_bool (call ("connection-defined?", name));
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree connection_eval ( string  name,
string  session,
string  s 
)

Definition at line 359 of file connection.cpp.

                                                        {
  // cout << "Evaluating " << name << ", " << session << ", " << s << LF;
  connection con= connection_get (name, session);
  if (is_nil (con)) return "";
  connection_write (name, session, s);
  return connection_retrieve (name, session);
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree connection_eval ( string  name,
string  session,
tree  t 
)

Definition at line 350 of file connection.cpp.

                                                      {
  // cout << "Evaluating " << name << ", " << session << ", " << t << LF;
  connection con= connection_get (name, session);
  if (is_nil (con)) return "";
  connection_write (name, session, t);
  return connection_retrieve (name, session);
}

Here is the call graph for this function:

Definition at line 215 of file connection.cpp.

                                  {
  static hashmap<string,tree> handlers (tuple ());
  if (!handlers->contains (name))
    handlers (name)= stree_to_tree (call ("connection-get-handlers", name));
  return handlers[name];
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree connection_info ( string  name,
string  session 
)

Definition at line 210 of file connection.cpp.

                                              {
  return stree_to_tree (call ("connection-info", name, session));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void connection_interrupt ( string  name,
string  session 
)

Definition at line 286 of file connection.cpp.

                                                   {
  // cout << "Interrupt " << name << ", " << session << "\n";
  connection con= connection (name * "-" * session);
  if (is_nil (con)) return;
  con->interrupt ();
  con->listen ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree connection_read ( string  name,
string  session,
string  channel = "output" 
)

Definition at line 271 of file connection.cpp.

                                                              {
  // cout << "Read " << name << ", " << session << ", " << channel << "\n";
  connection con= connection (name * "-" * session);
  if (is_nil (con)) return "";
  con->read (LINK_ERR);
  tree t= con->tm_err->get (channel);
  if (t == "") {
    con->read (LINK_OUT);
    t= con->tm_in->get (channel);
  }
  // cout << "Result " << t << "\n";
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string connection_start ( string  name,
string  session,
bool  again = false 
)

Definition at line 227 of file connection.cpp.

                                                           {
  // cout << "Start " << name << ", " << session << "\n";
  if (!connection_declared (name))
    return "Error: connection " * name * " has not been declared";

  connection con= connection (name * "-" * session);
  if (is_nil (con)) {
    if (DEBUG_VERBOSE)
      cout << "TeXmacs] Starting session '" << session << "'\n";
    tree t= connection_info (name, session);
    if (is_tuple (t, "pipe", 1)) {
      tm_link ln= make_pipe_link (t[1]->label);
      con= tm_new<connection_rep> (name, session, ln);
    }
    else if (is_tuple (t, "socket", 2)) {
      tm_link ln= make_socket_link (t[1]->label, as_int (t[2]->label));
      con= tm_new<connection_rep> (name, session, ln);
    }
    else if (is_tuple (t, "dynlink", 3)) {
      tm_link ln=
       make_dynamic_link (t[1]->label, t[2]->label, t[3]->label, session);
      con= tm_new<connection_rep> (name, session, ln);
    }
  }

  return con->start (again);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int connection_status ( string  name,
string  session 
)

Definition at line 304 of file connection.cpp.

                                                {
  // cout << "Status " << name << ", " << session << " -> ";
  connection con= connection (name * "-" * session);
  if ((!is_nil (con)) && (con->status == CONNECTION_DYING))
    return WAITING_FOR_OUTPUT;
  if (is_nil (con) || (!con->ln->alive)) return CONNECTION_DEAD;
  // cout << con->ln->status << "\n";
  return con->status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void connection_stop ( string  name,
string  session 
)

Definition at line 295 of file connection.cpp.

                                              {
  // cout << "Stop " << name << ", " << session << "\n";
  connection con= connection (name * "-" * session);
  if (is_nil (con)) return;
  con->stop ();
  con->listen ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void connection_write ( string  name,
string  session,
string  s 
)

Definition at line 256 of file connection.cpp.

                                                         {
  // cout << "Write " << name << ", " << session << ", " << s << "\n";
  connection con= connection (name * "-" * session);
  if (is_nil (con)) return;
  con->write (s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void connection_write ( string  name,
string  session,
tree  t 
)

Definition at line 264 of file connection.cpp.

                                                       {
  // cout << "Write " << name << ", " << session << ", " << t << "\n";
  string s= as_string (call ("plugin-serialize", name, tree_to_stree (t)));
  connection_write (name, session, s);
}

Here is the call graph for this function: