Home | History | Annotate | Download | only in decpp
      1 /*-------------------------------------------------------------------------
      2  * drawElements C++ Base Library
      3  * -----------------------------
      4  *
      5  * Copyright 2014 The Android Open Source Project
      6  *
      7  * Licensed under the Apache License, Version 2.0 (the "License");
      8  * you may not use this file except in compliance with the License.
      9  * You may obtain a copy of the License at
     10  *
     11  *      http://www.apache.org/licenses/LICENSE-2.0
     12  *
     13  * Unless required by applicable law or agreed to in writing, software
     14  * distributed under the License is distributed on an "AS IS" BASIS,
     15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16  * See the License for the specific language governing permissions and
     17  * limitations under the License.
     18  *
     19  *//*!
     20  * \file
     21  * \brief deProcess C++ wrapper.
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "deProcess.hpp"
     25 
     26 #include <new>
     27 
     28 namespace de
     29 {
     30 
     31 Process::Process (void)
     32 	: m_process(deProcess_create())
     33 {
     34 	if (!m_process)
     35 		throw std::bad_alloc();
     36 }
     37 
     38 Process::~Process (void)
     39 {
     40 	deProcess_destroy(m_process);
     41 }
     42 
     43 void Process::start (const char* commandLine, const char* workingDirectory)
     44 {
     45 	if (!deProcess_start(m_process, commandLine, workingDirectory))
     46 		throw ProcessError(deProcess_getLastError(m_process));
     47 }
     48 
     49 void Process::waitForFinish (void)
     50 {
     51 	if (!deProcess_waitForFinish(m_process))
     52 		throw ProcessError(deProcess_getLastError(m_process));
     53 }
     54 
     55 void Process::terminate (void)
     56 {
     57 	if (!deProcess_terminate(m_process))
     58 		throw ProcessError(deProcess_getLastError(m_process));
     59 }
     60 
     61 void Process::kill (void)
     62 {
     63 	if (!deProcess_kill(m_process))
     64 		throw ProcessError(deProcess_getLastError(m_process));
     65 }
     66 
     67 void Process::closeStdIn (void)
     68 {
     69 	if (!deProcess_closeStdIn(m_process))
     70 		throw ProcessError(deProcess_getLastError(m_process));
     71 }
     72 
     73 void Process::closeStdOut (void)
     74 {
     75 	if (!deProcess_closeStdOut(m_process))
     76 		throw ProcessError(deProcess_getLastError(m_process));
     77 }
     78 
     79 void Process::closeStdErr (void)
     80 {
     81 	if (!deProcess_closeStdErr(m_process))
     82 		throw ProcessError(deProcess_getLastError(m_process));
     83 }
     84 
     85 } // de
     86