AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.0.2
AMPS::MessageStream Class Reference

An iterable object representing the contents of an AMPS topic. More...

#include <ampsplusplus.hpp>

Classes

class  iterator
 Represents an iterator over messages in an AMPS topic. More...
 

Public Member Functions

bool isValid () const
 Returns true if self is a valid stream that may be iterated.
 
iterator begin (void)
 Returns an iterator representing the beginning of the topic or subscription. More...
 
iterator end (void)
 Returns an iterator representing the end of the topic or subscription. More...
 

Detailed Description

An iterable object representing the contents of an AMPS topic.

Objects of MesageStream type are returned by the MessageStream-returning overloads of methods on class AMPS::Client, such as AMPS::Client::sow() and AMPS::Client::subscribe() . Use this object via the begin() and end() iterators returned, for example:

MessageStream myTopic = client.sow("orders");
for(auto i = myTopic.begin(), e = myTopic.end(); i!=e; ++i)
{
Message m = *i;
... // (work with the contents of m)
}

For MessageStream objects returned by calls to methods other than sow(), note that the "end" is never reached, unless the server is disconnected. In this case, you may choose to stop processing messages by simply exiting the loop, i.e.:

MessageStream myTopic = client.subscribe("aTopic");
for(auto i = myTopic.begin();; ++i)
{
Message m = *i;
... // do work with *i
if(imDone) break;
}

Member Function Documentation

iterator AMPS::MessageStream::begin ( void  )
inline

Returns an iterator representing the beginning of the topic or subscription.

Returns
An iterator representing the beginning of this topic.
iterator AMPS::MessageStream::end ( void  )
inline

Returns an iterator representing the end of the topic or subscription.

Returns
An iterator representing the ending of this topic or subscription.

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