Arcane  v4.1.2.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Process.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Process.h (C) 2000-2025 */
9/* */
10/* Gestion des processus. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_INTERNAL_PROCESS_H
13#define ARCCORE_COMMON_INTERNAL_PROCESS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/String.h"
18
19#include "arccore/common/Array.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30class ARCCORE_COMMON_EXPORT ProcessExecArgs
31{
32 friend class Process;
33
34 public:
35
36 enum class ExecStatus
37 {
38 // Le processus fils a terminé correctement (mais peut être en erreur)
39 OK,
44 // Le processus fils n'a pas terminé correctement (void waitpid())
45 AbnormalExit
46 };
47
48 public:
49
51 String command() const { return m_command; }
52 void setCommand(const String& v) { m_command = v; }
53
55 ConstArrayView<String> arguments() const { return m_arguments; }
56 void addArguments(const String& v) { m_arguments.add(v); }
57 void setArguments(const Array<String>& v) { m_arguments = v; }
58
60 ConstArrayView<Byte> inputBytes() const { return m_input_bytes; }
61 void setInputBytes(ConstArrayView<Byte> s) { m_input_bytes = s; }
62
64 ConstArrayView<Byte> outputBytes() const { return m_output_bytes; }
66 int exitCode() const { return m_exit_code; }
67
68 private:
69
70 String m_command;
71 UniqueArray<String> m_arguments;
72 UniqueArray<Byte> m_input_bytes;
73 UniqueArray<Byte> m_output_bytes;
74 int m_exit_code = 0;
75};
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
82class ARCCORE_COMMON_EXPORT Process
83{
84 public:
85
88};
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93} // namespace Arcane
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98#endif
Vue constante d'un tableau de type T.
ConstArrayView< Byte > outputBytes() const
Contient le résultat de la sortie standard (STDOUT) du processus.
Definition Process.h:64
@ CanNotFork
Le fork() a échoué
Definition Process.h:41
@ CanNotCreatePipe
L'appel à pipe2() a échoué
Definition Process.h:43
ConstArrayView< String > arguments() const
Liste des arguments.
Definition Process.h:55
String command() const
Commande à exécuter. Doit correspondre à un exécutable.
Definition Process.h:51
int exitCode() const
Code de retour du processus exécuté.
Definition Process.h:66
ConstArrayView< Byte > inputBytes() const
Chaîne de caractères à envoyer sur l'entrée standard (STDIN) du processsus.
Definition Process.h:60
Classe permettant d'exécuter un processus externe.
Definition Process.h:83
static ProcessExecArgs::ExecStatus execute(ProcessExecArgs &args)
Exécute un processus dont les infos sont contenues dans args.
Definition Process.cc:40
Chaîne de caractères unicode.
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-