LicenseSpring C++ SDK  7.31.0
Easily add Software Licensing to your application
LicenseSpring::BaseManager Class Reference

Base class for license management. More...

#include <LicenseSpring/BaseManager.h>

Inheritance diagram for LicenseSpring::BaseManager:
LicenseSpring::FloatingClient LicenseSpring::LicenseManager

Public Member Functions

 BaseManager (Configuration::ptr_t config, LicenseStorage::ptr_t storage=nullptr)
 Create and intialize license manager with given configuration. More...
 
 BaseManager (const BaseManager &)=delete
 
BaseManageroperator= (const BaseManager &)=delete
 
virtual ~BaseManager ()
 Destroy LicenseManger with current configuration. More...
 
Configuration::ptr_t currentConfig () const
 Returns current configuration. More...
 
void reconfigure (Configuration::ptr_t config)
 Change current configuration. More...
 
ProductDetails getProductDetails (bool includeLatestVersion=false)
 Get basic information from the backend on product which corresponds to the current configuration. More...
 
const License::ptr_t getCurrentLicense ()
 Load license from local storage (if not yet loaded). More...
 
const License::ptr_t reloadLicense ()
 Resets current license and loads it again from local storage. More...
 
void clearLocalStorage ()
 Remove local license, other files and folders created by LicenseSpring, usually should be called at app uninstallation. More...
 
const std::wstring & dataLocation () const
 Absolute folder path where LicenseSpring data is stored. More...
 
void setDataLocation (const std::wstring &path)
 Set absolute or relative path to folder where LicenseSpring data should be stored. More...
 
std::wstring licenseFileName () const
 Return license file name with extension, unless filename was explicitly set to be without extension. More...
 
void setLicenseFileName (const std::wstring &name)
 Set license file name, it can be with or without extension. More...
 
std::wstring licenseFilePath () const
 Return concatenated dataLocation() and licenseFileName(). More...
 

Protected Member Functions

void reset ()
 Reset (delete) members. More...
 

Protected Attributes

Configuration::ptr_t m_config
 
std::shared_ptr< DataHandler > m_dataHandler
 
LicenseService * m_pLicenseService
 
License::ptr_t m_currentLicense
 

Detailed Description

Base class for license management.

Used to manipulate configuration, product details, current license, data location, license file name and path.
Extended to FloatingClient.h and LicenseManager.h.

Definition at line 23 of file BaseManager.h.

Constructor & Destructor Documentation

◆ BaseManager() [1/2]

LicenseSpring::BaseManager::BaseManager ( Configuration::ptr_t  config,
LicenseStorage::ptr_t  storage = nullptr 
)

Create and intialize license manager with given configuration.

Parameters
configConfiguration object to use
storageStorage for local license, by default local license is saved in a file
Exceptions
ConfigurationExceptionIf provided config is null

◆ BaseManager() [2/2]

LicenseSpring::BaseManager::BaseManager ( const BaseManager )
delete

◆ ~BaseManager()

virtual LicenseSpring::BaseManager::~BaseManager ( )
virtual

Destroy LicenseManger with current configuration.

Member Function Documentation

◆ operator=()

BaseManager& LicenseSpring::BaseManager::operator= ( const BaseManager )
delete

◆ currentConfig()

Configuration::ptr_t LicenseSpring::BaseManager::currentConfig ( ) const

Returns current configuration.

Returns
Shared pointer to current configuration.

◆ reconfigure()

void LicenseSpring::BaseManager::reconfigure ( Configuration::ptr_t  config)

Change current configuration.

Parameters
configCurrent configuration object to reconfigure
Warning
This method is not thread safe.

◆ getProductDetails()

ProductDetails LicenseSpring::BaseManager::getProductDetails ( bool  includeLatestVersion = false)

Get basic information from the backend on product which corresponds to the current configuration.

