Alchemy  1.0
A framework to robustly process network messages and structured data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Hg::Datum< Idx, format_t > Class Template Reference

A type-wrapper that provides transparent access to a range of memory in a message buffer as if it were the specified type itself. More...

#include <datum.h>

Inheritance diagram for Hg::Datum< Idx, format_t >:
Hg::detail::FieldTypes< FieldT, TraitT >

Public Types

typedef
detail::DefineFieldType< Idx,
format_t >::type 
field_type
 Type mapping for the message format type to the actual value_type.
 
typedef format_t format_type
 format of the parent TypeList.
 
typedef field_type::index_type index_type
 The type extracted at the current index defined in the parent TypeList.
 
typedef field_type::value_type value_type
 The data type managed by this Datum. This is the type of data that will be written to the attached buffer.
 
- Public Types inherited from Hg::detail::FieldTypes< FieldT, TraitT >
typedef FieldT index_type
 
        The type at the index of the

parent type container.

 
typedef field_data_t
< index_type >::value_type 
value_type
 
        The specified value type for 

the current Datum.

 

Public Member Functions

 Datum ()
 Default Constructor.
 
 Datum (Datum &datum)
 Copy Constructor. More...
 
void clear ()
 Zeros the datum.
 
bool equivalent (const value_type &rhs) const
 Indicates equivalency for a value_type and this Datum's value. More...
 
const value_typeget () const
 Returns the current value of this Datum. More...
 
value_typeget ()
 Returns a reference to the value managed in this datum.
 
bool less (const value_type &rhs) const
 Compares a value_type against this Datum's value for less-than relationship. More...
 
 operator value_type () const
 Operator to value_type. More...
 
bool operator!= (const value_type &rhs) const
 Inequality Value Comparison (value_type) More...
 
bool operator< (const value_type &rhs) const
 less Than Value Comparison (value_type) More...
 
bool operator<= (const value_type &rhs) const
 less Than or equal Value Comparison (value_type) More...
 
Datumoperator= (const Datum &rhs)
 Assignment Operator. More...
 
Datumoperator= (value_type rhs)
 Assignment Operator (value_type) More...
 
bool operator== (const value_type &rhs) const
 Equality Value Comparison (value_type) More...
 
bool operator> (const value_type &rhs) const
 Greater Than Value Comparison (value_type) More...
 
bool operator>= (const value_type &rhs) const
 Greater Than or equal Value Comparison (value_type) More...
 
void set (const value_type &value)
 Updates the value of this Datum. More...
 
- Public Member Functions inherited from Hg::detail::FieldTypes< FieldT, TraitT >
const value_typedata () const
 Returns the value of the data buffer.
 
void data (const value_type &value)
 Returns the value of the data buffer.
 
value_typereference ()
 Returns a reference to the internal data storage. More...
 

Static Public Attributes

static const size_t k_offset = OffsetOf<Idx, format_t>::value
 The offset in the buffer where this msg field is located.
 

Protected Member Functions

const value_typeget_data () const
 Returns the value of the data buffer.
 
value_typeget_reference ()
 Returns a reference to the internal data storage. More...
 
void set_data (const value_type &value)
 Returns the value of the data buffer.
 

Additional Inherited Members

- Protected Attributes inherited from Hg::detail::FieldTypes< FieldT, TraitT >
value_type m_data
 
            This is a local copy of the data

value to shadow the value held in the buffer.

 

Detailed Description

template<size_t Idx, typename format_t>
class Hg::Datum< Idx, format_t >

A type-wrapper that provides transparent access to a range of memory in a message buffer as if it were the specified type itself.

The Datum<> is intended to be used as if it were the direct field itself. All details of byte-order and memory-alignment are handled internally by the buffers the Datum<> instance is mapped to.

Parameters
Idx[size_t] The index of this element in the TypeList definition. Idx must be < length<T>::value.
format_t[typename] The TypeList that contains this elements definition. T must be an indexable type container.
Note
Parameterized type T is verified by the compiler to be A type container.

