Home Libraries Author Links

stm::tools::BinMessage< ContextT > Class Template Reference
[BinMsg: Abstract Binary Message Model]

Inheritance diagram for stm::tools::BinMessage< ContextT >:

Inheritance graph
[legend]
Collaboration diagram for stm::tools::BinMessage< ContextT >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<class ContextT>
class stm::tools::BinMessage< ContextT >

Binary message scanning from a stm::byte_iterator_range.

ContextT shall be a specialization of BinMessageContext or be publicly derived therefrom. Therefore ContextT is a BinMessage<ContextT> factory and those types derived from BaseMessage<ContextT> registered as BinMessage<ContextT> types are known to that factory (see BinMessageContext::registerMessageType()).

Definition at line 404 of file binmsg.hpp.


Public Types

enum  
 Bitwise orable flag bits. More...
enum  
 Status values. More...
typedef ContextT context_type
 Context type of the messages to be scanned.
typedef BaseMessage< ContextT > basemessage_type
 Common base type of all message types registered for the factory.
typedef basemessage_type::Timestamp Timestamp
 Timestamp type.

Public Member Functions

 BinMessage (const byte *first, const byte *last, context_type &context, dword flags=NoFlags) throw (std::exception)
 Construct a BinMessage object from the range [first, last) read from context.
virtual ~BinMessage ()
 Virtual destructor to allow polymorphic class hierarchies.
const std::string & type () const
 Return the message type string.
dword flags () const
 Returns the flags of the message.
dword status () const
 Returns the status of the message.
const Timestamptimestamp () const
 Returns a reference to the message's Timestamp.
const byte_iterator_rangebody () const
 Returns the byte range consisting of the message's body excluding any padding bytes.
context_typecontext ()
 Returns the the message's context.

Member Typedef Documentation

template<class ContextT>
typedef ContextT stm::tools::BinMessage< ContextT >::context_type

Context type of the messages to be scanned.

Definition at line 413 of file binmsg.hpp.

template<class ContextT>
typedef BaseMessage<ContextT> stm::tools::BinMessage< ContextT >::basemessage_type

Common base type of all message types registered for the factory.

Definition at line 416 of file binmsg.hpp.

template<class ContextT>
typedef basemessage_type::Timestamp stm::tools::BinMessage< ContextT >::Timestamp

Timestamp type.

Definition at line 419 of file binmsg.hpp.


Member Enumeration Documentation

template<class ContextT>
anonymous enum

Bitwise orable flag bits.

Definition at line 422 of file binmsg.hpp.

template<class ContextT>
anonymous enum

Status values.

Definition at line 429 of file binmsg.hpp.


Constructor & Destructor Documentation

template<class ContextT>
stm::tools::BinMessage< ContextT >::BinMessage ( const byte *  first,
const byte *  last,
context_type context,
dword  flags = NoFlags 
) throw (std::exception)

Construct a BinMessage object from the range [first, last) read from context.

If a binary message consisting of one of the binary message types registered for the binary message factory of BinMessageContext begins with first and fits completely into the supplied range [first, last), the constructor succeeds. Then the method status() returns BinMessage::NoError, the method begin() returns first, the method end() returns a byte pointer to the byte after the possibly padded end of the message and the method body() returns the byte range consisting of the message's body excluding any padding bytes.

Else if the flags bit BinMessage::ThrowOnError is not set, status () returns BinMessage::OutOfSync or BinMessage::ConsistencyError, begin() returns first, end() returns a byte pointer to the next plausible begin of a message and body() returns the offended byte range which may be empty. If the flags bit BinMessage::ThrowOnError is set, the construcor throws std::runtime_error in these cases.

On other errors the constructor throws std::logic_error, if one of the arguments supplied is wrong, or std::range_error, if a binary message potentially begins with first, but does not fit completely into the range [first, last).

template<class ContextT>
virtual stm::tools::BinMessage< ContextT >::~BinMessage (  )  [virtual]

Virtual destructor to allow polymorphic class hierarchies.


Member Function Documentation

template<class ContextT>
const std::string& stm::tools::BinMessage< ContextT >::type (  )  const

Return the message type string.

template<class ContextT>
dword stm::tools::BinMessage< ContextT >::flags (  )  const

Returns the flags of the message.

template<class ContextT>
dword stm::tools::BinMessage< ContextT >::status (  )  const

Returns the status of the message.

template<class ContextT>
const Timestamp& stm::tools::BinMessage< ContextT >::timestamp (  )  const

Returns a reference to the message's Timestamp.

template<class ContextT>
const byte_iterator_range& stm::tools::BinMessage< ContextT >::body (  )  const

Returns the byte range consisting of the message's body excluding any padding bytes.

template<class ContextT>
context_type& stm::tools::BinMessage< ContextT >::context (  ) 

Returns the the message's context.


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).