torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::bitstream::Frame< WORD_TYPE > Class Template Reference

Bitstream frame. More...

#include <Frame.hpp>

Public Types

typedef WORD_TYPE word_t
 Frame word type. More...
 

Public Member Functions

 Frame (uint32_t inLength, word_t *inWords=0)
 Basic constructor. More...
 
 ~Frame (void)
 
uint32_t getLength (void) const
 Returns the length of the frame in words. More...
 
const word_tgetWords (void) const
 Returns a const raw word pointer. More...
 
bool isUsed (void) const
 Returns a non-const raw word pointer. More...
 
bool isDirty (void) const
 Returns true if the frame has been modified, or false otherwise. More...
 
void setUsed (bool inIsUsed=true)
 Marks the frame used or unused, and if unused automatically marks it clean. More...
 
void setDirty (bool inIsDirty=true)
 Marks the frame dirty or clean, and if dirty automatically marks it used. More...
 
word_t operator[] (int index)
 Returns the specified frame word, or 0 if out of bounds. More...
 
void setWord (int index, word_t inWord)
 Sets the value of the specified frame word. More...
 

Protected Types

typedef boost::uint32_t uint32_t
 Imported type name. More...
 

Protected Attributes

bool mIsUsed
 Flag to indicate whether the frame is in use. More...
 
bool mIsDirty
 Flag to indicate whether the frame has been modified. More...
 
uint32_t mLength
 Frame length in words. More...
 
WORD_TYPE * mWords
 Array of frame words. More...
 

Detailed Description

template<typename WORD_TYPE>
class torc::bitstream::Frame< WORD_TYPE >

Bitstream frame.

Definition at line 31 of file Frame.hpp.

Member Typedef Documentation

template<typename WORD_TYPE >
typedef boost::uint32_t torc::bitstream::Frame< WORD_TYPE >::uint32_t
protected

Imported type name.

Definition at line 35 of file Frame.hpp.

template<typename WORD_TYPE >
typedef WORD_TYPE torc::bitstream::Frame< WORD_TYPE >::word_t

Frame word type.

Definition at line 48 of file Frame.hpp.

Constructor & Destructor Documentation

template<typename WORD_TYPE >
torc::bitstream::Frame< WORD_TYPE >::Frame ( uint32_t  inLength,
word_t inWords = 0 
)
inline

Basic constructor.

Definition at line 51 of file Frame.hpp.

51  : mIsUsed(true), mIsDirty(false),
52  mLength(inLength) {
53  if(inWords && inLength) {
54  mWords = new word_t[inLength];
55  word_t* p = mWords;
56  for(uint32_t i = 0; i < inLength; i++) *p++ = *inWords++;
57  } else {
58  mWords = 0;
59  }
60  }
bool mIsUsed
Flag to indicate whether the frame is in use.
Definition: Frame.hpp:38
WORD_TYPE * mWords
Array of frame words.
Definition: Frame.hpp:44
uint32_t mLength
Frame length in words.
Definition: Frame.hpp:42
bool mIsDirty
Flag to indicate whether the frame has been modified.
Definition: Frame.hpp:40
boost::uint32_t uint32_t
Imported type name.
Definition: Frame.hpp:35
WORD_TYPE word_t
Frame word type.
Definition: Frame.hpp:48
template<typename WORD_TYPE >
torc::bitstream::Frame< WORD_TYPE >::~Frame ( void  )
inline

Definition at line 61 of file Frame.hpp.

61  {
62  if(mWords) delete mWords;
63  mWords = 0;
64  }
WORD_TYPE * mWords
Array of frame words.
Definition: Frame.hpp:44

Member Function Documentation

template<typename WORD_TYPE >
uint32_t torc::bitstream::Frame< WORD_TYPE >::getLength ( void  ) const
inline

Returns the length of the frame in words.

Definition at line 67 of file Frame.hpp.

67 { return mLength; }
uint32_t mLength
Frame length in words.
Definition: Frame.hpp:42

+ Here is the caller graph for this function:

template<typename WORD_TYPE >
const word_t* torc::bitstream::Frame< WORD_TYPE >::getWords ( void  ) const
inline

Returns a const raw word pointer.

Definition at line 69 of file Frame.hpp.

69 { return mWords; }
WORD_TYPE * mWords
Array of frame words.
Definition: Frame.hpp:44

+ Here is the caller graph for this function:

template<typename WORD_TYPE >
bool torc::bitstream::Frame< WORD_TYPE >::isDirty ( void  ) const
inline

Returns true if the frame has been modified, or false otherwise.

