Message* MessageInflater::inflate(const UninflatedMessage& inSource) { Message* theResult = NULL; MessageInflaterMap::iterator i = mMap.find(inSource.inflatedType()); if(i != mMap.end()) { try { theResult = i->second->clone(); if(theResult != NULL) { bool successfulInflate = theResult->inflateFrom(inSource); if(!successfulInflate) { logWarning1("inflate failed of message type %i", inSource.inflatedType()); throw 1; } } else { logWarning1("clone() failed message type %i", inSource.inflatedType()); } } catch(...) { logWarning1("exception caught in inflated() message type %i", inSource.inflatedType()); delete theResult; theResult = NULL; } } else { logAnomaly1("do not know how to inflate message type %i", inSource.inflatedType()); } if(theResult == NULL) { // We should end up here in any of the following circumstances: // 1. No entry in map // 2. clone() returned NULL // 3. exception thrown in clone() // 4. inflateFrom() returned "false" meaning "unsuccessful inflate" // 5. exception thrown in inflateFrom() // In any of these cases, we were unable to inflate the message, so we return // a new copy of the uninflated message. theResult = inSource.clone(); } return theResult; }
void vpause(const char *message) { logWarning1("vpause: %s", message); fprintf(stderr, "vpause %s\n", message); }