Ejemplo n.º 1
0
void add_impl(struct node* set, const char* x, int at) {
    if (at == n) {
        return;
    }
    if (x[at] == '0') {
        if (set->zero == 0) {
            set->zero = create();
        }
        add_impl(set->zero, x, at + 1);
    } else {
        if (set->one == 0) {
            set->one = create();
        }
        add_impl(set->one, x, at + 1);
    }
}
Ejemplo n.º 2
0
static inline T op2_impl(Op op, T x, T y) {
	switch (op) {
	case OP_ADD: return add_impl(x, y);
	case OP_SUB: return sub_impl(x, y);
	case OP_MUL: return mul_impl(x, y);
	case OP_DIV: return div_impl(x, y);
	case OP_POW: return pow_impl(x, y);
	default:     throw std::invalid_argument("Wrong number of arguments for operator");
	}
}
Ejemplo n.º 3
0
CCS::Thermometer_ptr
Controller_impl::create_thermometer (CCS::AssetType anum, const char * loc)
{
    if (anum % 2 == 0)
        throw CORBA::BAD_PARAM ();   // Thermometers have odd numbers
    if (exists (anum))
        throw CCS::Controller::DuplicateAsset ();

    assert (ICP_online (anum) == 0);
    assert (ICP_set (anum, "location", loc) == 0);
    add_impl (anum, 0);
    return make_dref (m_poa.in (), anum);
}
Ejemplo n.º 4
0
void compile(struct node* set, int at, struct node* compiledSet, char* element, char* compiled) {
    if (at == n) {
        for (int i = 0; i < n; i++) {
            compiled[i] = element[get_p(i)];
        }
        add_impl(compiledSet, compiled, 0);
        return;
    }
    if (set->zero != 0) {
        element[at] = '0';
        compile(set->zero, at + 1, compiledSet, element, compiled);
    }
    if (set->one != 0) {
        element[at] = '1';
        compile(set->one, at + 1, compiledSet, element, compiled);
    }
}
Ejemplo n.º 5
0
CCS::Thermostat_ptr
Controller_impl::
create_thermostat (
    CCS::AssetType      anum,
    const char*     loc,
    CCS::TempType       temp)
{
    if (anum % 2 != 0)
        throw CORBA::BAD_PARAM ();   // Thermostats have even numbers
    if (exists (anum))
        throw CCS::Controller::DuplicateAsset ();

    assert (ICP_online (anum) == 0);
    assert (ICP_set (anum, "location", loc) == 0);
    // Set the nominal temperature.
    if (ICP_set (anum, "nominal_temp", &temp) != 0) {

        // If ICP_set () failed, read this thermostat's minimum
        // and maximum so we can initialize the BadTemp exception.
        CCS::Thermostat::BtData btd;
        ICP_get (
            anum, "MIN_TEMP",
            &btd.min_permitted, sizeof (btd.min_permitted)
        );
        ICP_get (
            anum, "MAX_TEMP",
            &btd.max_permitted, sizeof (btd.max_permitted)
        );
        btd.requested = temp;
        btd.error_msg = CORBA::string_dup (
                            temp > btd.max_permitted ? "Too hot" : "Too cold"
                        );
        ICP_offline (anum);
        throw CCS::Thermostat::BadTemp (btd);
    }

    add_impl (anum, 0);
    CORBA::Object_var obj = make_dref (m_poa.in (), anum);
    return CCS::Thermostat::_narrow (obj.in ());
}
Ejemplo n.º 6
0
void add_element(char* x) {
    if (--w < 0 || compiled || !check(x)) {
        wa();
    }
    add_impl(set, x, 0);
}
Ejemplo n.º 7
0
base_c &
base_c::add(void const *buffer,
            size_t size) {
  add_impl(static_cast<unsigned char const *>(buffer), size);
  return *this;
}
Ejemplo n.º 8
0
base_c &
base_c::add(memory_c const &buffer) {
  add_impl(buffer.get_buffer(), buffer.get_size());
  return *this;
}
Ejemplo n.º 9
0
 /**
  * Adds an item with a specified count to the sketch.
  */
 void add(const T& t, size_t count = 1) {
   add_impl(t, count, 0);
 }
Ejemplo n.º 10
0
 match_set(MatchFields&&... fields)
     : match_{OFPFW_ALL, 0}
 {
     add_impl(std::forward<MatchFields>(fields)...);
 }
Ejemplo n.º 11
0
 void add_impl(MatchField&& field, MatchFields&&... fields)
 {
     add(std::forward<MatchField>(field));
     add_impl(std::forward<MatchFields>(fields)...);
 }
Ejemplo n.º 12
0
void favorite_manager::add_favorite(running_machine &machine)
{
	apply_running_machine(
			machine,
			[this, &machine] (game_driver const &driver, device_image_interface *imagedev, software_info const *software, bool &done)
			{
				if (imagedev)
				{
					// creating this is fairly expensive, but we'll assume this usually succeeds
					ui_software_info info;
					software_part const *const part(imagedev->part_entry());
					assert(software);
					assert(part);

					// start with simple stuff that can just be copied
					info.shortname = software->shortname();
					info.longname = imagedev->longname();
					info.parentname = software->parentname();
					info.year = imagedev->year();
					info.publisher = imagedev->manufacturer();
					info.supported = imagedev->supported();
					info.part = part->name();
					info.driver = &driver;
					info.listname = imagedev->software_list_name();
					info.interface = part->interface();
					info.instance = imagedev->instance_name();
					info.startempty = 0;
					info.devicetype = strensure(imagedev->image_type_name());
					info.available = true;

					// look up the parent in the list if necessary (eugh, O(n) walk)
					if (!info.parentname.empty())
					{
						auto const listdev = software_list_device::find_by_name(machine.config(), info.listname);
						assert(listdev);
						for (software_info const &other : listdev->get_info())
						{
							if (other.shortname() == info.parentname)
							{
								info.parentlongname = other.longname();
								break;
							}
						}
					}

					// fill in with the first usage entry we find
					for (feature_list_item const &feature : software->other_info())
					{
						if (feature.name() == "usage")
						{
							info.usage = feature.value();
							break;
						}
					}

					// hooray for move semantics!
					add_impl(std::move(info));
				}
				else
				{
					add_impl(driver);
				}
			});
}
Ejemplo n.º 13
0
void favorite_manager::add_favorite_software(ui_software_info const &swinfo)
{
	add_impl(swinfo);
}
Ejemplo n.º 14
0
void favorite_manager::add_favorite_system(game_driver const &driver)
{
	add_impl(driver);
}
Ejemplo n.º 15
0
void
GTimeout::add(unsigned int milliseconds, Slot0<bool> *slot)
{
    GSource *source = g_timeout_source_new(milliseconds);
    add_impl(source, gcallback, slot);
}
Ejemplo n.º 16
0
void
GIdle::add(Slot0<bool> *slot)
{
    GSource *source = g_idle_source_new ();
    add_impl(source, gcallback, slot);
}