Example #1
0
void SimulationInfo::loadJSON(const JSON::Value &value) {
  const JSON::Dict &dict = value.getDict();

  if (dict.has("user")) user = dict["user"]->getString();
  if (dict.has("team")) team = dict["team"]->getString();
  if (dict.has("project")) project = (uint32_t)dict["project"]->getNumber();
  if (dict.has("run")) run = (uint32_t)dict["run"]->getNumber();
  if (dict.has("clone")) clone = (uint32_t)dict["clone"]->getNumber();
  if (dict.has("gen")) gen = (uint32_t)dict["gen"]->getNumber();
  if (dict.has("core_type"))
    coreType = (uint32_t)dict["core_type"]->getNumber();
  if (dict.has("core")) core = dict["core"]->getString();
  if (dict.has("total_iterations"))
    totalIterations = (uint64_t)dict["total_iterations"]->getNumber();
  if (dict.has("iterations_done"))
    iterationsDone = (uint64_t)dict["iterations_done"]->getNumber();
  if (dict.has("energy")) energy = dict["energy"]->getNumber();
  if (dict.has("temperature")) temperature = dict["temperature"]->getNumber();
  if (dict.has("start_time"))
    startTime = Time::parse(dict["start_time"]->getString());
  if (dict.has("timeout")) timeout = (uint64_t)dict["timeout"]->getNumber();
  if (dict.has("deadline")) deadline = (uint64_t)dict["deadline"]->getNumber();
  if (dict.has("eta")) eta = (uint64_t)dict["eta"]->getNumber();
  if (dict.has("progress")) progress = dict["progress"]->getNumber();
  if (dict.has("slot")) slot = (uint32_t)dict["slot"]->getNumber();
}
Example #2
0
void ACLSet::set(const JSON::Value &json) {
  clear();

  const JSON::Dict &dict = json.getDict();

  // Users
  if (dict.has("users")) {
    const JSON::List &users = dict.get("users")->getList();
    for (unsigned i = 0; i < users.size(); i++) addUser(users[i]->getString());
  }

  // Groups
  if (dict.has("groups")) {
    const JSON::Dict &groups = dict.get("groups")->getDict();
    for (unsigned i = 0; i < groups.size(); i++) {
      const string &name = groups.keyAt(i);
      addGroup(name);

      // Users
      const JSON::List &users = groups.get(i)->getList();
      for (unsigned j = 0; j < users.size(); j++)
        groupAddUser(name, users[j]->getString());
    }
  }

  // ACLs
  if (dict.has("acls")) {
    const JSON::Dict &acls = dict.get("acls")->getDict();
    for (unsigned i = 0; i < acls.size(); i++) {
      const JSON::Dict &acl = acls.get(i)->getDict();
      const string &path = acls.keyAt(i);
      addACL(path);

      // Users
      if (acl.has("users")) {
        const JSON::List &users = acl.get("users")->getList();
        for (unsigned j = 0; j < users.size(); j++)
          aclAddUser(path, users[j]->getString());
      }

      // Groups
      if (acl.has("groups")) {
        const JSON::List &groups = acl.get("groups")->getList();
        for (unsigned j = 0; j < groups.size(); j++)
          aclAddGroup(path, groups[j]->getString());
      }
    }
  }
}
void Workpiece::read(const JSON::Value &value) {
  automatic = value.getBoolean("automatic", automatic);
  margin = value.getNumber("margin", margin);
  if (value.hasDict("bounds")) bounds.read(value.getDict("bounds"));
}