Definition at line 75 of file Frame.hpp.

75 { return mIsDirty; }
bool mIsDirty
Flag to indicate whether the frame has been modified.
Definition: Frame.hpp:40

+ Here is the caller graph for this function:

template<typename WORD_TYPE >
bool torc::bitstream::Frame< WORD_TYPE >::isUsed ( void  ) const
inline

Returns a non-const raw word pointer.

Returns true if the frame is in use in the bitstream, or false otherwise.

Definition at line 73 of file Frame.hpp.

73 { return mIsUsed; }
bool mIsUsed
Flag to indicate whether the frame is in use.
Definition: Frame.hpp:38

+ Here is the caller graph for this function:

template<typename WORD_TYPE >
word_t torc::bitstream::Frame< WORD_TYPE >::operator[] ( int  index)
inline

Returns the specified frame word, or 0 if out of bounds.

Definition at line 81 of file Frame.hpp.

81  {
82  if(mWords == 0 || index < 0 || static_cast<uint32_t>(index) >= mLength) return 0;
83  return mWords[index];
84  }
WORD_TYPE * mWords
Array of frame words.
Definition: Frame.hpp:44
uint32_t mLength
Frame length in words.
Definition: Frame.hpp:42
template<typename WORD_TYPE >
void torc::bitstream::Frame< WORD_TYPE >::setDirty ( bool  inIsDirty = true)
inline

Marks the frame dirty or clean, and if dirty automatically marks it used.

Definition at line 79 of file Frame.hpp.

79 { mIsDirty = inIsDirty; if(mIsDirty) mIsUsed = true; }
bool mIsUsed
Flag to indicate whether the frame is in use.
Definition: Frame.hpp:38
bool mIsDirty
Flag to indicate whether the frame has been modified.
Definition: Frame.hpp:40

+ Here is the caller graph for this function:

template<typename WORD_TYPE >
void torc::bitstream::Frame< WORD_TYPE >::setUsed ( bool  inIsUsed = true)
inline

Marks the frame used or unused, and if unused automatically marks it clean.

Definition at line 77 of file Frame.hpp.

77 { mIsUsed = inIsUsed; if(!mIsUsed) mIsDirty = false; }
bool mIsUsed
Flag to indicate whether the frame is in use.
Definition: Frame.hpp:38
bool mIsDirty
Flag to indicate whether the frame has been modified.
Definition: Frame.hpp:40
template<typename WORD_TYPE >
void torc::bitstream::Frame< WORD_TYPE >::setWord ( int  index,
word_t  inWord 
)
inline

Sets the value of the specified frame word.

Definition at line 86 of file Frame.hpp.

86  {
87  // do nothing if the index is out of bounds
88  if(index < 0 || static_cast<uint32_t>(index) >= mLength) return;
89  // allocate and zero out the words if they were previously unallocated
90  if(mWords == 0) {
91  mWords = new word_t[mLength];
92  word_t* p = mWords;
93  for(uint32_t i = 0; i < mLength; i++) *p++ = 0;
94  setDirty();
95  }
96  // if the new value is different, update the word and mark the frame dirty
97  if(mWords[index] != inWord) {
98  mWords[index] = inWord;
99  setDirty();
100  }
101  }
WORD_TYPE * mWords
Array of frame words.
Definition: Frame.hpp:44
void setDirty(bool inIsDirty=true)
Marks the frame dirty or clean, and if dirty automatically marks it used.
Definition: Frame.hpp:79
uint32_t mLength
Frame length in words.
Definition: Frame.hpp:42
boost::uint32_t uint32_t
Imported type name.
Definition: Frame.hpp:35
WORD_TYPE word_t
Frame word type.
Definition: Frame.hpp:48

+ Here is the call graph for this function:

Field Documentation

template<typename WORD_TYPE >
bool torc::bitstream::Frame< WORD_TYPE >::mIsDirty
protected

Flag to indicate whether the frame has been modified.

Definition at line 40 of file Frame.hpp.

template<typename WORD_TYPE >
bool torc::bitstream::Frame< WORD_TYPE >::mIsUsed
protected

Flag to indicate whether the frame is in use.

Definition at line 38 of file Frame.hpp.

template<typename WORD_TYPE >
uint32_t torc::bitstream::Frame< WORD_TYPE >::mLength
protected

Frame length in words.

Definition at line 42 of file Frame.hpp.

template<typename WORD_TYPE >
WORD_TYPE* torc::bitstream::Frame< WORD_TYPE >::mWords
protected

Array of frame words.

Definition at line 44 of file Frame.hpp.


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