//======================================================================= /// <summary> /// Creates a driving property object using the XML describing the property. /// </summary> /// <param name="sXML">XML for the driving property containing the DDML type.</param> //======================================================================= public TCompDriver(String sXML) { TSDMLParser parser; XmlNode anode; String sBuf; sDescr = ""; sFullDescr = ""; parser = new TSDMLParser(sXML); anode = parser.firstElementChild(parser.rootNode(), "type"); initType = new TDDMLValue(parser, anode, ""); FName = parser.getAttrValue(parser.rootNode(), "name"); initType.Name = FName; sDescr = parser.getAttrValue(parser.rootNode(), "descr"); FMinConn = 1; // Default sBuf = parser.getAttrValue(parser.rootNode(), "minsrc"); if (sBuf.Trim().Length > 0) { FMinConn = Convert.ToInt32(sBuf); } FMaxConn = 1; // Default sBuf = parser.getAttrValue(parser.rootNode(), "maxsrc"); if (sBuf.Trim().Length > 0) { FMaxConn = Convert.ToInt32(sBuf); } anode = parser.firstElementChild(parser.rootNode(), "description"); if (anode != null) { sFullDescr = parser.getText(anode); } }
//============================================================================ /// <summary> /// Construct this object using the parser already created in the parent. Also /// use the dom node, baseNode to be the root node of the document for this /// new typed value. Can also specify the base type using sBaseType. /// </summary> /// <param name="parentParser">The parent's parser.</param> /// <param name="baseNode">DOM node to use as the root node.</param> /// <param name="sBaseType">Used to set the base type.</param> //============================================================================ public TInitValue(TSDMLParser parentParser, XmlNode baseNode, String sBaseType) : base(parentParser, baseNode, sBaseType) { //FMax = null; //FMin = null; FDefault = null; //required in this derived class buildType(parentParser, baseNode); //calls suitable virtual functions if (isArray()) // default array length is zero { setElementCount(0); } }
//========================================================================= /// <summary> /// Initialise the component's properties from the SDML init section. /// </summary> /// <param name="sdml">The SDML for the init section.</param> //========================================================================= public void setXML(string sdml) { XmlNode anode; TSDMLParser parser = new TSDMLParser(sdml); anode = parser.firstElementChild(parser.rootNode(), "init"); while (anode != null) { TSDMLValue sdmlVal = new TSDMLValue(parser, anode, ""); writeValue(sdmlVal.Name, sdmlVal); anode = parser.nextElementSibling(anode, "init"); } }
//======================================================================= /// <summary> /// Creates a component property from the XML description of a property. /// </summary> /// <param name="sXML">XML for the property containing the DDML type. e.g. /// <property name="name" access="read" init="F"> /// <type kind="string"><defval></defval> /// </type> /// </property> /// </param> //======================================================================= public TCompProperty(String sXML) { TSDMLParser parser; String access; XmlNode anode; //create a parser. (not very nice creating a second parser but....) parser = new TSDMLParser(sXML); anode = parser.firstElementChild(parser.rootNode(), "type"); InitValue = new TInitValue(parser, anode, ""); bRead = false; bWrite = false; bInit = false; sDescr = ""; sFullDescr = ""; Name = parser.getAttrValue(parser.rootNode(), "name"); InitValue.Name = Name; sDescr = parser.getAttrValue(parser.rootNode(), "descr"); access = parser.getAttrValue(parser.rootNode(), "access"); if (access == "both") { bRead = true; bWrite = true; } if ((access == "read") || (access.Length == 0)) { bRead = true; } if (access == "write") { bWrite = true; } if (parser.getAttrValue(parser.rootNode(), "init") == "T") { bInit = true; initialiseMembers(InitValue); } anode = parser.firstElementChild(parser.rootNode(), "description"); if (anode != null) { sFullDescr = parser.getText(anode); } }
//============================================================================ /// <summary> /// Construct this object using the parser already created in the parent. Also /// use the dom node, baseNode to be the root node of the document for this /// new typed value. Can also specify the base type using szBaseType. /// </summary> /// <param name="parentParser">The parent's parser.</param> /// <param name="baseNode">DOMNode to use as the root node.</param> /// <param name="sBaseType">Used to set the base type.</param> //============================================================================ public TDDMLValue(TSDMLParser parentParser, XmlNode baseNode, String sBaseType) : base(parentParser, baseNode, sBaseType) { //required in this derived class buildType(parentParser, baseNode); //calls suitable virtual functions }
//============================================================================ /// <summary> /// Construct this object using the parser already created in the parent. Also /// use the dom node, baseNode to be the root node of the document for this /// new typed value. Can also specify the base type using szBaseType. /// </summary> /// <param name="parentParser">Pointer to the parents parser.</param> /// <param name="baseNode">DOM node to use as the root node.</param> /// <param name="sBaseType">Used to set the base type.</param> //============================================================================ public TSDMLValue(TSDMLParser parentParser, XmlNode baseNode, String sBaseType) : base (parentParser, baseNode, sBaseType) { //required in this derived class buildType(parentParser, baseNode); //calls suitable virtual functions }
//============================================================================ /// <summary> /// Creates a 1-dimensional array of arbitrary type /// baseValue is used as a blue print only. /// </summary> /// <param name="arrayName">Name of the array.</param> /// <param name="baseValue">Blue print typed value.</param> /// <param name="noElements">Number of elements for the array.</param> //============================================================================ public TTypedValue(String arrayName, TTypedValue baseValue, int noElements) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = baseValue.FBaseType; parser = null; FData = null; FDataSize = 0; childTemplate = null; FUnit = ""; }
//============================================================================ /// <summary> /// Copy constructor. This constructor makes a copy of the source's structure. /// For specialised child classes, this constructor should be overriden. /// </summary> /// <param name="typedValue">Use this typed value as the source.</param> // N.Herrmann Apr 2002 //============================================================================ public TTypedValue(TTypedValue typedValue) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = typedValue.FBaseType; FData = null; FDataSize = 0; parser = null; //won't be using a parser here childTemplate = null; FUnit = ""; //Called in the derived classes because it calls virtual functions //initTypeCopy(typedValue) }
//============================================================================ /// <summary> /// Creates a one dimensional array of scalar items. /// </summary> /// <param name="sArrayName">Name of this array.</param> /// <param name="aBaseType">Set the base type of this array.</param> /// <param name="iNoElements">Create it with this number of elements.</param> // N.Herrmann Apr 2002 //============================================================================ public TTypedValue(String sArrayName, TBaseType aBaseType, int iNoElements) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = aBaseType; parser = null; FData = null; FDataSize = 0; childTemplate = null; Name = sArrayName; FUnit = ""; FIsScalar = false; FIsArray = true; FIsRecord = false; //Called in the derived classes because they call virtual functions //addScalar("", iBaseType); //calls suitable virtual function //setElementCount(iNoElements); }
//============================================================================ /// <summary> /// Creates a scalar of this aBaseType with sName. /// </summary> /// <param name="sName">Name of the scalar.</param> /// <param name="aBaseType">Base type of this scalar.</param> // N.Herrmann Apr 2002 //============================================================================ public TTypedValue(String sName, TBaseType aBaseType) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value FBaseType = aBaseType; //Called in the derived classes because it calls virtual functions //constructScalar(szName, iBaseType); //create a scalar type of TTypedValue parser = null; childTemplate = null; FUnit = ""; }
//============================================================================ /// <summary> /// Construct this object using the parser already created in the parent. Also /// use the dom node, baseNode to be the root node of the document for this /// new typed value. Can also specify the base type using sBaseType. /// </summary> /// <param name="parentParser">Pointer to the parents parser.</param> /// <param name="baseNode">DOM node to use as the root node.</param> /// <param name="sBaseType">Used to set the base type. See <see cref="sTYPECODES"/></param> // N.Herrmann Apr 2002 //============================================================================ public TTypedValue(TSDMLParser parentParser, XmlNode baseNode, String sBaseType) { ascii = new System.Text.ASCIIEncoding(); FMembers = new List<TTypedValue>(); //set the kind of this typed value setBaseType(sBaseType); parser = null; FData = null; FDataSize = 0; childTemplate = null; FUnit = ""; //Called in the derived classes because it calls virtual functions //buildType(parentParser, baseNode); }
//====================================================================== /// <summary> /// Uses the parents parser and the base node for this this type to build the /// type. Called by the descendant constructor. /// </summary> /// <param name="parentParser">Pointer to the parents parser.</param> /// <param name="baseNode">DOM Node to use as the root node.</param> // N.Herrmann Apr 2002 //====================================================================== protected void buildType(TSDMLParser parentParser, XmlNode baseNode) { XmlNode parentsNode; parser = parentParser; //use the parent's parser parentsNode = parentParser.rootNode(); //store parser.setTopNode(baseNode); parser.getDescription(); //gets the values from the dom into the parser fields getDescription(); //set the description fields from the parser parseType(); //do the parsing of this type parser = null; //has only been borrowed parentParser.setTopNode(parentsNode); //restore the topElement of the parser }
//====================================================================== /// <summary> /// Uses the xml text to build the type. Called by the descendant constructor. /// </summary> /// <param name="sXML">XML text description.</param> // N.Herrmann Apr 2002 //====================================================================== protected void buildType(String sXML) { parser = new TSDMLParser(sXML); //create a parser, also reads description fields getDescription(); //set the description fields from the parser parseType(); //do the parsing of this type }