AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
ExternalProcess.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXOSG_EXTERNALPROCESS_H
18#define AGXOSG_EXTERNALPROCESS_H
19
20#include <agxOSG/export.h>
21#include <agx/Referenced.h>
22#include <thread>
23#include <memory>
24#include <atomic>
25#include <agx/String.h>
26
28namespace detail
29{
30 class Process;
31}
33
34namespace agxOSG
35{
41 {
42 public:
44 ExternalProcess(const agx::String& processTag = "");
45
46 /*
47 Launch an external process with a shell command.
48 \param command The shell command to be executed
49 \param workingDir The working directory where the process will be executed
50 \param waitForStartupMs The wait time in ms after the process has started
51 before returning the process status in the function.
52 \return True if process is still running.
53 */
54 bool startProcess(const agx::StringVector& commandVector,
55 const agx::String& workingDir,
56 agx::UInt startupWaitTimeMs=50);
57
63
69
72
74 bool isRunning() const;
75
77 protected:
79
80 bool startProcess(const agx::String& command,
81 const agx::String& workingDir,
82 agx::UInt startupWaitTimeMs=50);
83
84 private:
85 const agx::String m_processTag;
86 std::unique_ptr<detail::Process> m_externalProcess;
87 std::thread m_processThread;
88 std::atomic_bool m_processIsRunning;
89 int m_exitStatus;
90 };
91}
92
93#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXOSG_EXPORT
Cross-platform utility class for wrapping and launching external processes.
ExternalProcess(const ExternalProcess &)=delete
int closeAndWaitForExit()
Will try to close the external process and wait for it's exit.
bool startProcess(const agx::String &command, const agx::String &workingDir, agx::UInt startupWaitTimeMs=50)
ExternalProcess(const agx::String &processTag="")
Default constructor.
void killProcess()
Will kill the external process by forcing a close.
bool startProcess(const agx::StringVector &commandVector, const agx::String &workingDir, agx::UInt startupWaitTimeMs=50)
bool isRunning() const
Return true if the process is still running. False it not.
int waitUntilExit()
Will wait until the external process has exited.
Base class providing referencing counted objects.
Definition: Referenced.h:120
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
uint64_t UInt
Definition: Integer.h:27