AGXDynamics  2.31.1.0
Runtime.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 
69  #ifdef STANDALONE_RUNTIME
70  class Runtime {
71  #else
73  #endif
74 
75  public:
76 
78  NIC = 1,
79  USB = 2,
80  HDD = 3
81  };
82 
83 
84  #ifdef STANDALONE_RUNTIME
85  typedef std::vector< UniqueIdStruct > UniqueIdVector;
86  #else
88  #endif
89 
91  static Runtime* instance();
92 
94  static bool isInitialized();
95 
96 
100  static agx::String generateMD5( const agx::String& deviceID );
101 
102 
103  #if AGX_LAAS_ENABLE()
104 
106 
108 
117  bool loadLicenseFile( agx::String licPath, bool forceRefresh = false );
118 
119 
131  bool loadLicenseString( agx::String licenseContents, bool forceRefresh = false );
132 
136  bool isLicenseRefreshed();
137 
145 
146 
154  bool activateAgxLicense( int licenseId, const agx::String& activationPassword );
155 
156 
166  bool activateAgxLicense( int licenseId, const agx::String& activationPassword, const agx::String& outputLicenseFile );
167 
168 
172  agx::String generateOfflineActivationRequest(int licenseId, const agx::String& activationPassword );
173 
178  bool processOfflineActivationRequest(const agx::String& activationResponse);
179 
185  bool deactivateAgxLicense();
186 
197  agx::String encryptRuntimeActivation( int runtimeLicenseId,
198  const agx::String& runtimeLicensePassword,
199  const agx::String& applicationFilename ) const;
200 
208  bool activateEncryptedRuntime( const agx::String& encryptedRuntimeData,
209  const agx::String& outputLicenseFile );
211  #endif
212 
213 
214 
216 
221  const UniqueIdVector& getUniqueIds() const;
222 
223 
224  #ifndef STANDALONE_RUNTIME
225 
226 
238  bool unlock(const char* licenseString);
239 
240  bool unlock( const agx::String& licenseString);
241 
242 
244  bool verifyAndUnlock( const char* licenseStr );
245 
250  bool hasKey( const char* key ) const;
251 
255  agx::String readValue( const char* key ) const;
256 
258 
259 
260 
262 
268  bool isValid() const;
269 
274  const agx::String& getStatus() const;
275 
279  const agx::String& getExtendedStatus() const;
280 
281 
286  bool isModuleEnabled( const char* name ) const;
287 
291  const agx::StringVector& getEnabledModules() const;
292 
294 
295 
307  bool checkVersion(const agx::String& versionString, int generation, int major=-1, int minor=-1, int patch=-1);
308 
309 
310  SINGLETON_CLASSNAME_METHOD();
311  #endif
312 
313  #ifndef STANDALONE_RUNTIME
314  virtual void shutdown() override;
316  #else
317  void shutdown();
318  #endif
319 
323  void clear();
324 
325  protected:
326  Runtime();
327 
328  private:
329  static Runtime *s_instance;
330 
331  #ifndef STANDALONE_RUNTIME
333 
334  #if AGX_LAAS_ENABLE()
335  bool readLaasLicense();
336  #endif
337 
338 
339  bool readAgxLicense();
340  bool validate();
341 
342  void fillTable( void* ptr );
343 
344 
345 
346 
347  StringTable m_table;
348 
349  agx::StringVector m_modules;
350 
351  agx::String m_status; // Contains status information
352  agx::String m_extendedStatus; //
353 
354  bool m_valid;
355  #endif
356 
357  UniqueIdVector m_uniqueIds;
358  };
359 
360 
361 }
362 
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.
agx::String encryptRuntimeActivation(int runtimeLicenseId, const agx::String &runtimeLicensePassword, const agx::String &applicationFilename) const
Encrypt license id and password for runtime activation.
bool hasKey(const char *key) const
agx::String id
Definition: Runtime.h:58
bool activateAgxLicense(int licenseId, const agx::String &activationPassword)
Perform online activation of AGX.
#define AGXPHYSICS_EXPORT
AgXString< std::string > String
Definition: String.h:423
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
static agx::String generateMD5(const agx::String &deviceID)
Utility method using agxStream::MD5Checksum::getMD5.
bool verifyAndUnlock(const char *licenseStr)
For internal usage. Use one of the unlock functions instead.
Namespace agx contains the dynamics/math part of the AGX Dynamics API.
const agx::String & getStatus() const
Provides status information if license validation failed.
bool isValid() const
bool loadLicenseFile(agx::String licPath, bool forceRefresh=false)
Load a License file that was created by activating AGX.
bool loadLicenseString(agx::String licenseContents, bool forceRefresh=false)
Load a license but provided as a string instead of read from a file.
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:87
agx::String readValue(const char *key) const
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:102
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:101
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:72
bool activateEncryptedRuntime(const agx::String &encryptedRuntimeData, const agx::String &outputLicenseFile)
Perform online activation of an encrypted runtime license.