Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DasherNode.h

Go to the documentation of this file.
00001 // DasherNode.h
00002 //
00004 //
00005 // Copyright (c) 2001-2002 David Ward
00006 //
00008 
00009 #ifndef __DasherNode_h__
00010 #define __DasherNode_h__
00011 
00012 #include "NoClones.h"
00013 #include "DasherTypes.h"
00014 #include "LanguageModel.h"
00015 
00016 namespace Dasher {class CDasherNode;}
00017 class Dasher::CDasherNode : private NoClones
00018 {
00019         // CDasherNode represents a rectangle and character 
00020         // nodes have children, siblings and parents
00021 private:
00022         const unsigned int m_iLbnd,m_iHbnd;// the cumulative lower and upper bound prob relative to parent
00023         const unsigned int m_iGroup;       // group membership - e.g. 0=nothing 1=caps 2=punc
00024         unsigned int m_iChars, m_iAge;
00025         bool m_bAlive;                     // if true, then display node, else dont bother
00026         bool m_bControlNode;               // if true, node is a control node
00027         bool m_bControlChild;              // if true, node is offspring of a control node
00028         //bool m_Cscheme;                  // color scheme for the node - alternates through relatives
00029         Opts::ColorSchemes m_ColorScheme;
00030         int m_iPhase;                      // index for coloring
00031         int m_iColour;                     // for the advanced colour mode
00032         
00033         const symbol m_Symbol;             // the character to display
00034         CLanguageModel *m_languagemodel;   // pointer to the language model - in future, could be different for each node       
00035         CDasherNode **m_Children;          // pointer to array of children
00036         CDasherNode *m_parent;             // pointer to parent - only needed to grab parent context
00037         CLanguageModel::CNodeContext *m_context;
00038 public:
00039         
00040         CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, Opts::ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour);
00041         ~CDasherNode();
00042         bool m_bForce;                     // flag to force a node to be drawn - shouldn't be public
00043     
00044         // return private data members - read only 
00045         CDasherNode ** const Children() const {return m_Children;}
00046         unsigned int Lbnd() const {return m_iLbnd;}
00047         bool Alive() {return m_bAlive;}
00048         bool Control() {return m_bControlChild;}
00049         void Kill()  {m_bAlive=0;m_iAge=0;}
00050         unsigned int Hbnd() const {return m_iHbnd;}
00051         unsigned int Group() const {return m_iGroup;}
00052         unsigned int Age() const {return m_iAge;}
00053         symbol Symbol() const {return m_Symbol;}
00054         unsigned int Chars() const {return m_iChars;}
00055         int Phase() const {return m_iPhase;}
00056         Opts::ColorSchemes Cscheme() const {return m_ColorScheme;}
00057         int Colour() const {return m_iColour;}
00058         
00059         CDasherNode* const Get_node_under(int,myint y1,myint y2,myint smousex,myint smousey); // find node under given co-ords
00060         void Get_string_under(const int,const myint y1,const myint y2,const myint smousex,const myint smousey,std::vector<symbol>&) const; // get string under given co-ords
00061         void Generic_Push_Node(CLanguageModel::CNodeContext *context);
00062         void Push_Node();                                      // give birth to children
00063         void Push_Node(CLanguageModel::CNodeContext *context); // give birth to children with this context
00064         void Delete_children();
00065         void Dump_node() const;                                // diagnostic
00066 };
00067 
00069 // Inline functions
00071 
00072 using namespace Dasher;
00073 using namespace Opts;
00074 
00076 
00077 inline CDasherNode::CDasherNode(CDasherNode *parent,symbol Symbol, unsigned int igroup, int iphase, ColorSchemes ColorScheme,int ilbnd,int ihbnd,CLanguageModel *lm, int Colour=0) :
00078           m_iLbnd(ilbnd),
00079           m_iHbnd(ihbnd),
00080           m_iGroup(igroup),
00081           m_iChars(0), 
00082           m_iAge(0), 
00083           m_bAlive(1), 
00084           m_bControlChild(false),
00085           m_ColorScheme(ColorScheme), 
00086           m_iPhase(iphase),
00087           m_iColour(Colour),
00088           m_Symbol(Symbol),
00089           m_languagemodel(lm),
00090           m_Children(0), 
00091           m_parent(parent),
00092           m_context(0),  
00093           m_bForce(false)
00094 {
00095         /*
00096         switch (ColorScheme) {
00097                 case Nodes1:
00098                         m_ColorScheme = Nodes2;
00099                         break;
00100                 case Nodes2:
00101                         m_ColorScheme = Nodes1;
00102                         break;
00103                 case Special1:
00104                         m_ColorScheme = Special2;
00105                         break;
00106                 case Special2:
00107                         m_ColorScheme = Special1;
00108                         break;
00109                 case default:
00110                         m_ColorScheme = ColorScheme;
00111                         break;
00112         }
00113         */
00114 }
00115 
00117 
00118 inline void CDasherNode::Delete_children() 
00119 {
00120         if (m_Children) {
00121                 unsigned int i; 
00122                 for (i=1;i<m_iChars;i++)
00123                         delete m_Children[i];
00124                 delete [] m_Children;
00125         }
00126         m_Children=0;
00127         
00128 }
00129 
00131 
00132 inline CDasherNode::~CDasherNode() 
00133 {
00134         Delete_children();
00135         if (m_context)
00136                 m_languagemodel->ReleaseNodeContext(m_context);
00137 }
00138 
00140 
00141 #endif /* #ifndef __DasherNode_h__ */

Generated on Sat Nov 5 16:16:00 2005 for OPIE by  doxygen 1.4.2