Make your own free website on Tripod.com
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ComplexElement Class Reference

#include <element.h>

Inheritance diagram for ComplexElement:

Element List of all members.

Public Methods

 ComplexElement (const char *name, enum ComplexType type, Elements *elements)
 ~ComplexElement ()
int AssignPos (int currPos)
 Assign position to this element Return next pos. More...

void Process (ostream &out)
void Output (ostream &out, Element *sel)

Static Public Methods

ComplexElement * Find (const char *name)

Private Attributes

enum ComplexType type
std::auto_ptr< Elementselements

Static Private Attributes

std::map< std::string, ComplexElement * > all

Constructor & Destructor Documentation

ComplexElement::ComplexElement const char *    name,
enum ComplexType    type,
Elements   elements
 

Definition at line 72 of file element.h.

References all, ComplexType, and Element::name.

00073                                             :
00074 Element(_name),type(_type),elements(_elements)
00075 {
00076         all[name] = this;
00077 }

ComplexElement::~ComplexElement  
 

Definition at line 79 of file element.h.

References all, and Element::name.

00080 {
00081         all.erase(name);
00082 }


Member Function Documentation

int ComplexElement::AssignPos int    currPos [virtual]
 

Assign position to this element Return next pos.

Implements Element.

Definition at line 91 of file element.h.

References elements, Element::len, Element::position, type, and Union.

Referenced by Process().

00092 {
00093         position = currPos;
00094         
00095         Elements::TV::iterator i = elements->v.begin();
00096         Elements::TV::iterator end = elements->v.end();
00097         int pos = currPos;
00098         int maxPos = currPos;
00099         for(; i!= end;++i)
00100         {
00101                 pos = (*i)->AssignPos(pos);
00102                 if (type==Union)
00103                 {
00104                         // union, calc maximun for result and then reset
00105                         maxPos = maxPos > pos ? maxPos : pos;
00106                         pos = currPos;
00107                 }
00108                 else
00109                 {
00110                         maxPos = pos;
00111                 }
00112         }
00113         
00114         len = maxPos - position;
00115         
00116         return maxPos;
00117 }

ComplexElement * ComplexElement::Find const char *    name [static]
 

Definition at line 84 of file element.h.

References all, and Element::name.

Referenced by createDefinedElement().

00085 {
00086         if (all.find(name) == all.end())
00087                 return NULL;
00088         return all[name];
00089 }

void ComplexElement::Output ostream &    out,
Element   sel
[virtual]
 

Implements Element.

Definition at line 119 of file element.h.

References elements, Element::len, Element::name, and Element::position.

Referenced by DefinedElement::Output(), and Process().

00120 {
00121         Elements::TV::iterator i = elements->v.begin();
00122         Elements::TV::iterator end = elements->v.end();
00123         out << "Complex " << name << " pos:" << position << " len:" << len << " {" << endl;
00124         for(; i!= end;++i)
00125         {
00126                 (*i)->Output(out,NULL);
00127         }
00128         out << "};" << endl;
00129 }

void ComplexElement::Process ostream &    out
 

Definition at line 131 of file element.h.

References AssignPos(), and Output().

Referenced by processElement().

00132 {
00133         AssignPos(0);
00134         Output(out,NULL);
00135 }


Member Data Documentation

std::map< std::string, ComplexElement * > ComplexElement::all [static, private]
 

Definition at line 70 of file element.h.

Referenced by ComplexElement(), Find(), and ~ComplexElement().

std::auto_ptr<Elements> ComplexElement::elements [private]
 

Definition at line 66 of file element.h.

Referenced by AssignPos(), and Output().

enum ComplexType ComplexElement::type [private]
 

Definition at line 65 of file element.h.

Referenced by AssignPos().


The documentation for this class was generated from the following file:
Generated on Mon Jan 13 22:20:36 2003 for perdr by doxygen1.2.15