Streaming C++ API
DequeueResult.hpp
1// Copyright (c) 2004-2023 TIBCO Software Inc. All rights reserved.
2
3#ifndef DEQUEUE_RESULT_H
4#define DEQUEUE_RESULT_H
5
6#include "StreamBase.hpp"
7
8#include "StreamProperties.hpp"
9#include "Tuple.hpp"
10#include "TupleList.hpp"
11#include "StreamBaseURI.hpp"
12#include "StreamBaseConstants.hpp"
13
14SB_INTERNAL_FWD(DequeueResultUtil);
15
16SB_NAMESPACE_BEGIN;
17
18/// Null value encountered
19STREAMBASE_EXCEPTION_TYPE(ArgumentOutOfRange, sb_internal::Errors::NON_FATAL_ERROR);
20
21/// Encapsulates the data returned from a dequeue() operation.
22/// Contains a stream name and a list of tuples.
24public:
25#ifndef SWIG // not supported by SWIG, and not especially useful in scripting languages anyway
26 ///
27 /// A callback interface that can be implemented by an object that is associated with
28 /// a StreamBaseClient and which gets used in the course of dequeuing tuples.
29 ///
30 class Interceptor {
31 public:
32 /// SUPPRESSED is a flag used to signify that the results from processResult should
33 /// be suppressed.
35
36 virtual ~Interceptor() {}
37 ///
38 /// Take a DequeueResult and modify it. Returns the same object if
39 /// there are no changes. Returns SUPPRESSED if results should
40 /// be suppressed.
41 /// May return a different DequeueResult object.
42 ///
43 virtual DequeueResult processResult(const DequeueResult &results) {
44 // do nothing
45 return results;
46 }
47 };
48#endif
49
50 /// Possible Dequeue results status
51 enum Status {
52 UNINITIALIZED = 0,
53 GOOD = 1,
54 TIMEOUT = 2,
55 CLOSED = 3,
56 };
57
58 /// Default (null) Constructor
59 DequeueResult() : _status(UNINITIALIZED), _leadershipStatus(LEADER) {};
60
61 /// Create a Dequeue Result with a list of tuples, with the given LeadershipStatus
63 const TupleList& tuples,
64 const StreamBaseURI &serverURI,
65 LeadershipStatus _leadershipStatus);
66
67 virtual ~DequeueResult();
68
69 /// Currently a no-op maintained for backwards compatibility
70 /// @deprecated
71 void reuseTuple() { }
72
73 /// Return the status of this DequeueResult.
74 /// DequeueResult::GOOD means the DequeueResult contains tuples.
75 /// @return the status of this DequeueResult
77
78 /// Returns the name of the stream on which tuples were dequeued.
79 const std::string& getStreamName() const;
80
81 /// Returns the number of tuples dequeued.
82 int getTupleCount() const;
83
84 /// Returns the StreamProperties for this DequeueResult
86
87 /// Returns the index'th tuple.
88 const Tuple& getTuple(int index) const;
89
90 /// Returns the list of tuples
91 const TupleList& getTuples() const;
92
93 /// Return the leadership status of the server that produced this dequeue result.
94 LeadershipStatus getLeadershipStatus() const {
95 return _leadershipStatus;
96 }
97
98 /// return the server that produced these results
99 const StreamBaseURI &getServerURI() const {
100 return _serverURI;
101 }
102private:
103 /// create a DequeueResult with the given DequeueResult status and LeadershipStatus
104 DequeueResult(DequeueResult::Status status, LeadershipStatus leadershipStatus);
105
106 friend class sb_internal::DequeueResultUtil;
107
108 TupleList _tuples;
109 StreamProperties _props;
110 bool _isLogicalControlStreamMessage;
111 DequeueResult::Status _status;
112 LeadershipStatus _leadershipStatus;
113 StreamBaseURI _serverURI;
114};
115
116SB_NAMESPACE_END;
117#endif
118
Null value encountered.
Definition: DequeueResult.hpp:19
A callback interface that can be implemented by an object that is associated with a StreamBaseClient ...
Definition: DequeueResult.hpp:30
virtual DequeueResult processResult(const DequeueResult &results)
Take a DequeueResult and modify it.
Definition: DequeueResult.hpp:43
static const DequeueResult SUPPRESSED
SUPPRESSED is a flag used to signify that the results from processResult should be suppressed.
Definition: DequeueResult.hpp:34
Encapsulates the data returned from a dequeue() operation.
Definition: DequeueResult.hpp:23
void reuseTuple()
Currently a no-op maintained for backwards compatibility.
Definition: DequeueResult.hpp:71
const std::string & getStreamName() const
Returns the name of the stream on which tuples were dequeued.
DequeueResult()
Default (null) Constructor.
Definition: DequeueResult.hpp:59
DequeueResult(const StreamProperties &props, const TupleList &tuples, const StreamBaseURI &serverURI, LeadershipStatus _leadershipStatus)
Create a Dequeue Result with a list of tuples, with the given LeadershipStatus.
const TupleList & getTuples() const
Returns the list of tuples.
LeadershipStatus getLeadershipStatus() const
Return the leadership status of the server that produced this dequeue result.
Definition: DequeueResult.hpp:94
const DequeueResult::Status getStatus() const
Return the status of this DequeueResult.
int getTupleCount() const
Returns the number of tuples dequeued.
Status
Possible Dequeue results status.
Definition: DequeueResult.hpp:51
const Tuple & getTuple(int index) const
Returns the index'th tuple.
const StreamBaseURI & getServerURI() const
return the server that produced these results
Definition: DequeueResult.hpp:99
const StreamProperties & getStreamProperties() const
Returns the StreamProperties for this DequeueResult.
A URI for a StreamBase client connection.
Definition: StreamBaseURI.hpp:36
Properties of a single stream.
Definition: StreamProperties.hpp:17
TupleLists are value types that can be copied and modified seperately thus.
Definition: TupleList.hpp:17
Tuples are value types that can be copied and modified separately thus.
Definition: Tuple.hpp:47