AGX Dynamics  2.35.0.1
ScriptConsole.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 
18 #pragma once
19 #ifndef AGXPYTHON_SCRIPTCONSOLE_H
20 #define AGXPYTHON_SCRIPTCONSOLE_H 1
21 
22 #include <agx/config/AGX_USE_PYTHON.h>
23 
24 #if AGX_USE_PYTHON()
25 
26 #include <agxPython/export.h>
27 
28 #include <agx/Referenced.h>
29 #include <agx/String.h>
30 
31 #include <string>
32 
33 namespace agxPython
34 {
35 
36  class AGXPYTHON_EXPORT ScriptConsole : public agx::Referenced
37  {
38  public:
39 
46  static bool EmbedIntoPython();
47 
48  ScriptConsole();
49 
55  virtual void OnStdout(const agx::String& buffer);
56 
62  virtual void OnStderr(const agx::String& buffer);
63 
64  void write(const std::string& s, void *type);
65 
66  void init();
67 
68  void set_stdout();
69  void reset_stdout();
70 
71  void set_stderr();
72  void reset_stderr();
73 
74  protected:
75 
76  virtual ~ScriptConsole();
77 
78  private:
79 
80  void *m_stdout;
81  void *m_stdout_saved;
82 
83  void *m_stderr;
84  void *m_stderr_saved;
85 
86  };
87 
88 
89 }
90 
91 
92 
93 #endif
94 
95 #endif
#define AGXPYTHON_EXPORT
Base class providing referencing counted objects.
Definition: Referenced.h:114
bool AGXPHYSICS_EXPORT write(const std::string &filename, const agxStream::Serializable *data)
Write a Serializable object to a file.
void AGXPHYSICS_EXPORT init()
Initialize agx.