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

Public Types | Public Member Functions | Static Public Member Functions | List of all members
LicenseSpring::FileStorageWithLock Class Reference

Class that saves license in a file, derived from `LicenseFileStorageBase` class. More...

`#include <LicenseSpring/LicenseFileStorage.h>`

Inheritance diagram for LicenseSpring::FileStorageWithLock:

## Public Types
using | ptr_t = std::shared_ptr< FileStorageWithLock >
Public Types inherited from LicenseSpring::LicenseFileStorageBase
using | ptr_t = std::shared_ptr< LicenseFileStorageBase >
Public Types inherited from LicenseSpring::LicenseStorage
using | ptr_t = std::shared_ptr< LicenseStorage >

## Public Member Functions
| FileStorageWithLock (const std::wstring &licensePath=std::wstring())
| FileStorageWithLock constructor. More...
void | saveLicense (const std::string &data) override
| Saves given license data string to the file. More...
std::string | loadLicense () override
| Load license from file. More...
void | clear () override
| Removes local license file. More...
uint32_t | attemptsCount () const
| Get file lock operation attempts count. More...
void | setAttemptsCount (uint32_t count)
| Set file lock operation attempts count. More...
uint32_t | waitTimeout () const
| Get timeout in milliseconds between file lock attempts. More...
void | setWaitTimeout (uint32_t timeout)
| Set timeout in milliseconds between file lock attempts. More...
Public Member Functions inherited from LicenseSpring::LicenseFileStorageBase
| LicenseFileStorageBase (const std::wstring &licensePath=std::wstring())
| Constructor for LicenseFileStorageBase object. More...
void | setLicenseFileName (const std::wstring &name)
| Setter for license filename with extension (optional). Default filename is License.key. More...
void | setLicenseFolderPath (const std::wstring &path)
| Setter for folder path where License file is being stored. More...
const std::wstring & | licenseFileName () const
| Getter for license filename with extension (optional). More...
const std::wstring & | licenseFolderPath () const
| Getter for folder path where License file is being stored. More...
std::wstring | licenseFilePath () const
| Getter for path to the license file. More...
Public Member Functions inherited from LicenseSpring::LicenseStorage
virtual | ~LicenseStorage ()
| Destructor for LicenseStorage object. More...

## Static Public Member Functions
static ptr_t | create (const std::wstring &licensePath=std::wstring())
| Allocates and constructs a FileStorageWithLock object and passes args to FileStorageWithLock(). More...
Static Public Member Functions inherited from LicenseSpring::LicenseFileStorageBase
static ptr_t | create (const std::wstring &licensePath=std::wstring())
| Allocates and constructs a LicenseFileStorageBase object and passes args to LicenseFileStorageBase(). More...

## Additional Inherited Members
Protected Member Functions inherited from LicenseSpring::LicenseFileStorageBase
std::wstring | prepareRead () const
| Prepare to read license file. More...
std::wstring | prepareWrite () const
| Prepare to write license file. More...
std::string | readLicense (const std::wstring &filePath) const
| Reads license from file. More...
void | writeLicense (const std::wstring &filePath, const std::string &data) const
| Writes given license data string to the file. More...
Protected Attributes inherited from LicenseSpring::LicenseFileStorageBase
std::wstring | m_folderPath
std::wstring | m_fileName

## Detailed Description

Class that saves license in a file, derived from `LicenseFileStorageBase` class.

Enhanced license file storage type for interprocess use. It uses file locking mechanism for synchronization. File operations of this class is thread and process safe.

Definition at line 194 of file LicenseFileStorage.h.

## Member Typedef Documentation

## ◆ ptr_t

using LicenseSpring::FileStorageWithLock::ptr_t = std::shared_ptr<FileStorageWithLock>

Definition at line 197 of file LicenseFileStorage.h.

## Constructor & Destructor Documentation

## ◆ FileStorageWithLock()

LicenseSpring::FileStorageWithLock::FileStorageWithLock | ( | const std::wstring & | licensePath = `std::wstring()` | ) |

FileStorageWithLock constructor.

Parameters

  licensePath | The path that license folder path will be set to

## Member Function Documentation

## ◆ create()

static ptr_t LicenseSpring::FileStorageWithLock::create | ( | const std::wstring & | licensePath = `std::wstring()` | ) |
| static

Allocates and constructs a FileStorageWithLock object and passes args to FileStorageWithLock().

Parameters

  licensePath | The path that license folder path will be set to

Returns
  A shared_ptr object that owns and stores a pointer to a newly allocated FileStorageWithLock object.

## ◆ saveLicense()

void LicenseSpring::FileStorageWithLock::saveLicense | ( | const std::string & | data | ) |
| override virtual

Saves given license data string to the file.

Parameters

  data | License data string

Reimplemented from LicenseSpring::LicenseFileStorageBase.

## ◆ loadLicense()

std::string LicenseSpring::FileStorageWithLock::loadLicense | ( |  | ) |
| override virtual

Load license from file.

Returns
  Encrypted license data.

Reimplemented from LicenseSpring::LicenseFileStorageBase.

## ◆ clear()

void LicenseSpring::FileStorageWithLock::clear | ( |  | ) |
| override virtual

Removes local license file.

Reimplemented from LicenseSpring::LicenseFileStorageBase.

## ◆ attemptsCount()

uint32_t LicenseSpring::FileStorageWithLock::attemptsCount | ( |  | ) | const

Get file lock operation attempts count.

Default value is 20 attempts, min is 1.

Returns
  Attempts count.

## ◆ setAttemptsCount()

void LicenseSpring::FileStorageWithLock::setAttemptsCount | ( | uint32_t | count | ) |

Set file lock operation attempts count.

Parameters

  count | Attempts count

## ◆ waitTimeout()

uint32_t LicenseSpring::FileStorageWithLock::waitTimeout | ( |  | ) | const

Get timeout in milliseconds between file lock attempts.

Default value is 50ms, min is 10ms.

Returns
  Timeout in milliseconds.

## ◆ setWaitTimeout()

void LicenseSpring::FileStorageWithLock::setWaitTimeout | ( | uint32_t | timeout | ) |

Set timeout in milliseconds between file lock attempts.

Parameters

  timeout | Timeout in milliseconds

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

- LicenseSpring/LicenseFileStorage.h