/// <summary>
        /// Parses value member of the realtimeobject
        /// </summary>
        /// <param name="in_element"></param>
        /// <param name="in_xml_stream"></param>
        /// <param name="in_parent"></param>
        internal void ParseValueMember(XPathNavigator in_element, TextReader in_xml_stream, object in_parent)
        {
            // get name
            m_name = XMLAttributeParser.ConvertAttributeToString(in_element, "Name", XMLAttributeParser.atObligatory);

            // get type
            m_member_type = TypeStringToMemberType(in_element.Name);

            // check type
            if (m_member_type == RealtimeObjectMember.MemberType.Unknown)
            {
                throw XMLParserBase.CreateXMLParseException(string.Format(ParserRealtimeObjectStringConstants.ErrorInvalidElementType, in_element.Name), in_element);
            }

            // get multiplier for fixed types
            if (RealtimeObjectMember.IsFixedMember(m_member_type))
            {
                m_fixed_multiplier = XMLAttributeParser.ConvertAttributeToInt(in_element, "Multiplier", XMLAttributeParser.atObligatory);
            }

            // store attributes for further processing
            XPathNavigator element = in_element.Clone();

            if (element.MoveToFirstAttribute())
            {
                m_attributes.Add(element.Name, element.Value);
            }

            while (element.MoveToNextAttribute())
            {
                m_attributes.Add(element.Name, element.Value);
            }
        }
Example #2
0
        /// <summary>
        /// Creates and adds new member to the object
        /// </summary>
        /// <param name="in_name"></param>
        /// <param name="in_member_type"></param>
        /// <returns></returns>
        public RealtimeObjectMember MemberCreate(string in_name, RealtimeObjectMember.MemberType in_member_type)
        {
            RealtimeObjectMember member = new RealtimeObjectMember(in_name, in_member_type);

            MemberAdd(member);

            return(member);
        }
Example #3
0
        /// <summary>
        /// Add all member from the parsed realtime object
        /// </summary>
        /// <param name="in_object"></param>
        public void CopyParsedMember(ParserRealtimeObject in_object)
        {
            foreach (ParserRealtimeObjectMember parsed_member in in_object.Members)
            {
                RealtimeObjectMember member = new RealtimeObjectMember(parsed_member);

                MemberAdd(member);
            }
        }
        /// <summary>
        /// Sets multiplier for fixed integer types
        /// </summary>
        /// <param name="in_multiplier"></param>
        public void SetFixedMultiplier(int in_multiplier)
        {
            if (!RealtimeObjectMember.IsFixedMember(m_member_type))
            {
                throw new ArgumentException("Fixed member type expected");
            }

            m_multiplier = in_multiplier;
        }
        /// <summary>
        /// Gets member binary size based on the type of the member
        /// </summary>
        /// <param name="in_member"></param>
        /// <returns></returns>
        static public int GetMemberSize(RealtimeObjectMember in_member)
        {
            switch (in_member.Type)
            {
            case MemberType.Unknown:
                throw new ArgumentException("Invalid member type");

            case MemberType.Int:
                return(4);

            case MemberType.Float:
                return(4);

            case MemberType.Int8:
                return(1);

            case MemberType.Int16:
                return(2);

            case MemberType.Int32:
                return(4);

            case MemberType.UInt8:
                return(1);

            case MemberType.UInt16:
                return(2);

            case MemberType.UInt32:
                return(4);

            case MemberType.Int8Fixed:
                return(1);

            case MemberType.UInt8Fixed:
                return(1);

            case MemberType.Int16Fixed:
                return(2);

            case MemberType.UInt16Fixed:
                return(2);

            case MemberType.Int32Fixed:
                return(4);

            case MemberType.UInt32Fixed:
                return(4);

            case MemberType.String:
                return(in_member.MaxStringLength);

            default:
                throw new ArgumentException("Invalid member type");
            }
        }
        private int m_max_string_length;  // length for fixed length strings

        #endregion

        #region · Constructor ·
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="in_name"></param>
        /// <param name="in_parent"></param>
        public RealtimeObjectMember(string in_name, MemberType in_type)
        {
            m_member_name       = in_name;
            m_member_type       = in_type;
            m_parent_object     = null;
            m_member_index      = -1;
            m_max_string_length = 0;

            m_binary_length = RealtimeObjectMember.GetMemberSize(this);
        }
Example #7
0
        /// <summary>
        /// Adds a new member to the object
        /// </summary>
        /// <param name="in_member"></param>
        public void MemberAdd(RealtimeObjectMember in_member)
        {
            int index;

            in_member.SetParentObject(this);

            m_members.Add(in_member);
            index = m_members.Count - 1;
            m_member_lookup.Add(in_member.Name, index);

            in_member.SetMemberIndex(index);
        }
Example #8
0
        /// <summary>
        /// Initializes member values to their default value
        /// </summary>
        internal void ObjectCreateEnd()
        {
            // convert object structure to the
            m_member_values = new object[2, m_members.Count];

            // create default values
            for (int i = 0; i < m_members.Count; i++)
            {
                m_member_values[0, i] = RealtimeObjectMember.CreateDefaultMemberObject(m_members[i].Type);
                m_member_values[1, i] = RealtimeObjectMember.CreateDefaultMemberObject(m_members[i].Type);
            }
        }
 /// <summary>
 /// Sets length of the fixed length string
 /// </summary>
 /// <param name="in_max_length"></param>
 public void SetMaxStringLength(int in_max_length)
 {
     m_max_string_length = in_max_length;
     m_binary_length     = RealtimeObjectMember.GetMemberSize(this);
 }