add new wrapper implementation for Ecorexx::Exe

SVN revision: 79643
This commit is contained in:
Andreas Volz 2012-11-24 21:36:10 +00:00
parent 1591248deb
commit 03584d3b73
5 changed files with 249 additions and 2 deletions

View File

@ -17,6 +17,7 @@
#include "Timer.h"
#include "XWindow.h"
#include "Job.h"
#include "Exe.h"
#endif // ECOREXX_H

View File

@ -0,0 +1,93 @@
#ifndef ECOREXX_EXE_H
#define ECOREXX_EXE_H
/* EFL */
#include <Ecore.h>
#include <eflxx/CountedPtr.h>
namespace Ecorexx {
/**
* @defgroup Ecorexx_Exe_Group Process Spawning Functions
*
* This module is responsible for managing portable processes using Ecore.
* With this module you're able to spawn processes and you also can pause,
* quit your spawned processes.
* An interaction between your process and those spawned is possible
* using pipes or signals.
*
*
* @ingroup Ecorexx_Main_Loop_Group
*
* @{
*/
class Exe
{
public:
virtual ~Exe();
static void setRunPriority(int pri);
static int getRunPriority();
static Eflxx::CountedPtr <Exe> run(const std::string &exe_cmd, const void *data);
static Eflxx::CountedPtr <Exe> runPipe(const std::string &exe_cmd, Ecore_Exe_Flags flags, const void *data);
// TODO
//EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func);
bool send(const void *data, int size);
void stdinClose();
void setAutoLimits(int start_bytes, int end_bytes, int start_lines, int end_lines);
// TODO
//EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags);
void freeData(Ecore_Exe_Event_Data *data);
pid_t getPid();
void setTag(const std::string &tag);
std::string getTag();
std::string getCmd();
void *getData();
void *setData(void *data);
Ecore_Exe_Flags getFlags();
void pause();
void cont();
void interrupt();
void quit();
void terminate();
void kill();
void signal(int num);
void hup();
private:
/**
* no constructor -> call run() or runPipe()
*/
Exe();
Exe(const Exe&); // forbid copy constructor
Ecore_Exe *mExe;
};
} // end namespace Ecorexx
#endif // ECOREXX_EXE_H

View File

@ -10,7 +10,8 @@ libecorexx_HEADERS = \
EvasWindowFB.h \
EvasWindowGLX11.h \
EvasWindowSoftwareX11.h \
EvasWindowXRenderX11.h
EvasWindowXRenderX11.h \
Exe.h
libecorexxdir = \
$(pkgincludedir)

151
ecorexx/src/Exe.cpp Normal file
View File

@ -0,0 +1,151 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* STL */
#include <string>
#include <cassert>
#include "ecorexx/Exe.h"
namespace Ecorexx {
Exe::Exe() :
mExe(NULL)
{
}
Exe::~Exe()
{
if(mExe)
{
assert(ecore_exe_free(mExe));
}
}
void Exe::setRunPriority(int pri)
{
ecore_exe_run_priority_set(pri);
}
int Exe::getRunPriority()
{
return ecore_exe_run_priority_get();
}
Eflxx::CountedPtr <Exe> Exe::run(const std::string &exe_cmd, const void *data)
{
Ecore_Exe *ecore_exe = ecore_exe_run(exe_cmd.c_str(), data);
Exe *exe_obj = new Exe();
exe_obj->mExe = ecore_exe;
return Eflxx::CountedPtr <Exe> (exe_obj);
}
Eflxx::CountedPtr <Exe> Exe::runPipe(const std::string &exe_cmd, Ecore_Exe_Flags flags, const void *data)
{
Ecore_Exe *ecore_exe = ecore_exe_pipe_run(exe_cmd.c_str(), flags, data);
Exe *exe_obj = new Exe();
exe_obj->mExe = ecore_exe;
return Eflxx::CountedPtr <Exe> (exe_obj);
}
bool Exe::send(const void *data, int size)
{
return ecore_exe_send(mExe, data, size);
}
void Exe::stdinClose()
{
ecore_exe_close_stdin(mExe);
}
void Exe::setAutoLimits(int start_bytes, int end_bytes, int start_lines, int end_lines)
{
ecore_exe_auto_limits_set(mExe, start_bytes, end_bytes, start_lines, end_lines);
}
void Exe::freeData(Ecore_Exe_Event_Data *data)
{
ecore_exe_event_data_free(data);
}
pid_t Exe::getPid()
{
return ecore_exe_pid_get(mExe);
}
void Exe::setTag(const std::string &tag)
{
ecore_exe_tag_set(mExe, tag.c_str());
}
std::string Exe::getTag()
{
return ecore_exe_tag_get(mExe);
}
std::string Exe::getCmd()
{
return ecore_exe_cmd_get(mExe);
}
void *Exe::getData()
{
return ecore_exe_data_get(mExe);
}
void *Exe::setData(void *data)
{
return ecore_exe_data_set(mExe, data);
}
Ecore_Exe_Flags Exe::getFlags()
{
return ecore_exe_flags_get(mExe);
}
void Exe::pause()
{
ecore_exe_pause(mExe);
}
void Exe::cont()
{
ecore_exe_continue(mExe);
}
void Exe::interrupt()
{
ecore_exe_interrupt(mExe);
}
void Exe::quit()
{
ecore_exe_quit(mExe);
}
void Exe::terminate()
{
ecore_exe_terminate(mExe);
}
void Exe::kill()
{
ecore_exe_kill(mExe);
}
void Exe::signal(int num)
{
ecore_exe_signal(mExe, num);
}
void Exe::hup()
{
ecore_exe_hup(mExe);
}
} // end namespace Ecorexx

View File

@ -26,7 +26,8 @@ libecorexx_la_SOURCES = \
EvasWindowFB.cpp \
EvasWindowGLX11.cpp \
EvasWindowSoftwareX11.cpp \
EvasWindowXRenderX11.cpp
EvasWindowXRenderX11.cpp \
Exe.cpp
libecorexx_la_LIBADD = \
$(EFL_LIBS)