aja::ElementItem Class Reference

Basic class for elements. More...

#include <ElementItem.h>

Inheritance diagram for aja::ElementItem:

aja::Item aja::ElementData aja::ElementNumber aja::ElementParent aja::ElementString List of all members.

Public Member Functions

 ElementItem (number_t element_id, elementType_t type)
 construct basic element
virtual ~ElementItem ()
 destructor free all allocated memory like added attributes, data etc..
elementType_t getElementType ()
 Function return type of element(PARENT, STRING etc..
number_t getElementId ()
 Function return element's ID.
void clearAttributes ()
 function clear all attributes in element
AttributeItemcreateStrAttribute (const byte_t attr_id, const char *attr_text)
 Function create string attribute in element.
AttributeItemcreateNumAttribute (const byte_t attr_id, number_t attr_num)
 Function create NUMBER attribute in element.
bool addAttribute (AttributeItem *attr)
 function add attribute into element
byte_t getAttributesCount ()
 function retun count of attributes in element
AttributeItemgetAttribute (byte_t id)
 Function return pointer to attribute of current id.
std::string getAttributeStr (byte_t id)
 Function return text value of attribute in element.
int getAttributeNum (byte_t id)
 Function return number of attribute like int.
ElementItemgetParent ()
 Function return pointer to parent element.
void setParent (ElementItem *parent)
 Function set parent of this element.
virtual bool buildAja (OutputBuffer &out)
 Function build ElementItem AJA binary form.
virtual number_t getItemSize ()
 function return complete size of element item(size of header + size of atributes + data size)
virtual number_t getChildsCount ()
 Function return count of child elements under this element.
virtual number_t getChildsCount (number_t id)
 Function return count of child elements with current ID under this element.
virtual ElementItemgetChild (unsigned int index)
 Function return child element at index position.
virtual ElementItemgetChildByID (number_t id)
 Function return child element with current ID.
virtual bool parseElmData (const buffer_t buffer, unsigned int size, unsigned int &pos)=0
 Function is called when is needed parsed data part of element.
virtual std::string getElementContent ()=0
 Function return element content like a string.

Static Public Member Functions

static ElementItemparseElement (const buffer_t buffer, unsigned int size, unsigned int &pos)
 this is main element-parsing process.

Protected Attributes

elementType_t mElementType
 element type (can be DATA, STRING, NUMBER etc)
number_t mElementId: 24
 24bit number representing element ID
byte_t mAttributesCount
 count of attributes in element
attributeArray_t mAttributes
 attributes associative array
ElementItemmParent
 pointer to parent element

Detailed Description

Basic class for elements.

This class contain methods for manipulating with attributes, parsing attributes, lement ID etc and abstract function parseElmData.Child classes have code for parsing data part in this function.


Constructor & Destructor Documentation

aja::ElementItem::ElementItem number_t  element_id,
elementType_t  type
 

construct basic element

Parameters:
element_id ID of element
type type of element(see elementType_t)

aja::ElementItem::~ElementItem  )  [virtual]
 

destructor free all allocated memory like added attributes, data etc..


Member Function Documentation

bool aja::ElementItem::addAttribute AttributeItem attr  ) 
 

function add attribute into element

Function add attribute pointer to array of attributes in class.

Parameters:
attr pointer to attribute class
Returns:
true when attribute was added, false when error occured

bool aja::ElementItem::buildAja OutputBuffer out  )  [virtual]
 

Function build ElementItem AJA binary form.

In this function is implemented build process of every ElementItem child like ElementNumber, ElementParent etc.

Parameters:
out Into this class is written AJA binary result of building process.
Returns:
true id ok, false when error was occurred

Implements aja::Item.

Reimplemented in aja::ElementData, aja::ElementNumber, aja::ElementParent, and aja::ElementString.

void aja::ElementItem::clearAttributes  ) 
 

function clear all attributes in element

Function free all attributes from memory heap.

AttributeItem * aja::ElementItem::createNumAttribute const byte_t  attr_id,
number_t  attr_num
 

Function create NUMBER attribute in element.

This function create AttributeNumber element with current id and value.When is attribute correctly created, then is added into Element.

Parameters:
attr_id id of new created attribute
attr_num 32 unsigned number
Returns:
pointer to new created element.When is error occured, then is returned NULL.

AttributeItem * aja::ElementItem::createStrAttribute const byte_t  attr_id,
const char *  attr_text
 

Function create string attribute in element.

This function create AttributeData element with current id and value.When is attribute correctly created, then is added into Element.

Parameters:
attr_id id of new created attribute
attr_text pointer to value who is copied into attribute
Returns:
pointer to new created element.When is error occured, then is returned NULL.

AttributeItem * aja::ElementItem::getAttribute byte_t  id  ) 
 

Function return pointer to attribute of current id.

