| LicenseSpring C++ SDK 7.32.0 Easily add Software Licensing to your application

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LicenseSpring::BaseManager Class Reference

Base class for license management. More...

`#include <LicenseSpring/BaseManager.h>`

Inheritance diagram for LicenseSpring::BaseManager:

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

## Protected Member Functions
void | reset ()
| Reset (delete) members.

## Protected Attributes
Configuration::ptr_t | m_config
std::shared_ptr< DataHandler > | m_dataHandler
std::shared_ptr< 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

  config | Configuration object to use
  storage | Storage for local license, by default local license is saved in a file

Exceptions

  ConfigurationException | If 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

  config | Current 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

  includeLatestVersion | If true, also returns latest_version field

Returns
  ProductDetails object of product code given.

Exceptions

  ProductNotFoundException | If product is not found on the backend of account with API/shared key combination
  ConfigurationException | In case of API/shared key combination not found on server
  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  LicenseServerException | In case of internal server error
  SignatureMismatchException | In case signature returned by LicenseSpring server is not valid
  UnknownLicenseSpringException | In 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

  LocalLicenseException | Thrown 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

  LocalLicenseException | Thrown 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

  path | Absolute 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

  name | License 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

std::shared_ptr<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:

- LicenseSpring/BaseManager.h