seven bits

bit::FieldBase Class Reference
["Record Definitions"]

#include <bit/fieldbase.h>

Inheritance diagram for bit::FieldBase:

bit::Field bit::FieldVector::Element bit::RecordBase bit::RecordVector::Element bit::FieldVector bit::Record bit::RecordVector

List of all members.


Detailed Description

FieldBase serves as a top level parent providing the concepts of a starting offset within a buffer, a length value, and units associated with each.

Todo:
Put in some type of check to ensure validity of a set type, or defer until access???
Author:
Rick L. Vinyard, Jr.

Public Types

typedef BitPointer< FieldBasepointer
 A convenience typedef to a smart pointer to FieldBase.

Public Member Functions

 FieldBase ()
 Default constructor.
virtual ~FieldBase ()
 Destructor.
virtual size_t length () const =0
virtual size_t length (size_t units) const
virtual size_t length_units () const =0
 Returns the length units.
virtual int offset () const =0
virtual int offset (size_t units) const
virtual size_t offset_units () const =0
 Returns the offset units.
virtual int start (size_t units=BITS) const
virtual std::string name () const =0
 Returns the string name associated with this object.
virtual std::string name (int depth) const
virtual size_t depth () const
virtual std::string description () const =0
 Returns the string description of this object.
virtual const FieldTypetype () const =0
 Returns a FieldType object that describes how the field data should be interpreted.
virtual void set_type (const FieldType &)=0
 Sets the FieldType object describing how the field data should be interpreted.
virtual Encoding encoding () const =0
 Return the data encoding type.
virtual void set_encoding (Encoding en)=0
 Set the data encoding type.
virtual const std::string & xml ()=0
virtual bool operator< (const FieldBase &other) const
 Compares the starting bit position of objects.
virtual bool operator> (const FieldBase &other) const
 Compares the ending bit position of objects.
virtual FieldBase::pointer clone ()=0
virtual iterator begin ()
virtual iterator end ()
virtual FieldBaseoperator[] (std::string s) throw ( exception::invalid_container_op, std::out_of_range )
virtual FieldBaseoperator[] (size_t i) throw ( exception::invalid_container_op, std::out_of_range )
virtual size_t subfields ()
 Returns the number of subfields within this field object.
virtual FieldBase::pointer subfield (const std::string &s)
 Default implementation returns a null pointer.
virtual FieldBase::pointer subfield (size_t i)
 Default implementation returns a null pointer.
FieldBaseparent ()
virtual Container container_type ()=0

Protected Member Functions

virtual FieldBase::pointer previous_field (FieldBase::pointer current_field) throw ( exception::invalid_container_op )
virtual FieldBase::pointer next_field (FieldBase::pointer current_field) throw ( exception::invalid_container_op )

Protected Attributes

FieldBasem_parent
std::string m_xml

Friends

class RecordStorage
class RecordVector

Classes

class  iterator
 This is a generalized interator that performs all operations using the generalized container methods in the FieldBase class. More...

Member Typedef Documentation

typedef BitPointer<FieldBase> bit::FieldBase::pointer


Constructor & Destructor Documentation

bit::FieldBase::FieldBase (  ) 

Default constructor.

bit::FieldBase::~FieldBase (  )  [virtual]

Destructor.


Member Function Documentation

virtual size_t bit::FieldBase::length (  )  const [pure virtual]

size_t bit::FieldBase::length ( size_t  units  )  const [virtual]

Returns:
the length of this object in the supplied units
Whether the object is specified in bits or octets, length(BITS) will always return the length in bits and length(OCTETS) will always return the length in octets.

When the length in bits is not evenly divisible by the requested unit size (say a 12 bit offset with requested units = 8) the return value will be the number of units required to store the object. For example, if the object has a 12 bit offset and the units parameter = OCTETS, the return value will be 2.

Reimplemented in bit::Field, bit::FieldVector::Element, bit::FieldVector, bit::Record, bit::RecordVector::Element, and bit::RecordVector.

References length(), length_units(), and WHOLE_UNITS.

virtual size_t bit::FieldBase::length_units (  )  const [pure virtual]

virtual int bit::FieldBase::offset (  )  const [pure virtual]

Returns:
the offset of this object in the offset units of this object

Implemented in bit::Field, bit::FieldVector::Element, bit::RecordBase, and bit::RecordVector::Element.

Referenced by bit::RecordBase::offset(), bit::FieldVector::Element::offset(), offset(), bit::Field::offset(), and start().

int bit::FieldBase::offset ( size_t  units  )  const [virtual]

Returns:
the offset of this object in the specified offset units
This method can be used to get the offset as a specified unit size regardless of the currently set offset unit size of this object.

When the offset size in bits is not evenly divisible by the requested unit size (say a 12 bit offset with requested units = 8) the return value will be the number of units required to complete the offset. For example, if the object has a 12 bit offset and the units parameter = 8, the return value will be 2. If the units were the same, but the offset were -12 bits the return value would be -2.

Reimplemented in bit::Field, bit::FieldVector::Element, bit::RecordBase, and bit::RecordVector::Element.

References offset(), offset_units(), and WHOLE_UNITS.

virtual size_t bit::FieldBase::offset_units (  )  const [pure virtual]

int bit::FieldBase::start ( size_t  units = BITS  )  const [virtual]

Returns:
the starting position of this object in the specified units
This method will return the starting position of this object in the specified units, which defaults to bits. The returned value will also account for the offset of the parent object (if this object has a parent).

When the offset size in bits is not evenly divisible by the requested unit size (say a 12 bit offset with requested units = 8) the return value will be the number of units required to complete the offset. For example, if the object has a 12 bit offset and the units parameter = 8, the return value will be 2. If the units were the same, but the offset were -12 bits the return value would be -2.

References bit::BITS, m_parent, offset(), start(), and WHOLE_UNITS.

Referenced by operator<(), operator>(), and start().

virtual std::string bit::FieldBase::name (  )  const [pure virtual]

Returns the string name associated with this object.

This pure virtual method is reimplemented by children to provide the proper notation, such as the array notation of elements, by children.

Implemented in bit::Field, bit::FieldVector::Element, bit::RecordBase, and bit::RecordVector::Element.

Referenced by bit::RecordVector::Element::name(), bit::RecordBase::name(), bit::FieldVector::Element::name(), name(), and bit::Field::name().

std::string bit::FieldBase::name ( int  depth  )  const [virtual]

size_t bit::FieldBase::depth (  )  const [virtual]

References depth(), and m_parent.

Referenced by depth().

virtual std::string bit::FieldBase::description (  )  const [pure virtual]

virtual const FieldType& bit::FieldBase::type (  )  const [pure virtual]

Returns a FieldType object that describes how the field data should be interpreted.

Implemented in bit::Field, bit::FieldVector::Element, bit::RecordBase, and bit::RecordVector::Element.

Referenced by bit::RecordVector::Element::type(), and bit::FieldVector::Element::type().

virtual void bit::FieldBase::set_type ( const FieldType  )  [pure virtual]

Sets the FieldType object describing how the field data should be interpreted.

Implemented in bit::Field, bit::FieldVector::Element, bit::RecordBase, and bit::RecordVector::Element.

Referenced by bit::RecordVector::Element::set_type(), and bit::FieldVector::Element::set_type().

virtual Encoding bit::FieldBase::encoding (  )  const [pure virtual]

virtual void bit::FieldBase::set_encoding ( Encoding  en  )  [pure virtual]

virtual const std::string& bit::FieldBase::xml (  )  [pure virtual]

bool bit::FieldBase::operator< ( const FieldBase other  )  const [virtual]

Compares the starting bit position of objects.

This overload is provided to allow easy sorting of objects according to their starting bit position.

Returns:
true if this object's starting bit is less than the other object's starting bit

References bit::BITS, length(), and start().

bool bit::FieldBase::operator> ( const FieldBase other  )  const [virtual]

Compares the ending bit position of objects.

This overload is provided to allow easy sorting of objects according to position of their last bit.

Returns:
true if this object's starting bit is less than the other object's starting bit

References bit::BITS, length(), and start().

virtual FieldBase::pointer bit::FieldBase::clone (  )  [pure virtual]

FieldBase::iterator bit::FieldBase::begin (  )  [virtual]

FieldBase::iterator bit::FieldBase::end (  )  [virtual]

FieldBase & bit::FieldBase::operator[] ( std::string  s  )  throw ( exception::invalid_container_op, std::out_of_range ) [virtual]

References subfield().

FieldBase & bit::FieldBase::operator[] ( size_t  i  )  throw ( exception::invalid_container_op, std::out_of_range ) [virtual]

References subfield().

size_t bit::FieldBase::subfields (  )  [virtual]

Returns the number of subfields within this field object.

Reimplemented in bit::FieldVector, bit::Record, bit::RecordVector::Element, and bit::RecordVector.

FieldBase::pointer bit::FieldBase::subfield ( const std::string &  s  )  [virtual]

Default implementation returns a null pointer.

Reimplemented in bit::FieldVector, bit::Record, bit::RecordVector::Element, and bit::RecordVector.

Referenced by operator[]().

FieldBase::pointer bit::FieldBase::subfield ( size_t  i  )  [virtual]

Default implementation returns a null pointer.

Reimplemented in bit::FieldVector, bit::Record, bit::RecordVector::Element, and bit::RecordVector.

FieldBase* bit::FieldBase::parent (  )  [inline]

References m_parent.

virtual Container bit::FieldBase::container_type (  )  [pure virtual]

FieldBase::pointer bit::FieldBase::previous_field ( FieldBase::pointer  current_field  )  throw ( exception::invalid_container_op ) [protected, virtual]

FieldBase::pointer bit::FieldBase::next_field ( FieldBase::pointer  current_field  )  throw ( exception::invalid_container_op ) [protected, virtual]


Friends And Related Function Documentation

friend class RecordStorage [friend]

friend class RecordVector [friend]

Reimplemented in bit::RecordVector::Element.


Member Data Documentation

std::string bit::FieldBase::m_xml [protected]


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

Generated on Mon Nov 3 10:50:01 2008 for bit by doxygen 1.5.6