pipe_port_rep Class Reference

Inheritance diagram for pipe_port_rep:
posix_port_rep port_rep rep_struct

List of all members.

Public Member Functions

Public Attributes

Protected Attributes


Detailed Description

Definition at line 39 of file pipe_port.cpp.


Constructor & Destructor Documentation

pipe_port_rep ( nat  kind,
nat  fd,
nat  pid2,
const string cmd2,
const string role2 
) [inline]

Definition at line 50 of file pipe_port.cpp.

00051                                                                 :
00052     posix_port_rep (kind, fd),
00053     cmd (cmd2), role (role2), pid (pid2) {}
  inline ~pipe_port_rep () {

~pipe_port_rep (  )  [inline]

Definition at line 54 of file pipe_port.cpp.

References posix_port_rep::fd.

00054                            {
00055     close (this->fd); }


Member Function Documentation

port accept (  )  [virtual, inherited]

Reimplemented in socket_port_rep.

Definition at line 88 of file port.cpp.

References ERROR, port_rep::expression(), mmx::lf, and mmx::mmerr.

00088                   {
00089   mmerr << "port= " << expression () << lf;
00090   ERROR ("socket server port expected");
00091 }

virtual bool busy (  )  [inline, virtual, inherited]

Reimplemented from port_rep.

Reimplemented in file_port_rep.

Definition at line 41 of file posix_port.hpp.

References posix_port_rep::alive, posix_port_rep::buffer, posix_port_rep::feed(), mmx::N(), and posix_port_rep::pos.

00041 { feed (); return alive || pos < N(buffer); }

virtual nat can_read (  )  [inline, virtual, inherited]

Reimplemented from port_rep.

Reimplemented in file_port_rep.

Definition at line 43 of file posix_port.hpp.

References posix_port_rep::buffer, posix_port_rep::feed(), mmx::N(), and posix_port_rep::pos.

00043 { feed (); return N(buffer) - pos; }

virtual nat can_write (  )  [inline, virtual, inherited]

Reimplemented from port_rep.

Reimplemented in file_port_rep.

Definition at line 42 of file posix_port.hpp.

References posix_port_rep::alive.

00042 { return alive? (nat) (-1): 0; }

port component ( const string name  )  [virtual, inherited]

Reimplemented in composite_port_rep, and formatting_port_rep.

Definition at line 94 of file port.cpp.

References ERROR, port_rep::expression(), mmx::lf, and mmx::mmerr.

00094                                        {
00095   mmerr << "port= " << expression () << lf;
00096   ERROR ("composite port expected");
00097 }

bool error_flag (  )  [virtual, inherited]

Reimplemented in composite_port_rep, formatting_port_rep, and error_port_rep.

Definition at line 39 of file port.cpp.

00039                       {
00040   return false;
00041 }

string error_message (  )  [virtual, inherited]

Reimplemented in composite_port_rep, formatting_port_rep, and error_port_rep.

Definition at line 44 of file port.cpp.

00044                          {
00045   return "";
00046 }

syntactic expression (  )  const [inline, virtual]

Implements port_rep.

Definition at line 45 of file pipe_port.cpp.

References mmx::syn().

00045                                 {
00046     return syn ("pipe_port", syntactic (cmd), syntactic (role));
00047   }

void feed (  )  [virtual, inherited]

Reimplemented in socket_port_rep.

Definition at line 67 of file posix_port.cpp.

References posix_port_rep::alive, posix_port_rep::buffer, ERROR, posix_port_rep::fd, posix_port_rep::read(), and posix_port_rep::wait().

Referenced by posix_port_rep::busy(), posix_port_rep::can_read(), and posix_port_rep::read().

00067                       {
00068   while (alive && wait (0)) {
00069     int r;
00070     char tempout[1024];
00071     r = ::read (fd, tempout, 1024);
00072     if (r == -1) {
00073 #if defined(__MINGW__) || defined(__MINGW32__)
00074       _cwait (NULL, 0, _WAIT_CHILD);
00075 #else
00076       ::wait (NULL);
00077 #endif
00078       ERROR ("read failed");
00079     }
00080     else if (r == 0) alive= false;
00081     else buffer << string (tempout, r);
00082   }
00083 }

void flush (  )  [virtual, inherited]

Reimplemented in composite_port_rep, file_port_rep, and formatting_port_rep.

Definition at line 84 of file port.cpp.

00084                  {
00085 }

void format ( const print_format fm  )  [virtual, inherited]

Reimplemented in formatting_port_rep.

Definition at line 100 of file port.cpp.

References ERROR, port_rep::expression(), mmx::lf, and mmx::mmerr.

00100                                         {
00101   mmerr << "port= " << expression () << lf;
00102   ERROR ("formatting port expected");  
00103 }

virtual bool is_input_port (  )  [inline, virtual, inherited]

Reimplemented from port_rep.

Definition at line 40 of file posix_port.hpp.

References posix_port_rep::kind.

00040 { return (kind & 2) != 0; }

virtual bool is_output_port (  )  [inline, virtual, inherited]

Reimplemented from port_rep.

Definition at line 39 of file posix_port.hpp.

References posix_port_rep::kind.

00039 { return (kind & 1) != 0; }

virtual void read ( char *  s,
nat  n 
) [inline, virtual, inherited]

Reimplemented from port_rep.

Reimplemented in file_port_rep.

Definition at line 45 of file posix_port.hpp.

References posix_port_rep::buffer, posix_port_rep::feed(), mmx::inside(), mmx::mem_copy(), mmx::N(), and posix_port_rep::pos.

Referenced by posix_port_rep::feed().

00045                                             {
00046     while (pos + n > N(buffer)) feed ();
00047     mem_copy (s, inside (buffer, pos), n);
00048     pos += n; }

virtual void send ( const char *  s,
nat  n 
) [virtual, inherited]

Referenced by posix_port_rep::write().

bool wait ( int  msecs  )  [virtual, inherited]

Reimplemented from port_rep.

Definition at line 86 of file posix_port.cpp.

References posix_port_rep::alive, posix_port_rep::fd, and posix_port_rep::kind.

Referenced by socket_port_rep::accept(), socket_port_rep::feed(), and posix_port_rep::feed().

00086                                {
00087   //mmout << "Wait " << msecs << " ms on " << expression () << "\n";
00088   if ((kind & 2) == 0 || !alive) return false;
00089   fd_set in_fds;
00090   FD_ZERO (&in_fds);
00091   FD_SET (fd, &in_fds);
00092   
00093   nat nr;
00094   struct timeval tv;
00095   tv.tv_sec  = msecs / 1000;
00096   tv.tv_usec = 1000 * (msecs % 1000);
00097   if (msecs < 0) nr= select (fd + 1, &in_fds, NULL, NULL, NULL);
00098   else nr= select (fd + 1, &in_fds, NULL, NULL, &tv);
00099   //mmout << "Received " << nr << " on " << fd << "\n";
00100   return nr > 0;
00101 }

virtual void write ( const char *  s,
nat  n 
) [inline, virtual, inherited]

Reimplemented from port_rep.

Reimplemented in file_port_rep.

Definition at line 44 of file posix_port.hpp.

References posix_port_rep::send().

00044 { send (s, n); }


Member Data Documentation

bool alive [protected, inherited]
string buffer [protected, inherited]
int fd [protected, inherited]
int kind [protected, inherited]
nat pos [protected, inherited]
MMX_ALLOCATORS int ref_count [inherited]

Definition at line 164 of file basix.hpp.


The documentation for this class was generated from the following file:

Generated on 6 Dec 2012 for basix by  doxygen 1.6.1