Parameters
includeLatestVersionIf true, also returns latest_version field
Returns
ProductDetails object of product code given.
Exceptions
ProductNotFoundExceptionIf product is not found on the backend of account with API/shared key combination
ConfigurationExceptionIn case of API/shared key combination not found on server
NoInternetExceptionIf cannot reach the server
NetworkTimeoutExceptionIn case of network timeout
LicenseServerExceptionIn case of internal server error
SignatureMismatchExceptionIn case signature returned by LicenseSpring server is not valid
UnknownLicenseSpringExceptionIn rare case if something went wrong, for example unexpected server response

◆ getCurrentLicense()

const License::ptr_t LicenseSpring::BaseManager::getCurrentLicense ( )

Load license from local storage (if not yet loaded).

If license has been already loaded into memory, this method just returns existing pointer to the license.

Returns
Shared pointer to license or null if no license exists for current configuration and storage.
Exceptions
LocalLicenseExceptionThrown if could not read license file or if local license corrupted

◆ reloadLicense()

const License::ptr_t LicenseSpring::BaseManager::reloadLicense ( )

Resets current license and loads it again from local storage.

Returns
Shared pointer to license or null if no license exists for current configuration and storage.
Exceptions
LocalLicenseExceptionThrown if could not read license file or if local license corrupted

◆ clearLocalStorage()

void LicenseSpring::BaseManager::clearLocalStorage ( )

Remove local license, other files and folders created by LicenseSpring, usually should be called at app uninstallation.

This method also removes current license from memory.

◆ dataLocation()

const std::wstring& LicenseSpring::BaseManager::dataLocation ( ) const

Absolute folder path where LicenseSpring data is stored.

Data like: log file, temp offline activation data, local license file in case LicenseFileStorageBase (or derived) is used.
Default SDK data location on Windows is: {SystemDrive}:/Users/{UserName}/AppData/Local/LicenseSpring/{ProductCode}
Default SDK data location on Linux is: HOME/.LicenseSpring/LicenseSpring/{ProductCode}
Default SDK data location on MAC is: ~/Library/Application Support/LicenseSpring/{ProductCode}

Returns
Absolute folder path (location) of the SDK data.

◆ setDataLocation()

void LicenseSpring::BaseManager::setDataLocation ( const std::wstring &  path)

Set absolute or relative path to folder where LicenseSpring data should be stored.

If you want set data location to current directory use ".", empty string results in reset to default location (see dataLocation()). If path provided does not exist, the folders are created to match the path given.

Parameters
pathAbsolute or relative folder path
Warning
If there's a license in the new location, it will be set as current license, otherwise the current license will be removed from memory.

◆ licenseFileName()

std::wstring LicenseSpring::BaseManager::licenseFileName ( ) const

Return license file name with extension, unless filename was explicitly set to be without extension.

Meaningful only if LicenseFileStorageBase (or derived) is used. Default filename is License.key.

Returns
License file name.

◆ setLicenseFileName()

void LicenseSpring::BaseManager::setLicenseFileName ( const std::wstring &  name)

Set license file name, it can be with or without extension.

Meaningful only if LicenseFileStorageBase (or derived) is used. Default filename is License.key.

Parameters
nameLicense file name
Warning
This method also removes current license from memory.

◆ licenseFilePath()

std::wstring LicenseSpring::BaseManager::licenseFilePath ( ) const

Return concatenated dataLocation() and licenseFileName().

If currently using not LicenseFileStorageBase (or derived), then it is the same as dataLocation().

Returns
Absolute license file path.

◆ reset()

void LicenseSpring::BaseManager::reset ( )
protected

Reset (delete) members.

Member Data Documentation

◆ m_config

Configuration::ptr_t LicenseSpring::BaseManager::m_config
protected

Definition at line 104 of file BaseManager.h.

◆ m_dataHandler

std::shared_ptr<DataHandler> LicenseSpring::BaseManager::m_dataHandler
protected

Definition at line 105 of file BaseManager.h.

◆ m_pLicenseService

LicenseService* LicenseSpring::BaseManager::m_pLicenseService
protected

Definition at line 106 of file BaseManager.h.

◆ m_currentLicense

License::ptr_t LicenseSpring::BaseManager::m_currentLicense
protected

Definition at line 107 of file BaseManager.h.


The documentation for this class was generated from the following file: