Skip to content

Commit

Permalink
Merge branch 'ui-multiplayer' of https://github.com/skyjake/Doomsday-…
Browse files Browse the repository at this point in the history
…Engine into oculus-refactor
  • Loading branch information
skyjake committed Feb 24, 2014
2 parents aec179a + 0a76a1c commit 5278913
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 174 deletions.
1 change: 1 addition & 0 deletions doomsday/libdeng2/data.pri
Expand Up @@ -114,6 +114,7 @@ SOURCES += \
src/data/bank.cpp \
src/data/binarytree_wrapper.cpp \
src/data/bitfield.cpp \
src/data/bitfield_elements.cpp \
src/data/block.cpp \
src/data/blockvalue.cpp \
src/data/byteorder.cpp \
Expand Down
94 changes: 78 additions & 16 deletions doomsday/libdeng2/include/de/data/bitfield.h
Expand Up @@ -30,6 +30,9 @@ namespace de {
/**
* Array of integer values packed tightly together.
*
* Before a BitField can be used, its elements must be defined with
* BitField::setElements().
*
* @ingroup data
*/
class DENG2_PUBLIC BitField
Expand All @@ -42,51 +45,110 @@ class DENG2_PUBLIC BitField
};
typedef QSet<Id> Ids;

/**
* Metadata about the elements of a bit field.
*/
class Elements
{
public:
Elements();

Elements(Spec const *elements, dsize count);

/**
* Adds a new element into the field.
*
* @param id Identifier of the element.
* @param numBits Number of bits for the element.
*
* @return Reference to this pack.
*/
Elements &add(Id id, dsize numBits);

void add(Spec const *elements, dsize count);

void add(QList<Spec> const &elements);

void clear();

/**
* Returns the number of elements.
*/
int size() const;

Spec at(int index) const;

void elementLayout(Id const &id, int &firstBit, int &numBits) const;

/**
* Total number of bits in the packed elements.
*/
int bitCount() const;

/**
* Returns the identifiers of all elements.
*/
Ids ids() const;

/**
* Returns the ids of all elements that are entirely or partially laid out on
* byte # @a index.
*
* @param index Index of the byte.
*
* @return Element ids.
*/
Ids idsLaidOutOnByte(int index) const;

private:
DENG2_PRIVATE(d)
};

/// Failure to compare two fields with each other. @ingroup errors
DENG2_ERROR(ComparisonError);

public:
BitField();
BitField(Elements const &elements);
BitField(BitField const &other);
BitField(Block const &data);

BitField &operator = (BitField const &other);

/**
* Removes all the elements and the data contained in the bit field.
* Sets the elements of the bit field.
*
* @param elements Elements metadata. BitField does not take ownership, so this must
* exist as long as the bit field is in use.
*/
void clear();
void setElements(Elements const &elements);

Elements const &elements() const;

/**
* Adds a new element into the field.
*
* @param id Identifier of the element.
* @param numBits Number of bits for the element.
*
* @return Reference to this pack.
* Removes all the elements and the data contained in the bit field. Elements must be
* redefined with setElements() after calling this.
*/
BitField &addElement(Id id, dsize numBits);

void addElements(Spec const *elements, dsize count);
void clear();

void addElements(QList<Spec> const &elements);
bool isEmpty() const;

/**
* Returns the number of elements in the bit field.
*/
int size() const;
//int size() const;

Spec element(int index) const;
//Spec element(int index) const;

/**
* Total number of bits in the packed elements.
*/
int bitCount() const;
//int bitCount() const;

/**
* Returns the identifiers of all elements.
*/
Ids elementIds() const;
//Ids elementIds() const;

/**
* Returns the packed data as an array of bytes. Only bitCount() bits are
Expand Down

0 comments on commit 5278913

Please sign in to comment.