Example #1
0
Kitchen *Reception::createKitchen(void) {
	pid_t pid;
	std::ostringstream stream;

	stream << "Kitchen" << this->_lastKitchen;
	// NamedPipe::create("write_" + stream.str());
	// NamedPipe::create("read_" + stream.str());
	// pid = Process::createProcess();
	pid = 1;

	if (pid == -1) {
		exit(1);
	} else if (pid == 0) {
		// Kitchen new_kitch(stream.str(), _numberCook, _preparePizza);		

		write(1, "New process\n", strlen("New process\n"));
		this->_log.write("Launching new Kitchen process\n");
		// new_kitch.run();
	} else {
		Kitchen kitchen(stream.str(), _numberCook);

		this->_kitchens.push_back(kitchen);
		this->_kitchens.back().takeOrder();
		this->_earnedMoney -= 300;
		this->_lastKitchen++;
		this->_log.write("Creation of new Kitchen in the list\n");
		return (&(this->_kitchens.back()));
	}

	return (NULL);
}
Example #2
0
int main()
{
    typedef  quan::length::m width;
    typedef  quan::length::m length;
   
    room kitchen(length(6),width(3) );
    room lounge(length(5), width(3.6));
    room bedroom1(length(3.6), width(3));
    room bedroom2(length(3.6), width(2.7));
    room bedroom3(length(2.1), width(3.6) );

    quan::area::m2 a 
    = kitchen.area()
    + lounge.area()
    + bedroom1.area()
    + bedroom2.area()
    + bedroom3.area();

    std::cout << "floor area = "<< a <<'\n';
}
Example #3
0
void	Plazza::assign_to_kitchen(std::string &pizza)
{
    std::list<Fifo>::iterator	itin;
    std::list<Fifo>::iterator	itout;
    std::string res;
    int	_pid;

    itin = this->fifosin.begin();
    itout = this->fifosout.begin();
    while (itin != this->fifosin.end())
    {
        *itout << pizza;
        *itin >> res;
        if (res.compare(0, 4, "succ") == 0)
            break ;
        itin++;
        itout++;
    }
    this->num = this->num + 1;
    if (getpid() == this->pid)
    {
        Fifo  fifoin(this->num, 0);
        Fifo  fifoout(this->num, 1);
        this->fifosin.push_back(fifoin);
        this->fifosout.push_back(fifoout);
        if ((_pid = fork()) < 0)
            throw cerrExcept("fork fail");
        if(_pid == 0)
        {
            Kitchen	kitchen(this->multiplier, this->cooks, this->time);
            kitchen.work(fifoout, fifoin);
        }
        else
        {
            fifoout << pizza;
            fifoin >> res;
            std::cout << res << "  res" << std::endl;
        }
    }