# Class is enumeration of several possible store configurations.
class StoreConfiguration
  id: undefined
  duplicates: undefined
  prefixing: undefined
  useExisting: undefined
  readOnly: undefined

  # Constructor.
  #
  # @param id.
  # @param mask.
  @create$int$String: (id, mask, o) ->
    if !o? then o = new StoreConfiguration()
    o.id = id
    bits = parseInt mask, 2
    o.duplicates = (bits & 1) > 0
    o.prefixing = ((bits >> 1) & 1) > 0
    o.useExisting = ((bits >> 2) & 1) > 0
    o.readOnly = ((bits >> 3) & 1) > 0
    return o

  @DBCONFIG_WITHOUT_DUPLICATES: StoreConfiguration.
  create$int$String(0, "00000000")
  @DBCONFIG_WITH_DUPLICATES: StoreConfiguration.
  create$int$String(1, "00000001")
  @DBCONFIG_WITHOUT_DUPLICATES_WITH_PREFIXING: StoreConfiguration.
  create$int$String(2, "00000010")
  @DBCONFIG_WITH_DUPLICATES_WITH_PREFIXING: StoreConfiguration.
  create$int$String(3, "00000011")
  @DBCONFIG_USE_EXISTING: StoreConfiguration.
  create$int$String(5, "00000100")
  @DBCONFIG_USE_EXISTING_READONLY: StoreConfiguration.
  create$int$String(5, "00001100")

  toString: () ->
    return "duplicates: " + duplicates + ", prefixing: " + prefixing +
    ", useExisting: " + useExisting + ", readOnly: " + readOnly

exports.StoreConfiguration = StoreConfiguration
