Lightstreamer C++ Client SDK
Loading...
Searching...
No Matches
Subscription.h
1#ifndef INCLUDED_Lightstreamer_Subscription
2#define INCLUDED_Lightstreamer_Subscription
3
4#include "../Lightstreamer.h"
5#include "Lightstreamer/LightstreamerError.h"
6
7namespace Lightstreamer {
8
57 friend class LightstreamerClient;
58 HaxeObject _delegate;
59public:
60 Subscription() = delete;
61 Subscription(const Subscription&) = delete;
62 Subscription& operator=(const Subscription&) = delete;
63
93 Subscription(const std::string& mode, const std::vector<std::string>& items, const std::vector<std::string>& fields) {
94 _delegate = Subscription_new(&mode, &items, &fields, this);
95 }
96
98 Lightstreamer_releaseHaxeObject(_delegate);
99 }
114 if (listener == nullptr)
115 throw LightstreamerError("Argument cannot be null");
116 Subscription_addListener(_delegate, listener);
117 }
132 if (listener == nullptr)
133 throw LightstreamerError("Argument cannot be null");
134 Subscription_removeListener(_delegate, listener);
135 }
142 std::vector<SubscriptionListener*> getListeners() {
143 return Subscription_getListeners(_delegate);
144 }
160 bool isActive() {
161 return Subscription_isActive(_delegate);
162 }
177 return Subscription_isSubscribed(_delegate);
178 }
186 std::string getDataAdapter() {
187 return Subscription_getDataAdapter(_delegate);
188 }
216 void setDataAdapter(const std::string& dataAdapter) {
217 Subscription_setDataAdapter(_delegate, &dataAdapter);
218 }
227 std::string getMode() {
228 return Subscription_getMode(_delegate);
229 }
239 std::vector<std::string> getItems() {
240 return Subscription_getItems(_delegate);
241 }
258 void setItems(const std::vector<std::string>& items) {
259 Subscription_setItems(_delegate, &items);
260 }
268 std::string getItemGroup() {
269 return Subscription_getItemGroup(_delegate);
270 }
286 void setItemGroup(const std::string& group) {
287 Subscription_setItemGroup(_delegate, &group);
288 }
296 std::vector<std::string> getFields() {
297 return Subscription_getFields(_delegate);
298 }
315 void setFields(const std::vector<std::string>& fields) {
316 Subscription_setFields(_delegate, &fields);
317 }
325 std::string getFieldSchema() {
326 return Subscription_getFieldSchema(_delegate);
327 }
343 void setFieldSchema(const std::string& schema) {
344 Subscription_setFieldSchema(_delegate, &schema);
345 }
357 return Subscription_getRequestedBufferSize(_delegate);
358 }
390 void setRequestedBufferSize(const std::string& size) {
391 Subscription_setRequestedBufferSize(_delegate, &size);
392 }
402 std::string getRequestedSnapshot() {
403 return Subscription_getRequestedSnapshot(_delegate);
404 }
441 void setRequestedSnapshot(const std::string& snapshot) {
442 Subscription_setRequestedSnapshot(_delegate, &snapshot);
443 }
455 return Subscription_getRequestedMaxFrequency(_delegate);
456 }
515 void setRequestedMaxFrequency(const std::string& frequency) {
516 Subscription_setRequestedMaxFrequency(_delegate, &frequency);
517 }
526 std::string getSelector() {
527 return Subscription_getSelector(_delegate);
528 }
545 void setSelector(const std::string& selector) {
546 Subscription_setSelector(_delegate, &selector);
547 }
562 return Subscription_getCommandPosition(_delegate);
563 }
578 return Subscription_getKeyPosition(_delegate);
579 }
590 return Subscription_getCommandSecondLevelAdapter(_delegate);
591 }
619 void setCommandSecondLevelDataAdapter(const std::string& dataAdapter) {
620 Subscription_setCommandSecondLevelDataAdapter(_delegate, &dataAdapter);
621 }
632 std::vector<std::string> getCommandSecondLevelFields() {
633 return Subscription_getCommandSecondLevelFields(_delegate);
634 }
672 void setCommandSecondLevelFields(const std::vector<std::string>& fields) {
673 Subscription_setCommandSecondLevelFields(_delegate, &fields);
674 }
686 return Subscription_getCommandSecondLevelFieldSchema(_delegate);
687 }
720 void setCommandSecondLevelFieldSchema(const std::string& schema) {
721 Subscription_setCommandSecondLevelFieldSchema(_delegate, &schema);
722 }
742 std::string getValue(const std::string& itemName, const std::string& fieldName) {
743 return Subscription_getValueSS(_delegate, &itemName, &fieldName);
744 }
767 std::string getValue(int itemPos, int fieldPos) {
768 return Subscription_getValueII(_delegate, itemPos, fieldPos);
769 }
791 std::string getValue(const std::string& itemName, int fieldPos) {
792 return Subscription_getValueSI(_delegate, &itemName, fieldPos);
793 }
815 std::string getValue(int itemPos, const std::string& fieldName) {
816 return Subscription_getValueIS(_delegate, itemPos, &fieldName);
817 }
838 std::string getCommandValue(const std::string& itemName, const std::string& keyValue, const std::string& fieldName) {
839 return Subscription_getCommandValueSS(_delegate, &itemName, &keyValue, &fieldName);
840 }
864 std::string getCommandValue(int itemPos, const std::string& keyValue, int fieldPos) {
865 return Subscription_getCommandValueII(_delegate, itemPos, &keyValue, fieldPos);
866 }
888 std::string getCommandValue(const std::string& itemName, const std::string& keyValue, int fieldPos) {
889 return Subscription_getCommandValueSI(_delegate, &itemName, &keyValue, fieldPos);
890 }
913 std::string getCommandValue(int itemPos, const std::string& keyValue, const std::string& fieldName) {
914 return Subscription_getCommandValueIS(_delegate, itemPos, &keyValue, &fieldName);
915 }
916};
917
918} // namespace Lightstreamer
919
920#endif // INCLUDED_Lightstreamer_Subscription
Facade class for the management of the communication to Lightstreamer Server.
Definition LightstreamerClient.h:34
The LightstreamerError class provides a base class for exceptions thrown by the library.
Definition LightstreamerError.h:12
Class representing a Subscription to be submitted to a Lightstreamer Server.
Definition Subscription.h:56
std::string getValue(const std::string &itemName, int fieldPos)
Returns the latest value received for the specified item/field pair.
Definition Subscription.h:791
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:619
void setSelector(const std::string &selector)
Setter method that sets the selector name for all the items in the Subscription.
Definition Subscription.h:545
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:515
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:93
std::string getRequestedMaxFrequency()
Inquiry method that can be used to read the max frequency, configured through setRequestedMaxFrequenc...
Definition Subscription.h:454
std::string getItemGroup()
Inquiry method that can be used to read the item group specified for this Subscription.
Definition Subscription.h:268
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:838
std::string getFieldSchema()
Inquiry method that can be used to read the field schema specified for this Subscription.
Definition Subscription.h:325
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:216
void addListener(SubscriptionListener *listener)
Adds a listener that will receive events from the Subscription instance.
Definition Subscription.h:113
std::string getSelector()
Inquiry method that can be used to read the selector name specified for this Subscription through s...
Definition Subscription.h:526
std::string getCommandSecondLevelFieldSchema()
Inquiry method that can be used to read the "Field Schema" specified for second-level Subscriptions.
Definition Subscription.h:685
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:390
int getCommandPosition()
Returns the position of the "command" field in a COMMAND Subscription.
Definition Subscription.h:561
std::string getMode()
Inquiry method that can be used to read the mode specified for this Subscription.
Definition Subscription.h:227
std::vector< std::string > getCommandSecondLevelFields()
Inquiry method that can be used to read the "Field List" specified for second-level Subscriptions.
Definition Subscription.h:632
bool isSubscribed()
Inquiry method that checks if the Subscription is currently subscribed to through the server or not.
Definition Subscription.h:176
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:672
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:742
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:913
void setItemGroup(const std::string &group)
Setter method that sets the "Item Group" to be subscribed to through Lightstreamer Server.
Definition Subscription.h:286
std::vector< std::string > getItems()
Inquiry method that can be used to read the "Item List" specified for this Subscription.
Definition Subscription.h:239
std::string getValue(int itemPos, const std::string &fieldName)
Returns the latest value received for the specified item/field pair.
Definition Subscription.h:815
void removeListener(SubscriptionListener *listener)
Removes a listener from the Subscription instance so that it will not receive events anymore.
Definition Subscription.h:131
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:258
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:888
std::vector< SubscriptionListener * > getListeners()
Returns a list containing the SubscriptionListener instances that were added to this client.
Definition Subscription.h:142
std::string getCommandSecondLevelDataAdapter()
Inquiry method that can be used to read the second-level Data Adapter name configured through setComm...
Definition Subscription.h:589
int getKeyPosition()
Returns the position of the "key" field in a COMMAND Subscription.
Definition Subscription.h:577
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:315
std::string getRequestedSnapshot()
Inquiry method that can be used to read the snapshot preferences, configured through setRequestedSnap...
Definition Subscription.h:402
std::string getDataAdapter()
Inquiry method that can be used to read the name of the Data Adapter specified for this Subscription ...
Definition Subscription.h:186
void setFieldSchema(const std::string &schema)
Setter method that sets the "Field Schema" to be subscribed to through Lightstreamer Server.
Definition Subscription.h:343
std::string getValue(int itemPos, int fieldPos)
Returns the latest value received for the specified item/field pair.
Definition Subscription.h:767
std::vector< std::string > getFields()
Inquiry method that can be used to read the "Field List" specified for this Subscription.
Definition Subscription.h:296
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:864
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:720
void setRequestedSnapshot(const std::string &snapshot)
Setter method that enables/disables snapshot delivery request for the items in the Subscription.
Definition Subscription.h:441
bool isActive()
Inquiry method that checks if the Subscription is currently "active" or not.
Definition Subscription.h:160
std::string getRequestedBufferSize()
Inquiry method that can be used to read the buffer size, configured though setRequestedBufferSize,...
Definition Subscription.h:356
Interface to be implemented to listen to Subscription events comprehending notifications of subscript...
Definition SubscriptionListener.h:18