using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using Axion.Collections.Concurrent; namespace ServerCore; //============================================================================================= // 각종 시스템에 사용할 플래그 설정을 타입화 하여 관리할 수 있는 제네릭 클래스 이다. // // author : kangms // //============================================================================================= public class Flags { private readonly ConcurrentHashSet m_switchs = new(); public bool hasFlag(T flag) { return m_switchs.Contains(flag); } public void setFlag(T flag, bool isEnable) { if (isEnable) { m_switchs.AddOrUpdate(flag); } else { m_switchs.Remove(flag); } } public bool isEmptyFlags() { return m_switchs.IsEmpty; } public void reset() { m_switchs.Clear(); } public virtual Flags clone() { var cloned = new Flags(); foreach(var value in m_switchs) { cloned.getData().AddOrUpdate(value); } return cloned; } public virtual void deepCopy(Flags other) { reset(); foreach (var value in other.getData()) { m_switchs.AddOrUpdate(value); } } public ConcurrentHashSet getData() => m_switchs; }