Returns:
Pointer to attribute, when attribute don't exist in element or is occured some error then is return NULL.

int aja::ElementItem::getAttributeNum byte_t  id  ) 
 

Function return number of attribute like int.

This function check when exist attribute with id and convert his value to number when is possible.When attribute is not number, then is returned 0.

Parameters:
id is ID of attribute in element
Returns:
when is possible then is returned int number, otherwise is returned 0

byte_t aja::ElementItem::getAttributesCount  ) 
 

function retun count of attributes in element

Returns:
count of attributes

string aja::ElementItem::getAttributeStr byte_t  id  ) 
 

Function return text value of attribute in element.

This function check when exist attribute with id in element and then call his getValueStr().This function fill into res variable string form of attribute's data.

Parameters:
id is ID of attribute in element
Returns:
string representation of attribute value, when attribute with id dont exist, is returned empty string.

ElementItem * aja::ElementItem::getChild unsigned int  index  )  [virtual]
 

Function return child element at index position.

Parameters:
index index of element
Returns:
pointer to child element at index.When dont exist, then is returned NULL.

Reimplemented in aja::ElementParent.

ElementItem * aja::ElementItem::getChildByID number_t  id  )  [virtual]
 

Function return child element with current ID.

Parameters:
id ID of element
Returns:
pointer to child element at index.When dont exist, then is returned NULL.

Reimplemented in aja::ElementParent.

number_t aja::ElementItem::getChildsCount number_t  id  )  [virtual]
 

Function return count of child elements with current ID under this element.

Parameters:
id ID of child elements
Returns:
count of child elements with current id

Reimplemented in aja::ElementParent.

number_t aja::ElementItem::getChildsCount  )  [virtual]
 

Function return count of child elements under this element.

Returns:
count of child elements

Reimplemented in aja::ElementParent.

virtual std::string aja::ElementItem::getElementContent  )  [pure virtual]
 

Function return element content like a string.

Into this function is necessary puting code who return string form of content.

Returns:
content like string

Implemented in aja::ElementData, aja::ElementNumber, aja::ElementParent, and aja::ElementString.

number_t aja::ElementItem::getElementId  ) 
 

Function return element's ID.

Returns:
element's ID like 24 bit unisgned number

elementType_t aja::ElementItem::getElementType  ) 
 

Function return type of element(PARENT, STRING etc..

Returns:
type of element

number_t aja::ElementItem::getItemSize  )  [virtual]
 

function return complete size of element item(size of header + size of atributes + data size)

Returns:
size of element in bytes

Implements aja::Item.

Reimplemented in aja::ElementData, aja::ElementNumber, aja::ElementParent, and aja::ElementString.

ElementItem * aja::ElementItem::getParent  ) 
 

Function return pointer to parent element.

Returns:
pointer to parent, when is NULL then element dont have parent

Reimplemented from aja::Item.

ElementItem * aja::ElementItem::parseElement const buffer_t  buffer,
unsigned int  size,
unsigned int &  pos
[static]
 

this is main element-parsing process.

Function take a data, check it when is valid, parse it and create element(using Factory) instance by data.Function parse element's attributes too.After parsing function set into pos position in buffer after parsed data.

Parameters:
buffer buffer contained data to parse
size size of buffer
pos actual position in buffer
Returns:
pointer to new created element, NULL when some error was occured.

virtual bool aja::ElementItem::parseElmData const buffer_t  buffer,
unsigned int  size,
unsigned int &  pos
[pure virtual]
 

Function is called when is needed parsed data part of element.

Into this function put your own code for parsing data part of element. This function take pointer to data(buffer contain data to parse), size of data and reference to position in data buffer.Where parsing is finish into pos reference parameter function put position after parsing.

Parameters:
buffer data buffer for parsing
size size of buffer
pos Position in buffer.This is input and output variable.After parsing contain position in buffer where end parsed data and at begin contain start position in buffer where parsing start.
Returns:
true - ok, false - error in parsing

Implemented in aja::ElementData, aja::ElementNumber, aja::ElementParent, and aja::ElementString.

void aja::ElementItem::setParent ElementItem parent  ) 
 

Function set parent of this element.

Parameters:
parent pointer to parent element


Member Data Documentation

attributeArray_t aja::ElementItem::mAttributes [protected]
 

attributes associative array

byte_t aja::ElementItem::mAttributesCount [protected]
 

count of attributes in element

number_t aja::ElementItem::mElementId [protected]
 

24bit number representing element ID

elementType_t aja::ElementItem::mElementType [protected]
 

element type (can be DATA, STRING, NUMBER etc)

ElementItem* aja::ElementItem::mParent [protected]
 

pointer to parent element

Reimplemented from aja::Item.


The documentation for this class was generated from the following files:
Generated on Sun Mar 4 00:30:37 2007 for LIBAJA by  doxygen 1.4.6