Overview Tutorial API reference Examples Build Download ZmqMessage 0.1 - 21 Oct 2011

ZmqMessage::Incoming< RoutingPolicy > Class Template Reference

Incoming multipart ZMQ message. More...

#include <ZmqMessage.hpp>

Inheritance diagram for ZmqMessage::Incoming< RoutingPolicy >:

ZmqMessage::Multipart ZmqMessage::Private::NonCopyable List of all members.

Public Types

typedef RoutingPolicy RoutingPolicyType

Public Member Functions

 Incoming (zmq::socket_t &sock)
zmq::socket_t & src ()
bool is_terminal () const
void check_is_terminal () const throw (MessageFormatError)
void validate (const char *part_names[], size_t part_names_length, bool strict) throw (MessageFormatError)
Incoming< RoutingPolicy > & receive (size_t parts, const char *part_names[], size_t part_names_length, bool check_terminal) throw (MessageFormatError, ZmqErrorType)
template<size_t N>
Incoming< RoutingPolicy > & receive (std::tr1::array< const char *, N > part_names, bool check_terminal) throw (MessageFormatError)
Incoming< RoutingPolicy > & receive (size_t parts, bool check_terminal) throw (MessageFormatError, ZmqErrorType)
Incoming< RoutingPolicy > & receive (size_t parts, const char *part_names[], bool check_terminal) throw (MessageFormatError, ZmqErrorType)
Incoming< RoutingPolicy > & receive_all (const size_t min_parts, const char *part_names[], size_t part_names_length) throw (MessageFormatError, ZmqErrorType)
Incoming< RoutingPolicy > & receive_all (const size_t min_parts, const char *part_names[]) throw (MessageFormatError, ZmqErrorType)
Incoming< RoutingPolicy > & receive_all () throw (MessageFormatError, ZmqErrorType)
Incoming< RoutingPolicy > & receive_all (const size_t min_parts) throw (MessageFormatError, ZmqErrorType)
Incoming< RoutingPolicy > & receive_up_to (size_t min_parts, const char *part_names[], size_t max_parts) throw (MessageFormatError, ZmqErrorType)
int fetch_tail (std::vector< char > &area, const char *delimiter=0) throw (ZmqErrorType)
int drop_tail () throw (ZmqErrorType)
template<typename T>
Incoming< RoutingPolicy > & operator>> (T &t) throw (NoSuchPartError)
Incoming< RoutingPolicy > & operator>> (zmq::message_t &msg) throw (NoSuchPartError)
Incoming< RoutingPolicy > & operator>> (Incoming< RoutingPolicy > &(*f)(Incoming< RoutingPolicy > &))
void set_binary ()
void set_text ()

Friends

class Outgoing
Incoming< RoutingPolicy > & Skip (Incoming< RoutingPolicy > &)
 Skip current message part in incoming message.

Detailed Description

template<class RoutingPolicy>
class ZmqMessage::Incoming< RoutingPolicy >

Incoming multipart ZMQ message.

RoutingPolicy either SimpleRouting or XRouting - rules for receiving routing info.

Examples:

zasync.cpp, zbisort.cpp, zqueue.cpp, zserialize.cpp, and zsort.cpp.


Member Typedef Documentation

template<class RoutingPolicy>
typedef RoutingPolicy ZmqMessage::Incoming< RoutingPolicy >::RoutingPolicyType


Constructor & Destructor Documentation

template<class RoutingPolicy>
ZmqMessage::Incoming< RoutingPolicy >::Incoming ( zmq::socket_t &  sock  )  [inline, explicit]


Member Function Documentation

template<class RoutingPolicy>
void ZmqMessage::Incoming< RoutingPolicy >::check_is_terminal (  )  const throw (MessageFormatError)

If received message is not already terminal (has no pending parts), throws MessageFormatError exception.

template<class RoutingPolicy>
int ZmqMessage::Incoming< RoutingPolicy >::drop_tail (  )  throw (ZmqErrorType)

Fetch all messages starting from tail message and drop them until there will be no more parts on socket.

Returns:
number of messages dropped (min 0)

template<class RoutingPolicy>
int ZmqMessage::Incoming< RoutingPolicy >::fetch_tail ( std::vector< char > &  area,
const char *  delimiter = 0 
) throw (ZmqErrorType)

Fetch all messages starting from tail message until there will be no more parts on socket. So the resulting data will be: { parts_[N-1] | message, ... }

Parameters:
area - result stored here
delimiter - null terminated string, inserted between parts
Returns:
number of messages in result (min 1)

template<class RoutingPolicy>
bool ZmqMessage::Incoming< RoutingPolicy >::is_terminal (  )  const [inline]

Returns:
true if we have detected, that no more message parts are accessible on socket (all parts are received).

template<class RoutingPolicy>
Incoming<RoutingPolicy>& ZmqMessage::Incoming< RoutingPolicy >::operator>> ( Incoming< RoutingPolicy > &(*)(Incoming< RoutingPolicy > &)  f  )  [inline]

Handle a manipulator

