ucc::bitmap Class Reference

A class to access bit fields in external bitmaps. More...

#include <bitmap.h>


Public Types

enum  bus_t {
  BMALLOC, B8, B16, B32,
  B64, BMIN = BMALLOC, BMAX = B64
}
 Specify data word size to use in accessing a bitmap. More...

Public Member Functions

 bitmap (void *addr, size_t length, bus_t size=B8)
 Create an object to reference the specified bitmap.
 bitmap (size_t length)
 Create a bitmap to manipulate locally.
 ~bitmap ()
 Destroy bitmap manipulation object.
void clear (void)
 Clear (zero) all the bits in the bitmap.
bool get (size_t offset)
 Get the value of a "bit" in the bitmap.
void set (size_t offset, bool value)
 Set an individual bit in the bitmask.

Protected Member Functions

unsigned memsize (void)

Protected Attributes

size_t size
addr_t addr
bus_t bus


Detailed Description

A class to access bit fields in external bitmaps.

The actual bitmap this object manipulates may not be stored in the obect. Bitmaps may be referenced on special memory mapped or i/o bus based devices or other structures that have varying data word sizes which may differ from the default cpu bus size. The bitmap class can be set to the preferred memory bus size of the specific external bitmap being used. Bitmap size may also be relevant when accessing individual bits in memory mapped device registers where performing refence and manipulations may change the state of the device and hence must be aligned with the device register being effected.

This class offers only the most basic bit manipulations, getting and setting individual bits in the bitmap. More advanced bit manipulations and other operations can be created in derived classes.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 51 of file bitmap.h.


Member Enumeration Documentation

Specify data word size to use in accessing a bitmap.

Enumerator:
BMALLOC  Use default cpu size.
B8  Accessing a bitmap on 8 bit bus device.
B16  Accessing a bitmap on a 16 bit device.
B32  Accessing a bitmap on a 32 bit device.
B64  Accessing a bitmap on a 64 bit device.

Definition at line 71 of file bitmap.h.


Constructor & Destructor Documentation

ucc::bitmap::bitmap ( void *  addr,
size_t  length,
bus_t  size = B8 
)

Create an object to reference the specified bitmap.

Parameters:
addr of the bitmap in mapped memory.
length of the bitmap being accessed in bits.
size of the memory bus or manipulation to use.

ucc::bitmap::bitmap ( size_t  length  ) 

Create a bitmap to manipulate locally.

This bitmap is created as part of the object itself, and uses the BMALLOC bus mode.

Parameters:
length of bitmap to create in bits.

ucc::bitmap::~bitmap (  ) 

Destroy bitmap manipulation object.

If a bitmap was locally created with the alternate constructor, that bitmap will also be removed from memory.


Member Function Documentation

bool ucc::bitmap::get ( size_t  offset  ) 

Get the value of a "bit" in the bitmap.

Parameters:
offset to bit in map to get.
Returns:
true if bit is set.

void ucc::bitmap::set ( size_t  offset,
bool  value 
)

Set an individual bit in the bitmask.

Parameters:
offset to bit in map to change.
value to change specified bit to.


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

Generated on Tue Jul 28 21:43:46 2009 for UCommon by  doxygen 1.5.9