Lightstreamer C++ Client SDK
Loading...
Searching...
No Matches
Subscription.h
1/*
2 * Copyright (C) 2023 Lightstreamer Srl
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef INCLUDED_Lightstreamer_Subscription
17#define INCLUDED_Lightstreamer_Subscription
18
19#include "../Lightstreamer.h"
20#include "Lightstreamer/LightstreamerError.h"
21
22namespace Lightstreamer {
23
72 friend class LightstreamerClient;
73 HaxeObject _delegate;
74public:
75 Subscription() = delete;
76 Subscription(const Subscription&) = delete;
77 Subscription& operator=(const Subscription&) = delete;
78
108 Subscription(const std::string& mode, const std::vector<std::string>& items, const std::vector<std::string>& fields) {
109 _delegate = Subscription_new(&mode, &items, &fields, this);
110 }
111
112 ~Subscription() {
113 Lightstreamer_releaseHaxeObject(_delegate);
114 }
129 if (listener == nullptr)
130 throw LightstreamerError("Argument cannot be null");
131 Subscription_addListener(_delegate, listener);
132 }
147 if (listener == nullptr)
148 throw LightstreamerError("Argument cannot be null");
149 Subscription_removeListener(_delegate, listener);
150 }
157 std::vector<SubscriptionListener*> getListeners() {
158 return Subscription_getListeners(_delegate);
159 }
175 bool isActive() {
176 return Subscription_isActive(_delegate);
177 }
192 return Subscription_isSubscribed(_delegate);
193 }
201 std::string getDataAdapter() {
202 return Subscription_getDataAdapter(_delegate);
203 }
231 void setDataAdapter(const std::string& dataAdapter) {
232 Subscription_setDataAdapter(_delegate, &dataAdapter);
233 }
242 std::string getMode() {
243 return Subscription_getMode(_delegate);
244 }
254 std::vector<std::string> getItems() {
255 return Subscription_getItems(_delegate);
256 }
273 void setItems(const std::vector<std::string>& items) {
274 Subscription_setItems(_delegate, &items);
275 }
283 std::string getItemGroup() {
284 return Subscription_getItemGroup(_delegate);
285 }
301 void setItemGroup(const std::string& group) {
302 Subscription_setItemGroup(_delegate, &group);
303 }
311 std::vector<std::string> getFields() {
312 return Subscription_getFields(_delegate);
313 }
330 void setFields(const std::vector<std::string>& fields) {
331 Subscription_setFields(_delegate, &fields);
332 }
340 std::string getFieldSchema() {
341 return Subscription_getFieldSchema(_delegate);
342 }
358 void setFieldSchema(const std::string& schema) {
359 Subscription_setFieldSchema(_delegate, &schema);
360 }
372 return Subscription_getRequestedBufferSize(_delegate);
373 }
405 void setRequestedBufferSize(const std::string& size) {
406 Subscription_setRequestedBufferSize(_delegate, &size);
407 }
417 std::string getRequestedSnapshot() {
418 return Subscription_getRequestedSnapshot(_delegate);
419 }
456 void setRequestedSnapshot(const std::string& snapshot) {
457 Subscription_setRequestedSnapshot(_delegate, &snapshot);
458 }
470 return Subscription_getRequestedMaxFrequency(_delegate);
471 }
530 void setRequestedMaxFrequency(const std::string& frequency) {
531 Subscription_setRequestedMaxFrequency(_delegate, &frequency);
532 }
541 std::string getSelector() {
542 return Subscription_getSelector(_delegate);
543 }
560 void setSelector(const std::string& selector) {
561 Subscription_setSelector(_delegate, &selector);
562 }
577 return Subscription_getCommandPosition(_delegate);
578 }
593 return Subscription_getKeyPosition(_delegate);
594 }
605 return Subscription_getCommandSecondLevelAdapter(_delegate);
606 }
634 void setCommandSecondLevelDataAdapter(const std::string& dataAdapter) {
635 Subscription_setCommandSecondLevelDataAdapter(_delegate, &dataAdapter);
636 }
647 std::vector<std::string> getCommandSecondLevelFields() {
648 return Subscription_getCommandSecondLevelFields(_delegate);
649 }
687 void setCommandSecondLevelFields(const std::vector<std::string>& fields) {
688 Subscription_setCommandSecondLevelFields(_delegate, &fields);
689 }
701 return Subscription_getCommandSecondLevelFieldSchema(_delegate);
702 }
735 void setCommandSecondLevelFieldSchema(const std::string& schema) {
736 Subscription_setCommandSecondLevelFieldSchema(_delegate, &schema);
737 }
757 std::string getValue(const std::string& itemName, const std::string& fieldName) {
758 return Subscription_getValueSS(_delegate, &itemName, &fieldName);
759 }
782 std::string getValue(int itemPos, int fieldPos) {
783 return Subscription_getValueII(_delegate, itemPos, fieldPos);
784 }
806 std::string getValue(const std::string& itemName, int fieldPos) {
807 return Subscription_getValueSI(_delegate, &itemName, fieldPos);
808 }
830 std::string getValue(int itemPos, const std::string& fieldName) {
831 return Subscription_getValueIS(_delegate, itemPos, &fieldName);
832 }
853 std::string getCommandValue(const std::string& itemName, const std::string& keyValue, const std::string& fieldName) {
854 return Subscription_getCommandValueSS(_delegate, &itemName, &keyValue, &fieldName);
855 }
879 std::string getCommandValue(int itemPos, const std::string& keyValue, int fieldPos) {
880 return Subscription_getCommandValueII(_delegate, itemPos, &keyValue, fieldPos);
881 }
903 std::string getCommandValue(const std::string& itemName, const std::string& keyValue, int fieldPos) {
904 return Subscription_getCommandValueSI(_delegate, &itemName, &keyValue, fieldPos);
905 }
928 std::string getCommandValue(int itemPos, const std::string& keyValue, const std::string& fieldName) {
929 return Subscription_getCommandValueIS(_delegate, itemPos, &keyValue, &fieldName);
930 }
931};
932
933} // namespace Lightstreamer
934
935#endif // INCLUDED_Lightstreamer_Subscription
Facade class for the management of the communication to Lightstreamer Server.
Definition LightstreamerClient.h:49
The LightstreamerError class provides a base class for exceptions thrown by the library.
Definition LightstreamerError.h:27
Class representing a Subscription to be submitted to a Lightstreamer Server.
Definition Subscription.h:71
std::string getValue(const std::string &itemName, int fieldPos)
Returns the latest value received for the specified item/field pair.
Definition Subscription.h:806
void setCommandSecondLevelDataAdapter(const std::string &dataAdapter)
Setter method that sets the name of the second-level Data Adapter (within the Adapter Set used by the...
Definition Subscription.h:634
void setSelector(const std::string &selector)
Setter method that sets the selector name for all the items in the Subscription.
Definition Subscription.h:560
void setRequestedMaxFrequency(const std::string &frequency)
Setter method that sets the maximum update frequency to be requested to Lightstreamer Server for all ...
Definition Subscription.h:530
Subscription(const std::string &mode, const std::vector< std::string > &items, const std::vector< std::string > &fields)
Creates an object to be used to describe a Subscription that is going to be subscribed to through Lig...
Definition Subscription.h:108
std::string getRequestedMaxFrequency()
Inquiry method that can be used to read the max frequency, configured through setRequestedMaxFrequenc...
Definition Subscription.h:469
std::string getItemGroup()
Inquiry method that can be used to read the item group specified for this Subscription.
Definition Subscription.h:283
std::string getCommandValue(const std::string &itemName, const std::string &keyValue, const std::string &fieldName)
Returns the latest value received for the specified item/key/field combination.
Definition Subscription.h:853
std::string getFieldSchema()
Inquiry method that can be used to read the field schema specified for this Subscription.
Definition Subscription.h:340
void setDataAdapter(const std::string &dataAdapter)
Setter method that sets the name of the Data Adapter (within the Adapter Set used by the current sess...
Definition Subscription.h:231
void addListener(SubscriptionListener *listener)
Adds a listener that will receive events from the Subscription instance.
Definition Subscription.h:128
std::string getSelector()
Inquiry method that can be used to read the selector name specified for this Subscription through s...
Definition Subscription.h:541
std::string getCommandSecondLevelFieldSchema()
Inquiry method that can be used to read the "Field Schema" specified for second-level Subscriptions.
Definition Subscription.h:700
void setRequestedBufferSize(const std::string &size)
Setter method that sets the length to be requested to Lightstreamer Server for the internal queuing b...
Definition Subscription.h:405
int getCommandPosition()
Returns the position of the "command" field in a COMMAND Subscription.
Definition Subscription.h:576
std::string getMode()
Inquiry method that can be used to read the mode specified for this Subscription.
Definition Subscription.h:242
std::vector< std::string > getCommandSecondLevelFields()
Inquiry method that can be used to read the "Field List" specified for second-level Subscriptions.
Definition Subscription.h:647
bool isSubscribed()
Inquiry method that checks if the Subscription is currently subscribed to through the server or not.
Definition Subscription.h:191
void setCommandSecondLevelFields(const std::vector< std::string > &fields)
Setter method that sets the "Field List" to be subscribed to through Lightstreamer Server for the sec...
Definition Subscription.h:687
std::string getValue(const std::string &itemName, const std::string &fieldName)
Returns the latest value received for the specified item/field pair.
Definition Subscription.h:757
std::string getCommandValue(int itemPos, const std::string &keyValue, const std::string &fieldName)
Returns the latest value received for the specified item/key/field combination.
Definition Subscription.h:928
void setItemGroup(const std::string &group)
Setter method that sets the "Item Group" to be subscribed to through Lightstreamer Server.
Definition Subscription.h:301
std::vector< std::string > getItems()
Inquiry method that can be used to read the "Item List" specified for this Subscription.
Definition Subscription.h:254
std::string getValue(int itemPos, const std::string &fieldName)
Returns the latest value received for the specified item/field pair.
Definition Subscription.h:830
void removeListener(SubscriptionListener *listener)
Removes a listener from the Subscription instance so that it will not receive events anymore.
Definition Subscription.h:146
void setItems(const std::vector< std::string > &items)
Setter method that sets the "Item List" to be subscribed to through Lightstreamer Server.
Definition Subscription.h:273
std::string getCommandValue(const std::string &itemName, const std::string &keyValue, int fieldPos)
Returns the latest value received for the specified item/key/field combination.
Definition Subscription.h:903
std::vector< SubscriptionListener * > getListeners()
Returns a list containing the SubscriptionListener instances that were added to this client.
Definition Subscription.h:157
std::string getCommandSecondLevelDataAdapter()
Inquiry method that can be used to read the second-level Data Adapter name configured through setComm...
Definition Subscription.h:604
int getKeyPosition()
Returns the position of the "key" field in a COMMAND Subscription.
Definition Subscription.h:592
void setFields(const std::vector< std::string > &fields)
Setter method that sets the "Field List" to be subscribed to through Lightstreamer Server.
Definition Subscription.h:330
std::string getRequestedSnapshot()
Inquiry method that can be used to read the snapshot preferences, configured through setRequestedSnap...
Definition Subscription.h:417
std::string getDataAdapter()
Inquiry method that can be used to read the name of the Data Adapter specified for this Subscription ...
Definition Subscription.h:201
void setFieldSchema(const std::string &schema)
Setter method that sets the "Field Schema" to be subscribed to through Lightstreamer Server.
Definition Subscription.h:358
std::string getValue(int itemPos, int fieldPos)
Returns the latest value received for the specified item/field pair.
Definition Subscription.h:782
std::vector< std::string > getFields()
Inquiry method that can be used to read the "Field List" specified for this Subscription.
Definition Subscription.h:311
std::string getCommandValue(int itemPos, const std::string &keyValue, int fieldPos)
Returns the latest value received for the specified item/key/field combination.
Definition Subscription.h:879
void setCommandSecondLevelFieldSchema(const std::string &schema)
Setter method that sets the "Field Schema" to be subscribed to through Lightstreamer Server for the s...
Definition Subscription.h:735
void setRequestedSnapshot(const std::string &snapshot)
Setter method that enables/disables snapshot delivery request for the items in the Subscription.
Definition Subscription.h:456
bool isActive()
Inquiry method that checks if the Subscription is currently "active" or not.
Definition Subscription.h:175
std::string getRequestedBufferSize()
Inquiry method that can be used to read the buffer size, configured though setRequestedBufferSize,...
Definition Subscription.h:371
Interface to be implemented to listen to Subscription events comprehending notifications of subscript...
Definition SubscriptionListener.h:33