template<class RoutingPolicy>
Incoming< RoutingPolicy > & ZmqMessage::Incoming< RoutingPolicy >::operator>> ( zmq::message_t &  msg  )  throw (NoSuchPartError)

Extract following message part's content by copying it into given message

template<class RoutingPolicy>
template<typename T>
Incoming< RoutingPolicy > & ZmqMessage::Incoming< RoutingPolicy >::operator>> ( T &  t  )  throw (NoSuchPartError)

After we have received message parts, we can extract message parts content into variables, one by one. Message content is copied for types that actually hold data, not just wrap it.

template<class RoutingPolicy>
Incoming<RoutingPolicy>& ZmqMessage::Incoming< RoutingPolicy >::receive ( size_t  parts,
const char *  part_names[],
bool  check_terminal 
) throw (MessageFormatError, ZmqErrorType) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. assume size of part_names == parts

template<class RoutingPolicy>
Incoming<RoutingPolicy>& ZmqMessage::Incoming< RoutingPolicy >::receive ( size_t  parts,
bool  check_terminal 
) throw (MessageFormatError, ZmqErrorType) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Part names are omitted

template<class RoutingPolicy>
template<size_t N>
Incoming<RoutingPolicy>& ZmqMessage::Incoming< RoutingPolicy >::receive ( std::tr1::array< const char *, N >  part_names,
bool  check_terminal 
) throw (MessageFormatError) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class RoutingPolicy>
Incoming< RoutingPolicy > & ZmqMessage::Incoming< RoutingPolicy >::receive ( size_t  parts,
const char *  part_names[],
size_t  part_names_length,
bool  check_terminal 
) throw (MessageFormatError, ZmqErrorType)

Receive definite number of message parts.

Parameters:
parts number of parts to receive
part_names array of parts names for error reporting and debug purposes
part_names_length length of part_names array
check_terminal if true, message may contain not more then parts number of parts.

template<class RoutingPolicy>
Incoming<RoutingPolicy>& ZmqMessage::Incoming< RoutingPolicy >::receive_all ( const size_t  min_parts  )  throw (MessageFormatError, ZmqErrorType) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Part names are unknown.

template<class RoutingPolicy>
Incoming<RoutingPolicy>& ZmqMessage::Incoming< RoutingPolicy >::receive_all (  )  throw (MessageFormatError, ZmqErrorType) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. No minimum parts limit (may be 0)

template<class RoutingPolicy>
Incoming<RoutingPolicy>& ZmqMessage::Incoming< RoutingPolicy >::receive_all ( const size_t  min_parts,
const char *  part_names[] 
) throw (MessageFormatError, ZmqErrorType) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. assume size of part_names == min_parts

template<class RoutingPolicy>
Incoming< RoutingPolicy > & ZmqMessage::Incoming< RoutingPolicy >::receive_all ( const size_t  min_parts,
const char *  part_names[],
size_t  part_names_length 
) throw (MessageFormatError, ZmqErrorType)

Receives ALL messages available on socket. (min min_parts, max unbounded). Multipart message will be considered terminal.

template<class RoutingPolicy>
Incoming< RoutingPolicy > & ZmqMessage::Incoming< RoutingPolicy >::receive_up_to ( size_t  min_parts,
const char *  part_names[],
size_t  max_parts 
) throw (MessageFormatError, ZmqErrorType)

Receives up to max_parts messages available on socket (but not less than min_parts). Assume that length of part_names == min_parts

template<class RoutingPolicy>
void ZmqMessage::Incoming< RoutingPolicy >::set_binary (  )  [inline]

Set stream mode to Binary: all subsequent non-string data is extracted from ZMQ message as binary data See modes

template<class RoutingPolicy>
void ZmqMessage::Incoming< RoutingPolicy >::set_text (  )  [inline]

Set stream mode to Text (default): all subsequent non-string data is converted to string (by writing to stream) after being extracted from ZMQ message. See modes

template<class RoutingPolicy>
zmq::socket_t& ZmqMessage::Incoming< RoutingPolicy >::src (  )  [inline]

Returns:
zmq socket to receive message parts from

template<class RoutingPolicy>
void ZmqMessage::Incoming< RoutingPolicy >::validate ( const char *  part_names[],
size_t  part_names_length,
bool  strict 
) throw (MessageFormatError)

Validate that message contains definite number of message parts.

Parameters:
part_names array of parts names for error reporting and debug purposes
part_names_length length of part_names array
strict if true, message MUST contain exactly part_names_length parts. Otherwise it MUST contain at least part_names_length parts.


Friends And Related Function Documentation

template<class RoutingPolicy>
friend class Outgoing [friend]

template<class RoutingPolicy>
Incoming<RoutingPolicy>& Skip ( Incoming< RoutingPolicy > &  in  )  [friend]

Skip current message part in incoming message.

When passed to Incoming (operator >>) just skips current message and moves receive pointer to next one. Also, usual checking that current part exists is performed.


The documentation for this class was generated from the following files:
ZmqMessage 0.1 — open source software, support@zmqmessage.org