AGX Dynamics  2.37.2.0
Runtime.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 #pragma once
18 
19 #include <agx/macros.h>
20 #include <agx/config/AGX_LAAS_ENABLE.h>
21 
22 #ifdef STANDALONE_RUNTIME
23 
24 #ifdef AGX_LAAS_ENABLE
25 #undef AGX_LAAS_ENABLE
26 #endif
27 
28 #define AGX_LAAS_ENABLE() 0
29 
30 #include <map>
31 #include <vector>
32 #include <string>
33 
34 #else
35 
36 #include <agx/agx.h>
37 #include <agx/Singleton.h>
38 #include <agx/String.h>
39 #include <agx/HashTable.h>
40 
41 #endif
42 
43 
44 namespace agx {
45 
47 
48  #ifdef STANDALONE_RUNTIME
49  typedef std::string String;
50  #endif
52 
53 
54 
57  typedef struct UniqueIdStruct_ {
61  unsigned int type;
63 
64 
73  #ifdef STANDALONE_RUNTIME
74  class Runtime {
75  #else
77  #endif
78 
79  public:
80 
82  NIC = 1,
83  USB = 2,
84  HDD = 3
85  };
86 
87 
88  #ifdef STANDALONE_RUNTIME
89  typedef std::vector< UniqueIdStruct > UniqueIdVector;
90  #else
92  #endif
93 
95  static Runtime* instance();
96 
98  static bool isInitialized();
99 
100 
104  static agx::String generateMD5( const agx::String& deviceID );
105 
106 
107  #if AGX_LAAS_ENABLE()
108 
110 
112 
121  bool loadLicenseFile( const agx::String& licPath, bool forceRefresh = false );
122 
123 
135  bool loadLicenseString( const agx::String& licenseContents, bool forceRefresh = false );
136 
140  bool isLicenseRefreshed();
141 
149 
150 
158  bool activateAgxLicense( int licenseId, const agx::String& activationPassword );
159 
160 
170  bool activateAgxLicense( int licenseId, const agx::String& activationPassword, const agx::String& outputLicenseFile );
171 
172 
176  agx::String generateOfflineActivationRequest(int licenseId, const agx::String& activationPassword );
177 
182  bool processOfflineActivationRequest(const agx::String& activationResponse);
183 
189  bool deactivateAgxLicense();
190 
191 
192 
206  bool openNetworkSession(const agx::String& licenseFile = "floating.lfx" );
207 
214  bool closeNetworkSession();
215 
220  bool isFloatingLicense() const;
221 
222 
233  agx::String encryptRuntimeActivation( int runtimeLicenseId,
234  const agx::String& runtimeLicensePassword,
235  const agx::String& applicationFilename ) const;
236 
244  bool activateEncryptedRuntime( const agx::String& encryptedRuntimeData,
245  const agx::String& outputLicenseFile );
247  #endif
248 
249 
250 
252 
257  const UniqueIdVector& getUniqueIds() const;
258 
259 
260  #ifndef STANDALONE_RUNTIME
261 
262 
274  bool unlock(const char* licenseString);
275 
276  bool unlock( const agx::String& licenseString);
277 
278 
291  bool verifyAndUnlock( const char* licenseStr );
292 
297  bool hasKey( const char* key ) const;
298 
302  const agx::String& readValue( const char* key ) const;
303 
305 
306 
307 
309 
315  bool isValid() const;
316 
321  const agx::String& getStatus() const;
322 
326  const agx::String& getExtendedStatus() const;
327 
328 
333  bool isModuleEnabled( const char* name ) const;
334 
338  const agx::StringVector& getEnabledModules() const;
339 
341 
342 
354  bool checkVersion(const agx::String& versionString, int generation, int major=-1, int minor=-1, int patch=-1);
355 
356 
357  SINGLETON_CLASSNAME_METHOD();
358  #endif
359 
360  #ifndef STANDALONE_RUNTIME
361  virtual void shutdown() override;
363  #else
364  void shutdown();
365  #endif
366 
370  void clear();
371 
372  protected:
373  Runtime();
374 
375  virtual ~Runtime();
376 
377  private:
378  static Runtime *s_instance;
379 
380  #ifndef STANDALONE_RUNTIME
382 
383  #if AGX_LAAS_ENABLE()
384  bool readLaasLicense();
385  #endif
386 
387 
388  bool readAgxLicense();
389  bool validate();
390 
391  void fillTable( void* ptr );
392 
393 
394 
395 
396  StringTable m_table;
397 
398  agx::StringVector m_modules;
399 
400  agx::String m_status; // Contains status information
401  agx::String m_extendedStatus; //
402 
403  bool m_valid;
404  #endif
405 
406  UniqueIdVector m_uniqueIds;
407  };
408 
409 
410 }
411 
const agx::String & getExtendedStatus() const
Provides optional extended status information about why license validation failed.
struct agx::UniqueIdStruct_ UniqueIdStruct
Struct holding information about a Unique Id.
const agx::String & readValue(const char *key) const
agx::String encryptRuntimeActivation(int runtimeLicenseId, const agx::String &runtimeLicensePassword, const agx::String &applicationFilename) const
Encrypt license id and password for runtime activation.
virtual ~Runtime()
bool hasKey(const char *key) const
agx::String id
Definition: Runtime.h:58
bool isFloatingLicense() const
Query licensetype.
bool activateAgxLicense(int licenseId, const agx::String &activationPassword)
Perform online activation of AGX.
#define AGXPHYSICS_EXPORT
bool loadLicenseFile(const agx::String &licPath, bool forceRefresh=false)
Load a License file that was created by activating AGX.
AgXString< std::string > String
Definition: String.h:427
void clear()
Clear any previously loaded license.
static bool isInitialized()
virtual void shutdown() override
Singleton cleanup method.
agx::String readEncryptedLicense()
Read the encrypted license, normally the contents from the license file.
static Runtime * instance()
Singleton instance method.
bool checkVersion(const agx::String &versionString, int generation, int major=-1, int minor=-1, int patch=-1)
Version string can be one of two variants:
bool deactivateAgxLicense()
Deactivate the currently loaded license if the license type allows it.
bool unlock(const char *licenseString)
Will try to unlock AGX with the license provided in licenseString.
agx::String raw
Definition: Runtime.h:59
bool closeNetworkSession()
Close the active network session.
static agx::String generateMD5(const agx::String &deviceID)
Utility method using agxStream::MD5Checksum::getMD5.
bool verifyAndUnlock(const char *licenseStr)
Unlock AGX Dynamics using obfuscated license string.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
const agx::String & getStatus() const
Provides status information if license validation failed.
bool loadLicenseString(const agx::String &licenseContents, bool forceRefresh=false)
Load a license but provided as a string instead of read from a file.
bool openNetworkSession(const agx::String &licenseFile="floating.lfx")
Try to open a network session using the specified floating license.
bool isValid() const
agx::String generateOfflineActivationRequest(int licenseId, const agx::String &activationPassword)
Generates an activation request for a machine that does not have Internet access. ...
agx::String comment
Definition: Runtime.h:60
agx::Vector< UniqueIdStruct > UniqueIdVector
Definition: Runtime.h:91
const UniqueIdVector & getUniqueIds() const
bool processOfflineActivationRequest(const agx::String &activationResponse)
Processes the response from a manual activation request.
bool isLicenseRefreshed()
Check if license was refreshed upon loading.
bool isModuleEnabled(const char *name) const
Check if a named AGX module is enabled.
const agx::StringVector & getEnabledModules() const
Struct holding information about a Unique Id.
Definition: Runtime.h:57
Inheritance with partial specialization due to bug with ref_ptr containers.
unsigned int type
Definition: Runtime.h:61
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:30
The Runtime class will read a license file upon creation and check what configuration is allowed to r...
Definition: Runtime.h:76
bool activateEncryptedRuntime(const agx::String &encryptedRuntimeData, const agx::String &outputLicenseFile)
Perform online activation of an encrypted runtime license.