// ----------------------------------------------------------------------------------------------------------------- public void RemoveByIdx(int idx) { CTag.CObject t = GetByIdx(idx); if (m_objects.GetRefCnt(t) == 1) { t.UnsetTag(this); } m_objects.RemoveByIdx(idx); AddToChangeset(t); }
// ----------------------------------------------------------------------------------------------------------------- public bool Add(CTag.CObject t) { if (m_limit > 0 && m_limit == m_objects.GetOrderLen()) { // Limit is reached if (m_limit_policy == ELimitPolicy.LP_DENY) { // Deny new objects return(false); } else { // Remove first object RemoveByIdx(0); } } // Set tag if it is not set yet int ref_cnt = m_objects.GetRefCnt(t); if (!t.IsTagSet(this)) { utils.Assert(ref_cnt == 0, "Failed to add tagged object. Ref-cnt not zero:: tag={0} obj={1} ref-cnt={2}", m_name, t.GetTagName(), ref_cnt); t.SetTag(this); } else { utils.Assert(ref_cnt > 0, "Failed to add tagged object. Ref-cnt is zero :: tag={0} obj={1} ref-cnt={2}", m_name, t.GetTagName(), ref_cnt); } // Add new object to list m_objects.Add(t, null); AddToChangeset(t); return(true); }
// ------------------------------------------------------------------------------------------------------------- public bool IsOnlyTag(CTag.CObject obj, int tag_idx) { return(obj.IsOnlyTag(GetTag(tag_idx))); }
// ------------------------------------------------------------------------------------------------------------- public bool IsTagSet(CTag.CObject obj, int tag_idx) { return(obj.IsTagSet(GetTag(tag_idx))); }
// ------------------------------------------------------------------------------------------------------------- public void UnsetTag(CTag.CObject obj, int tag_idx) { GetTag(tag_idx).Remove(obj); }
// ------------------------------------------------------------------------------------------------------------- public bool SetTag(CTag.CObject obj, int tag_idx) { return(GetTag(tag_idx).Add(obj)); }
// ----------------------------------------------------------------------------------------------------------------- private void AddToChangeset(CTag.CObject t) { m_changeset[t] = null; }
// ----------------------------------------------------------------------------------------------------------------- public void Remove(CTag.CObject t) { t.UnsetTag(this); m_objects.RemoveByKey(t); AddToChangeset(t); }