Example #1
0
        /// <summary>
        /// Creates a new feature ID that doesn't reference anything (and does not add it to the map model).
        /// </summary>
        /// <returns>The created feature ID.</returns>
        internal FeatureId CreateId()
        {
            IdPacket p = m_Group.FindPacket(m_Id);

            p.ReserveId(m_Id);
            return(p.CreateId(m_Id));
        }
Example #2
0
        /// <summary>
        /// Reserves a feature ID in a specific ID packet
        /// </summary>
        /// <devnote>This function is called by LoadIdCombo</devnote>
        /// <param name="packet">The ID packet containing the available ID.</param>
        /// <param name="ent">The entity type that the ID is for.</param>
        /// <param name="id">The available ID to reserve.</param>
        /// <returns>True if the ID was successfully reserved.</returns>
        internal bool ReserveId(IdPacket packet, IEntity ent, uint id)
        {
            // Ensure that any currently reserved ID is released.
            FreeReservedId();

            // Just get the packet to do it.
            if (packet.ReserveId(id))
            {
                m_Packet = packet;
                m_Id     = id;
                m_Entity = ent;
                return(true);
            }

            this.Reset();
            return(false);
        }
Example #3
0
        /// <summary>
        /// Reserves an ID belonging to this ID group.
        /// </summary>
        /// <param name="idh">The ID handle to define.</param>
        /// <param name="id">The specific ID to reserve. Specify 0 for the next
        /// available ID (in that case, an additional allocation will be made if
        /// necessary).</param>
        /// <returns>True if the ID was reserved ok. False if it is already reserved (or
        /// an allocation could not be obtained).</returns>
        internal bool ReserveId(IdHandle idh, uint id)
        {
            if (id > 0)
            {
                // Find the packet that contains the specified ID.
                IdPacket packet = FindPacket(id);
                if (packet == null)
                {
                    MessageBox.Show("IdGroup.ReserveId - Wrong ID group.");
                    return(false);
                }

                // Get the ID handle to reserve the ID.
                return(idh.ReserveId(packet, idh.Entity, id));
            }
            else
            {
                // Find the packet that contains the next available ID.
                IdPacket packet = FindNextAvail();

                // If we didn't find anything, ask the ID manager to make
                // a new allocation (most of the work actually gets passed
                // back to IdGroup.GetAllocation).
                if (packet == null)
                {
                    GetAllocation(true);
                    packet = FindNextAvail();
                    if (packet == null)
                    {
                        return(false);
                    }
                }

                // Get the next ID from the packet.
                uint nextid = packet.ReserveId();
                if (nextid == 0)
                {
                    MessageBox.Show("IdGroup.ReserveId - Range did not have any free IDs.");
                    return(false);
                }

                return(idh.Define(packet, idh.Entity, nextid));
            }
        }
Example #4
0
        /// <summary>
        /// Reserves a feature ID in a specific ID packet
        /// </summary>
        /// <devnote>This function is called by LoadIdCombo</devnote>
        /// <param name="packet">The ID packet containing the available ID.</param>
        /// <param name="ent">The entity type that the ID is for.</param>
        /// <param name="id">The available ID to reserve.</param>
        /// <returns>True if the ID was successfully reserved.</returns>
        internal bool ReserveId(IdPacket packet, IEntity ent, uint id)
        {
            // Ensure that any currently reserved ID is released.
            FreeReservedId();

            // Just get the packet to do it.
            if (packet.ReserveId(id))
            {
                m_Packet = packet;
                m_Id = id;
                m_Entity = ent;
                return true;
            }

            this.Reset();
            return false;
        }