dlvhex  2.5.0
DLVProcess Class Reference

A wrapper process for the DLV/DLVDB ASP engine. More...

#include <include/dlvhex2/DLVProcess.h>

Inheritance diagram for DLVProcess:
Collaboration diagram for DLVProcess:

Public Member Functions

 DLVProcess ()
 Constructor.
virtual ~DLVProcess ()
 Destructor.
virtual void addOption (const std::string &)
 Adds an option to the commandline.
virtual void setPath (const std::string &)
virtual std::string path () const
 Returns the executable command.
virtual std::vector< std::string > commandline () const
 Returns the whole reasoner commandline call.
virtual void spawn ()
 Instantiates a new process spawned from this one.
virtual void spawn (const std::vector< std::string > &)
 Instantiates a new process spawned from this one using a given commandline string.
virtual void endoffile ()
 Sends EOF to the process.
virtual int close (bool kill=false)
 Waits for the process to terminate.
virtual std::ostream & getOutput ()
 Retrieve the output stream of the process.
virtual std::istream & getInput ()
 Retrieve the input stream of the process.

Protected Member Functions

void setupStreams ()
 Initialize in/out streams.

Protected Attributes

ProcessBuf proc
std::istream * ipipe
 iostreams to the dlv process
std::ostream * opipe
 Output pipe.
std::string executable
 Executable path/name.
std::vector< std::string > argv
 Command line options.

Detailed Description

A wrapper process for the DLV/DLVDB ASP engine.

Todo:
this class should have a name similar to DebuggingSupportChildProcess to really capture its purpose

Definition at line 56 of file DLVProcess.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 50 of file DLVProcess.cpp.

DLVProcess::~DLVProcess ( ) [virtual]

Destructor.

Definition at line 54 of file DLVProcess.cpp.

References ProcessBuf::close(), ipipe, opipe, and proc.


Member Function Documentation

void DLVProcess::addOption ( const std::string &  o) [virtual]

Adds an option to the commandline.

Returns:
o Option to add.

Implements Process.

Definition at line 63 of file DLVProcess.cpp.

References argv.

Referenced by SimpleEvaluator::solve().

int DLVProcess::close ( bool  kill = false) [virtual]

Waits for the process to terminate.

Parameters:
killIf true the child process will be killed, otherwise the method waits.
Returns:
Return code of the process.

Implements Process.

Definition at line 154 of file DLVProcess.cpp.

References ProcessBuf::close(), ipipe, opipe, and proc.

std::vector< std::string > DLVProcess::commandline ( ) const [virtual]

Returns the whole reasoner commandline call.

Returns:
Command separated into executable and options.

Implements Process.

Definition at line 84 of file DLVProcess.cpp.

References argv, and path().

Referenced by spawn().

void DLVProcess::endoffile ( ) [virtual]

Sends EOF to the process.

Implements Process.

Definition at line 147 of file DLVProcess.cpp.

References ProcessBuf::endoffile(), and proc.

Referenced by SimpleEvaluator::solve().

std::istream & DLVProcess::getInput ( ) [virtual]

Retrieve the input stream of the process.

Returns:
Input stream.

Implements Process.

Definition at line 175 of file DLVProcess.cpp.

References ipipe.

Referenced by SimpleEvaluator::solve().

std::ostream & DLVProcess::getOutput ( ) [virtual]

Retrieve the output stream of the process.

Returns:
Output stream.

Implements Process.

Definition at line 167 of file DLVProcess.cpp.

References opipe.

Referenced by SimpleEvaluator::solve().

std::string DLVProcess::path ( ) const [virtual]

Returns the executable command.

Returns:
Reasoner executable command.

Implements Process.

Definition at line 77 of file DLVProcess.cpp.

References executable.

Referenced by commandline(), setPath(), and spawn().

void DLVProcess::setPath ( const std::string &  path) [virtual]

Definition at line 70 of file DLVProcess.cpp.

References executable, and path().

Referenced by SimpleEvaluator::solve().

void DLVProcess::setupStreams ( ) [protected]

Initialize in/out streams.

Definition at line 97 of file DLVProcess.cpp.

References Logger::DBG, DBGLOG, Logger::Instance(), ipipe, opipe, and proc.

Referenced by spawn().

void DLVProcess::spawn ( ) [virtual]

Instantiates a new process spawned from this one.

Implements Process.

Definition at line 128 of file DLVProcess.cpp.

References commandline(), ProcessBuf::open(), proc, and setupStreams().

Referenced by SimpleEvaluator::solve().

void DLVProcess::spawn ( const std::vector< std::string > &  c) [virtual]

Instantiates a new process spawned from this one using a given commandline string.

Parameters:
Commandlineexecuted by the new process.

Implements Process.

Definition at line 136 of file DLVProcess.cpp.

References ProcessBuf::open(), path(), proc, and setupStreams().


Field Documentation

std::vector<std::string> DLVProcess::argv [protected]

Command line options.

Definition at line 72 of file DLVProcess.h.

Referenced by addOption(), and commandline().

std::string DLVProcess::executable [protected]

Executable path/name.

Definition at line 69 of file DLVProcess.h.

Referenced by path(), and setPath().

std::istream* DLVProcess::ipipe [protected]

iostreams to the dlv process

Input pipe.

Definition at line 64 of file DLVProcess.h.

Referenced by close(), getInput(), setupStreams(), and ~DLVProcess().

std::ostream* DLVProcess::opipe [protected]

Output pipe.

Definition at line 66 of file DLVProcess.h.

Referenced by close(), getOutput(), setupStreams(), and ~DLVProcess().

Definition at line 60 of file DLVProcess.h.

Referenced by close(), endoffile(), setupStreams(), spawn(), and ~DLVProcess().


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