10Duke Scale C++ Client
Loading...
Searching...
No Matches
FluentConsumptionBuilder.h
1#ifndef TENDUKE_SE_LICENSING_FLUENTCONSUMPTIONBUILDER_H
2#define TENDUKE_SE_LICENSING_FLUENTCONSUMPTIONBUILDER_H
3
4#include "./LicenseCheckoutArguments.h"
5#include "./LicenseCheckoutParameters.h"
6#include "../../License.h"
7
8#include <cstdint>
9#include <string>
10#include <utility>
11
12namespace tenduke { namespace se { namespace licensing {
13
18template <typename Builder>
20{
21public:
26 explicit FluentConsumptionBuilder(std::string licenseKey)
27 : buildingItem(false)
28 , licenseKey(std::move(licenseKey))
29 , qty(0)
30 , qtyDimension(::tenduke::se::licensing::License::QuantityDimension::NONE)
31 {}
32
33public:
40 Builder & seats(const std::string &pProductName, std::int64_t numSeats)
41 {
42 buildArgument();
43 startArgument(::tenduke::se::licensing::License::SEATS, pProductName, numSeats);
44 return static_cast<Builder&>(*this);
45 }
46
52 Builder & seat(const std::string &pProductName)
53 {
54 return seats(pProductName, 1);
55 }
56
63 Builder & count(const std::string &pProductName, std::int64_t useCount)
64 {
65 buildArgument();
66 startArgument(::tenduke::se::licensing::License::USE_COUNT, pProductName, useCount);
67 return static_cast<Builder&>(*this);
68 }
69
75 Builder & count(const std::string &pProductName)
76 {
77 return count(pProductName, 1);
78 }
79
86 Builder & time(const std::string &pProductName, std::int64_t useTime)
87 {
88 buildArgument();
89 startArgument(::tenduke::se::licensing::License::USE_TIME, pProductName, useTime);
90 return static_cast<Builder&>(*this);
91 }
92
113 Builder & version(const std::string &pClientVersion)
114 {
115 if (buildingItem) {
116 this->clientVersion = pClientVersion;
117 }
118 else {
119 defaultVersion = pClientVersion;
120 }
121 return static_cast<Builder&>(*this);
122 }
123
139 Builder & licenseId(const std::string &pLicenseId)
140 {
141 this->id = pLicenseId;
142 return static_cast<Builder&>(*this);
143 }
144
145protected:
152 void buildArgument()
153 {
154 if (buildingItem) {
155 arguments.emplace_back(
156 productName,
157 qty,
158 qtyDimension,
159 clientVersion,
160 id
161 );
162 buildingItem = false;
163 }
164 }
165
172 void startArgument(
174 const std::string &pProductName,
175 std::int64_t pQty
176 )
177 {
178 this->buildingItem = true;
179 this->qtyDimension = pQtyDimension;
180 this->productName = pProductName;
181 this->qty = pQty;
182
183 this->id = "";
184 this->clientVersion = defaultVersion;
185 }
186
187protected:
189 const std::string licenseKey;
190
192 std::vector<::tenduke::se::licensing::LicenseCheckoutArguments> arguments;
193
194private:
195 bool buildingItem;
196 std::string defaultVersion;
197
199 std::string clientVersion;
200 std::int64_t qty;
201 std::string productName;
202 std::string id;
203};
204
205}}}
206
207#endif //TENDUKE_SE_LICENSING_FLUENTCONSUMPTIONBUILDER_H
FluentConsumptionBuilder(std::string licenseKey)
Constructs new instance.
Definition FluentConsumptionBuilder.h:26
Builder & seats(const std::string &pProductName, std::int64_t numSeats)
Start building a license-consumption for seats.
Definition FluentConsumptionBuilder.h:40
FluentConsumptionBuilder(std::string licenseKey)
Constructs new instance.
Definition FluentConsumptionBuilder.h:26
Builder & count(const std::string &pProductName, std::int64_t useCount)
Start building a license consumption for use count.
Definition FluentConsumptionBuilder.h:63
Builder & time(const std::string &pProductName, std::int64_t useTime)
Starts building a license consumption of use time.
Definition FluentConsumptionBuilder.h:86
Builder & seat(const std::string &pProductName)
Start building a license-consumption for one seat.
Definition FluentConsumptionBuilder.h:52
Builder & version(const std::string &pClientVersion)
Set the client version.
Definition FluentConsumptionBuilder.h:113
Builder & count(const std::string &pProductName)
Starts building a license consumption for one use count.
Definition FluentConsumptionBuilder.h:75
10Duke Scale license.
Definition License.h:27
QuantityDimension
Quantity dimensions.
Definition License.h:33
Licensing operations for 10Duke Scale.
Definition LicenseConsumerClientBindingStatus.h:8
Classes, functions and globals of 10Duke Scale C++ Client.
Definition AbstractClientFactory.h:16
Root for classes, functions and globals of 10Duke C++ Client.
Definition AbstractClientFactory.h:16