AGXDynamics  2.31.1.0
DotnetRuntime.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <agx/Singleton.h>
4 #include <agx/DynamicLibrary.h>
6 
7 // Header files copied from https://github.com/dotnet/core-setup
8 #include <external/dotnet/coreclr_delegates.h>
9 #include <external/dotnet/hostfxr.h>
10 
11 namespace agxDotnet {
12 
19  public:
21  public:
22  Function(component_entry_point_fn handle);
23 
24  int call(void *argData, size_t argNumBytes);
25 
26  private:
27  component_entry_point_fn m_fn;
28  };
29 
32  public:
33  agx::String getName() const;
34  agx::String getRootPath() const;
35  agx::String getConfigPath() const;
36  agx::String getLibPath() const;
37 
38  Function loadEntrypoint(const agx::String& classPath, const agx::String& methodName, agx::String& error);
39 
40  protected:
41  ~Assembly() override;
42 
43  private:
44  friend class HostedRuntime;
45  explicit Assembly(const agx::String& rootPath, const agx::String& name);
46 
47  private:
48  const agx::String m_rootPath;
49  const agx::String m_name;
50  load_assembly_and_get_function_pointer_fn m_loadFn;
51  };
52 
53  public:
54  static HostedRuntime *instance();
55  SINGLETON_CLASSNAME_METHOD();
56 
57  static HostedRuntime* init(const agx::String& distRoot, const agx::String& mainAssemblyName);
58 
59  Assembly* getMainAssembly();
60 
61  Assembly* assemblyFromConfig(const agx::String& distRoot, const agx::String& mainAssemblyName);
62 
63  protected:
64  void shutdown() override;
65  ~HostedRuntime() override;
66 
67  private:
68  void loadHostFxr();
69 
70  private:
71  hostfxr_initialize_for_runtime_config_fn m_initFn;
72  hostfxr_get_runtime_delegate_fn m_getDelegateFn;
73  hostfxr_close_fn m_closeFn;
74  agx::DynamicLibraryRef m_hostFxrLibrary;
75  AssemblyRef m_mainAssembly;
76  };
77 }
void AGXPHYSICS_EXPORT init()
Initialize agx.
void AGXPHYSICS_EXPORT shutdown()
Shutdown agx.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXDOTNET_EXPORT
Base class providing referencing counted objects.
Definition: Referenced.h:113
Ref for error codes: https://github.com/dotnet/runtime/blob/master/docs/design/features/host-error-co...
Definition: DotnetRuntime.h:18
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:30