示例#1
0
void Customer::orderDrink()
{
	BarEmp::Drink_Msg_Args tosend;
	tosend.cust_id = my_id;
	tosend.order_type = orderType;
	tosend.cust_ptr = this;

	ostringstream temp;
	string msg;
	temp << "Waiting for a " << typeAsString(orderType) << "...";
	log(name, temp.str());
	int val = msgsnd(drink_q_id, (void*)&tosend, sizeof(BarEmp::Drink_Msg_Args), 0);
	if(val == -1) {
		msg = "ERROR: Failed to send drink request";
		log(name, msg);
		if(errno == EACCES)
		{
			msg = "ERROR: Please run program with elevated permissions.";
			log(msg);
			exit(0);
		}
	}
	else
	{
		pthread_mutex_lock( &mutex );
		pthread_cond_wait(&rdy_condition, &mutex);
		pthread_mutex_unlock( &mutex );

		temp.str("");
		temp << "Received " << typeAsString(orderType);
		msg = temp.str();
		log(name, msg);
	}
}
示例#2
0
 void Json::typeAssert(JsonType otherType, const char* operationDescFmt, ...) const {
     if (otherType != mType) {
         char operatorDescription[1024];
         va_list args;
         va_start(args, operationDescFmt);
         vsprintf(operatorDescription, operationDescFmt, args);
         va_end(args);
         throw RuntimeError("Attempting '%s' on json of type '%s'. Type should have been '%s'", 
                            operatorDescription,
                            typeAsString(),
                            typeAsString(otherType));
     }
 }
示例#3
0
文件: arc.cpp 项目: chaubold/dpct
void Arc::update(double additionalDelta)
{
	currentScore_ = getScoreDelta() + sourceNode_->getCurrentScore() + additionalDelta;
    // updateEnabledState();
    DEBUG_MSG(typeAsString() << "-Arc update: score is now " << currentScore_ << " (enabled="
               << (enabled_?"true":"false") << ")" << " scoreDelta=" << scoreDeltas_);
}
示例#4
0
wxXmlNode* Shape::toXML(wxXmlNode *root) const {
	wxXmlNode* ret = new wxXmlNode(root, wxXML_ELEMENT_NODE, wxT("shape"));
	ret->AddProperty(wxT("type"), typeAsString());
	ret->AddProperty(wxT("top"), wxString::Format(wxT("%d"), top));
	ret->AddProperty(wxT("left"), wxString::Format(wxT("%d"), left));
	ret->AddProperty(wxT("width"), wxString::Format(wxT("%d"), width));
	ret->AddProperty(wxT("height"), wxString::Format(wxT("%d"), height));
	ret->AddProperty(wxT("color"), color.GetAsString(wxC2S_HTML_SYNTAX));
	return ret;
}
示例#5
0
void Customer::run()
{
	ostringstream temp;
	temp << "Entered the bar. TYPE: " << typeAsString(orderType) << "  DRINKS: " << drinksLeft << "  TABLE: " << favTableIndex;
	log(name, temp.str());
	greetLandlord(false);

	//order a drink and then drink it until no drinks left
	while(drinksLeft > 0)
	{
		orderDrink();
		drink();
	}

	greetLandlord(true);
	pthread_exit(NULL);
}
示例#6
0
 uint Json::size() const
 {
     if (mType == JsonType::Array) {
         return elements->size();
     }
     else if (mType == JsonType::Object) {
         return entries->size();
     }
     else {
         throw RuntimeError("size() called on %s - it can only be called on Objects or Arrays", typeAsString());
     }
 }
示例#7
0
 const char* Json::typeAsString() const {
     return typeAsString(mType);
 }