AGX Dynamics  2.35.0.1
Runtime.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 #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 #define AGX_LAAS_ENABLE() 0
28 
29 #include <map>
30 #include <vector>
31 #include <string>
32 
33 #else
34 
35 #include <agx/agx.h>
36 #include <agx/Singleton.h>
37 #include <agx/String.h>
38 #include <agx/HashTable.h>
39 #include <agxIO/win32Tools.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 
111 
112 
121  bool loadLicenseFile( const agx::String& licPath, bool forceRefresh = false );
122 
123 
135  bool loadLicenseString( const agx::String& licenseContents, bool forceRefresh = false );
136 
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 
190 
191 
192 
206  bool openNetworkSession(const agx::String& licenseFile = "floating.lfx" );
207 
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 
253 
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 
310 
315  bool isValid() const;
316 
321  const agx::String& getStatus() const;
322 
327 
328 
333  bool isModuleEnabled( const char* name ) const;
334 
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
362  virtual void shutdown() override;
363  #else
364  void shutdown();
365  #endif
366 
370  void clear();
371 
372  protected:
374 
375  private:
376  static Runtime *s_instance;
377 
378  #ifndef STANDALONE_RUNTIME
380 
381  #if AGX_LAAS_ENABLE()
382  bool readLaasLicense();
383  #endif
384 
385 
386  bool readAgxLicense();
387  bool validate();
388 
389  void fillTable( void* ptr );
390 
391 
392 
393 
394  StringTable m_table;
395 
396  agx::StringVector m_modules;
397 
398  agx::String m_status; // Contains status information
399  agx::String m_extendedStatus; //
400 
401  bool m_valid;
402  #endif
403 
404  UniqueIdVector m_uniqueIds;
405  };
406 
407 
408 }
409 
#define AGXPHYSICS_EXPORT
Inheritance with partial specialization due to bug with ref_ptr containers.
The Runtime class will read a license file upon creation and check what configuration is allowed to r...
Definition: Runtime.h:76
agx::String encryptRuntimeActivation(int runtimeLicenseId, const agx::String &runtimeLicensePassword, const agx::String &applicationFilename) const
Encrypt license id and password for runtime activation.
agx::String readEncryptedLicense()
Read the encrypted license, normally the contents from the license file.
bool hasKey(const char *key) const
bool processOfflineActivationRequest(const agx::String &activationResponse)
Processes the response from a manual activation request.
bool isModuleEnabled(const char *name) const
Check if a named AGX module is enabled.
bool openNetworkSession(const agx::String &licenseFile="floating.lfx")
Try to open a network session using the specified floating license.
const agx::String & getExtendedStatus() const
Provides optional extended status information about why license validation failed.
const agx::String & getStatus() const
Provides status information if license validation failed.
agx::Vector< UniqueIdStruct > UniqueIdVector
Definition: Runtime.h:91
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.
virtual void shutdown() override
Singleton cleanup method.
bool activateAgxLicense(int licenseId, const agx::String &activationPassword)
Perform online activation of AGX.
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:
const UniqueIdVector & getUniqueIds() const
static agx::String generateMD5(const agx::String &deviceID)
Utility method using agxStream::MD5Checksum::getMD5.
static bool isInitialized()
bool isValid() const
bool unlock(const agx::String &licenseString)
static Runtime * instance()
Singleton instance method.
bool closeNetworkSession()
Close the active network session.
agx::String generateOfflineActivationRequest(int licenseId, const agx::String &activationPassword)
Generates an activation request for a machine that does not have Internet access.
bool isLicenseRefreshed()
Check if license was refreshed upon loading.
bool activateAgxLicense(int licenseId, const agx::String &activationPassword, const agx::String &outputLicenseFile)
Perform online activation of AGX.
void clear()
Clear any previously loaded license.
const agx::StringVector & getEnabledModules() const
const agx::String & readValue(const char *key) const
bool loadLicenseString(const agx::String &licenseContents, bool forceRefresh=false)
Load a license but provided as a string instead of read from a file.
bool verifyAndUnlock(const char *licenseStr)
Unlock AGX Dynamics using obfuscated license string.
bool isFloatingLicense() const
Query licensetype.
bool loadLicenseFile(const agx::String &licPath, bool forceRefresh=false)
Load a License file that was created by activating AGX.
bool activateEncryptedRuntime(const agx::String &encryptedRuntimeData, const agx::String &outputLicenseFile)
Perform online activation of an encrypted runtime license.
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:31
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AgXString< std::string > String
Definition: String.h:423
struct agx::UniqueIdStruct_ UniqueIdStruct
Struct holding information about a Unique Id.
Struct holding information about a Unique Id.
Definition: Runtime.h:57
unsigned int type
Definition: Runtime.h:61
agx::String id
Definition: Runtime.h:58
agx::String raw
Definition: Runtime.h:59
agx::String comment
Definition: Runtime.h:60