Definition at line 41 of file datum.h.

Constructor & Destructor Documentation

template<size_t Idx, typename format_t>
Hg::Datum< Idx, format_t >::Datum ( Datum< Idx, format_t > &  datum)
inline

Copy Constructor.

Makes a complete copy of an existing Datum object.

Parameters
datumA reference to the Another instance of a Datum.

Definition at line 88 of file datum.h.

Member Function Documentation

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::equivalent ( const value_type rhs) const
inline

Indicates equivalency for a value_type and this Datum's value.

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 289 of file datum.h.

template<size_t Idx, typename format_t>
const value_type& Hg::Datum< Idx, format_t >::get ( ) const
inline

Returns the current value of this Datum.

If a buffer is attached to this message field, the value will be read from the buffer. Otherwise the data will be returned. This const version will not update the data from the buffer.

Returns
The value of this Datum is returned. If a valid buffer is associated with this field, the data referenced in the buffer is returned. Otherwise the temporary locally cached value is returned.

Definition at line 256 of file datum.h.

template<size_t Idx, typename format_t>
value_type& Hg::Datum< Idx, format_t >::get_reference ( )
inlineprotected

Returns a reference to the internal data storage.

Returns a reference to the internal data storage managed by this Datum. The reference to the data can be useful, and necessary for

Definition at line 312 of file datum.h.

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::less ( const value_type rhs) const
inline

Compares a value_type against this Datum's value for less-than relationship.

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 300 of file datum.h.

template<size_t Idx, typename format_t>
Hg::Datum< Idx, format_t >::operator value_type ( ) const
inline

Operator to value_type.

Allows this Datum object to be converted to the value_type managed by this object. The value returned comes from the data buffer.

Returns
The current value of this object is returned.

Definition at line 162 of file datum.h.

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::operator!= ( const value_type rhs) const
inline

Inequality Value Comparison (value_type)

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 185 of file datum.h.

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::operator< ( const value_type rhs) const
inline

less Than Value Comparison (value_type)

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 196 of file datum.h.

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::operator<= ( const value_type rhs) const
inline

less Than or equal Value Comparison (value_type)

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 207 of file datum.h.

template<size_t Idx, typename format_t>
Datum& Hg::Datum< Idx, format_t >::operator= ( const Datum< Idx, format_t > &  rhs)
inline

Assignment Operator.

Allows assignment of the Datum value. Associated buffers are not changed through assignment.

Parameters
rhsA different instance of a Datum object whose value will be copied into this instance.

Definition at line 131 of file datum.h.

template<size_t Idx, typename format_t>
Datum& Hg::Datum< Idx, format_t >::operator= ( value_type  rhs)
inline

Assignment Operator (value_type)

Allows assignment to this Datum type from it's parameter type, value_type. This function is the key to allowing the Datum to behave as if the assignment was performed directly on the the managed type.

Parameters
rhsA value of the Datum value_type that will be used to directly modify the value of the object.

Definition at line 148 of file datum.h.

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::operator== ( const value_type rhs) const
inline

Equality Value Comparison (value_type)

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 174 of file datum.h.

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::operator> ( const value_type rhs) const
inline

Greater Than Value Comparison (value_type)

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 230 of file datum.h.

template<size_t Idx, typename format_t>
bool Hg::Datum< Idx, format_t >::operator>= ( const value_type rhs) const
inline

Greater Than or equal Value Comparison (value_type)

Parameters
rhsA value_type value to compare with the value of this instance.

Definition at line 219 of file datum.h.

template<size_t Idx, typename format_t>
void Hg::Datum< Idx, format_t >::set ( const value_type value)
inline

Updates the value of this Datum.

Parameters
valueThe value to assign to this object. The local cached value will be updated. If a buffer has been associated with this object, its data will be updated with the value as well.

Definition at line 278 of file datum.h.


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