// getCapacitanceForCell float library::getCapacitanceForCell(string c, int numberOfInput) { string cellName = c ; #ifdef NAN45 if(cellName=="not"){ cellName="inv";} #endif //cout << "cell name=" << cellName << endl ; std::vector<liberty::Cell> cell = lib.getCells(); for (int i=0;i<cell.size();i++) { //cout << cell[i].getName() << endl ; string name = cell[i].getName(); transform ( name.begin(), name.end(), name.begin(), ptr_fun(::tolower) ); if( boost::starts_with(name, cellName) && ( cell[i].getName().find("X1")) != string::npos) { //cout << cell[i].getName() << endl ; if( cell[i].getInputPinCount() == numberOfInput ) { std::vector<liberty::Pin> pins = cell[i].getPins(); for(int j=0;j<pins.size();j++){ if (pins[j].getDirection()==input) { return (double)( pins[j].getCapacitance() ); } } } } } return 0.001; //1pf }
int main () { int* p = find_if (array, array + 3, ptr_fun (even)); if (p != array + 3) cout << *p << " is even" << endl; return 0; }
string ZString::TrimRight(const string str) { string strTmp=str; string::reverse_iterator rpos = find_if(strTmp.rbegin(),strTmp.rend(),not1(ptr_fun(::isspace))); strTmp.erase(rpos.base(),strTmp.end()); return strTmp; }
std::string Symbol::get_qualified_name(Scope sc, bool without_template_id) const { if (_symbol->symbol_name == NULL) { return std::string(""); } else { const char* (*ptr_fun)(struct scope_entry_tag* entry, const decl_context_t* decl_context, char* is_dependent, int* max_qualif_level) = get_fully_qualified_symbol_name; if (without_template_id) { ptr_fun = get_fully_qualified_symbol_name_without_template; } int max_level = 0; char is_dependent = 0; const char* qualified_name = ptr_fun(_symbol, sc._decl_context, &is_dependent, &max_level); return std::string(qualified_name); } }
int main(int argc, char* argv[]) { list< shared_ptr<Duck> > ducks; list< shared_ptr<Duck> >::const_iterator itr; ducks.push_back(shared_ptr<Duck>(new Duck("Daffy", 8))); ducks.push_back(shared_ptr<Duck>(new Duck("Dewey", 2))); ducks.push_back(shared_ptr<Duck>(new Duck("Howard", 7))); ducks.push_back(shared_ptr<Duck>(new Duck("Louie", 2))); ducks.push_back(shared_ptr<Duck>(new Duck("Donald", 10))); ducks.push_back(shared_ptr<Duck>(new Duck("Huey", 2))); cout << "Before sorting:" << endl; for (itr=ducks.begin();itr!=ducks.end();++itr) { printf("%s\n", (*itr)->toString().c_str()); } printf("\nAfter sorting:\n"); ducks.sort(ptr_fun(&Duck::compareTo)); for (itr=ducks.begin();itr!=ducks.end();++itr) { printf("%s\n", (*itr)->toString().c_str()); } return 0; }
string ZString::TrimLeft(const string str) { string strTmp=str; string::iterator pos=find_if(strTmp.begin(),strTmp.end(),not1(ptr_fun(::isspace))); strTmp.erase(strTmp.begin(), pos); return strTmp; }
string to_upper(string x) { //locale utfFile("en_US.UTF-8"); transform( x.begin(), x.end(), x.begin(), bind2nd( ptr_fun(&std::toupper<char>), locale("") ) ); return x; }
string& Rtrim(string& s) { int (*func)(int) = isspace; string::reverse_iterator iter; iter = find_if(s.rbegin(), s.rend(), not1(ptr_fun(func))); s.erase(iter.base(), s.end()); return s; }
string& Ltrim(string& s) { int (*func)(int) = isspace; string::iterator iter; iter = find_if(s.begin(), s.end(), not1(ptr_fun(func))); s.erase(s.begin(), iter); return s; }
DelayedDeleter::~DelayedDeleter() { timer.shutdown(); #if defined(DEBUG) mutex.lock(); // try out some STL template magic // this will run foreach(listelement) { delete listelement } std::for_each(list.begin(), list.end(), ptr_fun(delme)); mutex.unlock(); #endif }
BVHAccelTreeNode *BVHAccel::BuildHierarchy(std::vector<BVHAccelTreeNode *> &list, unsigned int begin, unsigned int end, unsigned int axis) { unsigned int splitAxis = axis; float splitValue; nNodes += 1; if (end - begin == 1) // Only a single item in list so return it return list[begin]; BVHAccelTreeNode *parent = new BVHAccelTreeNode(); parent->primitive = 0xffffffffu; parent->leftChild = NULL; parent->rightSibling = NULL; std::vector<unsigned int> splits; splits.reserve(treeType + 1); splits.push_back(begin); splits.push_back(end); for (unsigned int i = 2; i <= treeType; i *= 2) { // Calculate splits, according to tree type and do partition for (unsigned int j = 0, offset = 0; j + offset < i && splits.size() > j + 1; j += 2) { if (splits[j + 1] - splits[j] < 2) { j--; offset++; continue; // Less than two elements: no need to split } FindBestSplit(list, splits[j], splits[j + 1], &splitValue, &splitAxis); std::vector<BVHAccelTreeNode *>::iterator it = partition(list.begin() + splits[j], list.begin() + splits[j + 1], bind2nd(ptr_fun(bvh_ltf[splitAxis]), splitValue)); unsigned int middle = distance(list.begin(), it); middle = Max(splits[j] + 1, Min(splits[j + 1] - 1, middle)); // Make sure coincidental BBs are still split splits.insert(splits.begin() + j + 1, middle); } } BVHAccelTreeNode *child, *lastChild; // Left Child child = BuildHierarchy(list, splits[0], splits[1], splitAxis); parent->leftChild = child; parent->bbox = child->bbox; lastChild = child; // Add remaining children for (unsigned int i = 1; i < splits.size() - 1; i++) { child = BuildHierarchy(list, splits[i], splits[i + 1], splitAxis); lastChild->rightSibling = child; parent->bbox = Union(parent->bbox, child->bbox); lastChild = child; } return parent; }
bool KDLTypekitPlugin::loadConstructors() { TypeInfoRepository::shared_ptr ti = TypeInfoRepository::Instance(); ti->type("KDL.Vector")->addConstructor( newConstructor(&vectorxyz) ); ti->type("KDL.Rotation")->addConstructor( newConstructor( ptr_fun( Rotation::RPY )) ); ti->type("KDL.Rotation")->addConstructor( newConstructor(&rotationAngleAxis) ); ti->type("KDL.Frame")->addConstructor( newConstructor(&framerv) ); ti->type("KDL.Frame")->addConstructor( newConstructor(&framevr) ); ti->type("KDL.Wrench")->addConstructor( newConstructor(&wrenchft) ); ti->type("KDL.Twist")->addConstructor( newConstructor(&twistvw) ); RTT::Service::shared_ptr gs = RTT::internal::GlobalService::Instance(); gs->provides("KDL")->provides("Rotation")->addOperation("RotX",&Rotation::RotX).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("RotY",&Rotation::RotY).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("RotZ",&Rotation::RotZ).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("RPY",&Rotation::RPY).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("EulerZYX",&Rotation::EulerZYX).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("EulerZYZ",&Rotation::EulerZYZ).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("Quaternion",&Rotation::Quaternion).doc(""); //ti->type("Frame[]")->addConstructor(newConstructor(stdvector_ctor<Frame>() ) ); //ti->type("Frame[]")->addConstructor(newConstructor(stdvector_ctor2<Frame>() ) ); //ti->type("Frame[]")->addConstructor(new StdVectorBuilder<Frame>() ); //ti->type("Vector[]")->addConstructor(newConstructor(stdvector_ctor<Vector>() ) ); //ti->type("Vector[]")->addConstructor(newConstructor(stdvector_ctor2<Vector>() ) ); //ti->type("Vector[]")->addConstructor(new StdVectorBuilder<Vector>() ); //ti->type("Rotation[]")->addConstructor(newConstructor(stdvector_ctor<Rotation>() ) ); //ti->type("Rotation[]")->addConstructor(newConstructor(stdvector_ctor2<Rotation>() ) ); //ti->type("Rotation[]")->addConstructor(new StdVectorBuilder<Rotation>() ); //ti->type("Wrench[]")->addConstructor(newConstructor(stdvector_ctor<Wrench>() ) ); //ti->type("Wrench[]")->addConstructor(newConstructor(stdvector_ctor2<Wrench>() ) ); //ti->type("Wrench[]")->addConstructor(new StdVectorBuilder<Wrench>() ); //ti->type("Twist[]")->addConstructor(newConstructor(stdvector_ctor<Twist>() ) ); //ti->type("Twist[]")->addConstructor(newConstructor(stdvector_ctor2<Twist>() ) ); //ti->type("Twist[]")->addConstructor(new StdVectorBuilder<Twist>() ); return true; }
//the compute distance is undertaken an overhaull. I prefere to compute the probability instead of the //euclidean distance. void CRegionalMetaModel::ComputeDistance( vector< vector<REAL> >& mxInputs, vector<REAL>& vcPtCen, dist_pair_vector& vcDists ) { int rows = mxInputs.size(); int cols = mxInputs.front().size(); /*compute the center of the hyperecllipsoid*/ vector<REAL> center(cols, 0.0); for( vector< vector<REAL> >::iterator iter=mxInputs.begin(); iter!=mxInputs.end(); iter++ ) transform( center.begin(), center.end(), iter->begin(), center.begin(), plus<REAL>() ); transform( center.begin(), center.end(), center.begin(), bind2nd(divides<REAL>(), rows) ); /*compute the standard deviation of the columns*/ //compute sum( (x-u)*(x-u) ) for each column vector<REAL> stds(cols, 0.0); for( int i=0; i<rows; i++ ) for( int j=0; j<cols; j++ )stds[j] += sqr( center[j] - mxInputs[i][j] ); //using compose function operator to do "sqrt( sum/N-1 )" transform( stds.begin(), stds.end(), stds.begin(), compose_f_gx( ptr_fun(sqrt), bind2nd(divides<double>(), rows-1) ) ); /* compute the radius */ REAL alpha = 1.5; vector<REAL> radius(cols); transform( stds.begin(), stds.end(), radius.begin(), bind2nd(multiplies<REAL>(), alpha) ); for( i=0; i<cols; i++ )if( radius[i]<=0.0001 )radius[i]=0.0001; /* compute the distance for each point */ vector<REAL> radius_sqr(cols); transform( radius.begin(), radius.end(), radius.begin(), radius_sqr.begin(), multiplies<REAL>() ); for( i=0; i<rows; i++ ){ vector<REAL> temp(cols); transform( mxInputs[i].begin(), mxInputs[i].end(), center.begin(), temp.begin(), diff_sqr<REAL>() ); REAL distance = inner_product( temp.begin(), temp.end(), radius_sqr.begin(), 0.0, plus<REAL>(), divides<REAL>() ); vcDists.push_back( dist_pair(i, distance) ); } sort( vcDists.begin(), vcDists.end(), op_dist_less() ); }
// getTimingforCell // Returns a duo rise & fall time, usually it's based on nano seconds, // however it may differs in standard cell library. timingData library::getTimingForCell(string c, int numberOfInput, double outputCapacitance) { timingData data; string cellName = c; data.rise=0; data.fall=0; //cout << "cell name=" << cellName << endl ; #ifdef NAN45 if(cellName=="not"){ cellName="inv";} #endif std::vector<liberty::Cell> cell = lib.getCells(); for (int i=0;i<cell.size();i++) { //cout << cell[i].getName() << endl ; string name = cell[i].getName(); transform ( name.begin(), name.end(), name.begin(), ptr_fun(::tolower) ); if( boost::starts_with(name, cellName) && ( cell[i].getName().find("X1")) != string::npos) { //cout << cell[i].getName() << endl ; if( (cell[i].getInputPinCount() == numberOfInput) || (cellName=="dff")) { std::vector<liberty::Pin> pins = cell[i].getPins(); for(int j=0;j<pins.size();j++){ if (pins[j].getDirection()==output) { try { std::vector<liberty::Timing> timing = pins[j].getTiming(); utils::Table tableRise = timing[0].getCellRiseTable(); utils::Table tableFall = timing[0].getCellFallTable(); //cout << tableRise << endl ; //cout << "---------------" << endl ; //cout << tableFall << endl ; //0.0004 0.0008 0.0016 0.0032 0.0064 0.0128 0.0256 /* std::vector<double> cap = tableRise._index2; int c=0; do { c++; } while (c<cap.size() && cap[c]<outputCapacitance); data.rise= tableRise.getValue(0,c); cap = tableFall._index2; c=0; do { c++; } while (c<cap.size() && cap[c]<outputCapacitance); */ data.rise= 1000* tableRise.getValue((tableRise._index1)[0],outputCapacitance); data.fall= 1000* tableFall.getValue((tableFall._index1)[0],outputCapacitance); return data; //cout << tableRise._numIndices << endl ; //std::vector<double> idx1 = tableRise._values ; //for(int c=0;c<idx1.size();c++) cout << idx1[c] << " " ; //cout << endl ; //cout << tableRise.getValue(2,3) << endl ; } catch (...) { cout << "Warning! Pin " << pins[j].getName() << " in cell " << cell[i].getName() <<" has no timing information." << endl ; return data; } } } } } } return data; }
bool CustomCodeGenerator::Generate(const FileDescriptor* file, const string& parameter, compiler::GeneratorContext* generator_context, string* error) const { string outfilename = file->name().substr(0, file->name().size() - strlen(".proto")); string outheaderfilename = outfilename + (".pb.rpc.h"); string outsrcfilename = outfilename + (".pb.rpc.cc"); string includefilename = outfilename + ".pb.h"; string::size_type slastpos = 0; string::size_type spos; vector<string> ns; string spacket = file->package(); do { spos = spacket.find(".", slastpos); ns.push_back(spacket.substr(slastpos, spos - slastpos)); slastpos = spos + 1; } while (spos != string::npos); string identifier; for (size_t i=0; i<ns.size(); ++i) identifier += ns[i] + "_"; identifier += outfilename; identifier.erase(remove_if(identifier.begin(), identifier.end(), not1(ptr_fun(::is_identifier))), identifier.end()); identifier += "_rpc"; scoped_ptr<io::ZeroCopyOutputStream> outputh(generator_context->Open(outheaderfilename)); scoped_ptr<io::ZeroCopyOutputStream> outputcc(generator_context->Open(outsrcfilename)); io::Printer printer(outputh.get(), '$'); io::Printer ccprinter(outputcc.get(), '$'); printer.Print( "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $filename$\n" "\n" "#ifndef PROTOBUF_$filename_identifier$__INCLUDED\n" "#define PROTOBUF_$filename_identifier$__INCLUDED\n" "\n" "\n", "filename", file->name(), "filename_identifier", identifier); printer.Print("#include \"$header$\"\n" "#include <string>\n" "#include <memory>\n", "header", includefilename); printer.Print("\n"); ccprinter.Print( "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $filename$\n" "\n", "filename", file->name()); ccprinter.Print("#include \"$header$\"\n" "#include <boost/pool/singleton_pool.hpp>\n", "header", outheaderfilename); ccprinter.Print("\n"); for (size_t i=0; i<ns.size(); ++i) { printer.Print("namespace $part$ {\n", "part", ns[i]); ccprinter.Print("namespace $part$ {\n", "part", ns[i]); } printer.Print("\n\n"); ccprinter.Print("\n\n"); const EnumDescriptor* emu_cmdids = NULL; for (int i=0; i< file->enum_type_count(); ++i) { if (file->enum_type(i)->name() == "CmdIDs") emu_cmdids = file->enum_type(i); } for (int i = 0; i < file->service_count(); ++i) { for (int j=0; j < file->service(i)->method_count(); ++j) { const MethodDescriptor* m = file->service(i)->method(j); printer.Print( "class $RPCNAME$\n" "{\n" "public:\n", "RPCNAME", m->name()); printer.Indent(); printer.Print( "typedef $REQNAME$ RequestType;\n" "typedef $RESPNAME$ ResponseType;\n" "\n", "REQNAME", m->input_type()->name(), "RESPNAME", m->output_type()->name()); string cmdid; if (emu_cmdids) { const EnumValueDescriptor* ev = emu_cmdids->FindValueByName("CmdID_" + m->name()); if (ev) cmdid = ev->name(); } printer.Print( "static const ::std::string& ns() { return ns_; }\n" "static const ::std::string& name() { return name_; }\n" "static const ::std::string& full_name() { return full_name_; }\n" "static bool has_cmd_id() { return $HAS_CMDID$; }\n" "static uint32_t cmd_id() { return $CMDID$; }\n" "\n" "static RequestType& request();\n" "static ResponseType& response();\n" "\n", "HAS_CMDID", cmdid.empty() ? "false" : "true", "CMDID", cmdid.empty() ? "0U" : cmdid ); printer.Outdent(); printer.Print("private:\n"); printer.Indent(); printer.Print("static ::std::string ns_;\n" "static ::std::string name_;\n" "static ::std::string full_name_;\n"); printer.Outdent(); printer.Print("};\n\n\n"); ccprinter.Print( "// $RPCNAME$\n" "::std::string $RPCNAME$::ns_ = \"$SERVICENAME$\";\n" "::std::string $RPCNAME$::name_ = \"$RPCNAME$\";\n" "::std::string $RPCNAME$::full_name_ = \"$SERVICENAME$.$RPCNAME$\";\n", "SERVICENAME", m->service()->name(), "RPCNAME", m->name()); ccprinter.Print("\n\n"); } } if (!ns.empty()) { for (size_t i=0; i<ns.size(); ++i) { printer.Print("} // namespace $part$\n", "part", ns[ns.size()-i-1]); ccprinter.Print("} // namespace $part$\n", "part", ns[ns.size()-i-1]); } } printer.Print("\n#endif // PROTOBUF_$filename_identifier$__INCLUDED\n", "filename_identifier", identifier); return true; }
string ZString::EraseSpace(const string str) { string strTmp=str; strTmp.erase(remove_if(strTmp.begin(),strTmp.end(),ptr_fun(::isspace)),strTmp.end()); return strTmp; }
/////////////////////////////////////////////////////////////////////////////// // ErrlManager::errlogMsgHndlr() /////////////////////////////////////////////////////////////////////////////// void ErrlManager::errlogMsgHndlr () { TRACFCOMP( g_trac_errl, ENTER_MRK "Enter ErrlManager::errlogMsgHndlr" ); while( 1 ) { msg_t * theMsg = msg_wait( iv_msgQ ); TRACFCOMP( g_trac_errl, INFO_MRK"Got an error log Msg - Type: 0x%08x", theMsg->type ); //Process message just received switch( theMsg->type ) { case ERRLOG_ACCESS_PNOR_TYPE: { // PNOR is up and running now. setupPnorInfo(); //We are done with the msg msg_free(theMsg); // go back and wait for a next msg break; } case ERRLOG_ACCESS_TARG_TYPE: { // TARGETING is up and running now. // do we NOT need to send the error? TARGETING::Target * sys = NULL; TARGETING::targetService().getTopLevelTarget( sys ); TARGETING::SpFunctions spfn; if (!(sys && sys->tryGetAttr<TARGETING::ATTR_SP_FUNCTIONS>(spfn) && spfn.baseServices)) { iv_isSpBaseServices = false; // if there are queued errors, clear the Mbox flag // since they will never be sent, which will delete // the errors that have been fully processed ErrlListItr_t it = iv_errlList.begin(); while(it != iv_errlList.end()) { // Mark MBOX processing complete _clearFlag(*it, MBOX_FLAG); _updateErrlListIter(it); } } //We are done with the msg msg_free(theMsg); // go back and wait for a next msg break; } case ERRLOG_ACCESS_MBOX_TYPE: { // MBOX is up and running now. // do we need to send the errorlog TARGETING::Target * sys = NULL; TARGETING::targetService().getTopLevelTarget( sys ); TARGETING::SpFunctions spfn; if (sys && sys->tryGetAttr<TARGETING::ATTR_SP_FUNCTIONS>(spfn) && spfn.mailboxEnabled) { iv_isMboxEnabled = true; } // if we're supposed to and can now send msgs, do it. if (iv_isSpBaseServices && iv_isMboxEnabled) { // Register messageQ with Mailbox to receive message. errlHndl_t l_err = MBOX::msgq_register( MBOX::HB_ERROR_MSGQ, iv_msgQ ); if( l_err ) { TRACFCOMP(g_trac_errl, ERR_MRK "Msg queue already registered"); delete( l_err ); l_err = NULL; //If we got an error then it means the message queue //is registered with mailbox. //This should not happen. So assert here. assert(0); } // if errors came in before MBOX was ready, // the errors would be on this list. send them now. ErrlListItr_t it = iv_errlList.begin(); while(it != iv_errlList.end()) { // Check if MBOX processing is needed if (_isFlagSet(*it, MBOX_FLAG)) { // send errlog sendErrLogToFSP(it->first); // Mark MBOX processing complete _clearFlag(*it, MBOX_FLAG); } _updateErrlListIter(it); } } else { // Delete errors that have been completely processed ErrlListItr_t it = iv_errlList.begin(); while(it != iv_errlList.end()) { // Mark MBOX processing complete _clearFlag(*it, MBOX_FLAG); _updateErrlListIter(it); } } //We are done with the msg msg_free(theMsg); // go back and wait for a next msg break; } case ERRLOG_ACCESS_IPMI_TYPE: { #ifdef CONFIG_BMC_IPMI // IPMI is up and running now. iv_isIpmiEnabled = true; // if we can now send msgs, do it. // if errors came in before IPMI was ready, // the errors would be on this list. send them now. ErrlListItr_t it = iv_errlList.begin(); while(it != iv_errlList.end()) { // Check if IPMI processing is needed if (_isFlagSet(*it, IPMI_FLAG)) { // send errorlog sendErrLogToBmc(it->first); // Mark IPMI processing complete _clearFlag(*it, IPMI_FLAG); } _updateErrlListIter(it); } #endif //We are done with the msg msg_free(theMsg); // go back and wait for a next msg break; } case ERRLOG_ACCESS_ERRLDISP_TYPE: { #ifdef CONFIG_CONSOLE_OUTPUT_ERRORDISPLAY // Errldisplay now ready iv_isErrlDisplayEnabled = true; CONSOLE::displayf("ERRL", "Dumping errors reported prior to registration"); // Display errlogs to errldisplay ErrlListItr_t it = iv_errlList.begin(); while(it != iv_errlList.end()) { // Check if ERRLDISP processing is needed if (_isFlagSet(*it, ERRLDISP_FLAG)) { ERRORLOGDISPLAY::errLogDisplay().msgDisplay (it->first, ((it->first->reasonCode()) & 0xFF00)); // Mark ERRLDISP processing complete _clearFlag(*it, ERRLDISP_FLAG); } _updateErrlListIter(it); } #endif //We are done with the msg msg_free(theMsg); break; } case ERRLOG_NEEDS_TO_BE_COMMITTED_TYPE: { // Extract error log handle from the message. We need the // error log handle to pass along errlHndl_t l_err = (errlHndl_t) theMsg->extra_data; // Ask the ErrlEntry to assign commit component, commit time l_err->commit( (compId_t) theMsg->data[0] ); // Pair with all flags set to add to the errlList ErrlFlagPair_t l_pair(l_err, ALL_FLAGS); #ifdef CONFIG_CONSOLE_OUTPUT_ERRORDISPLAY // Display errl to errldisplay if (iv_isErrlDisplayEnabled) { ERRORLOGDISPLAY::errLogDisplay().msgDisplay (l_err, ( (l_err->reasonCode()) & 0xFF00)); // Mark ERRLDISP processing complete on this error _clearFlag(l_pair, ERRLDISP_FLAG); } #endif //Save the error log to PNOR bool l_savedToPnor = saveErrLogToPnor(l_err); // Check if we actually saved the msg to PNOR if (l_savedToPnor) { // Mark PNOR processing complete on this error _clearFlag(l_pair, PNOR_FLAG); } #ifdef STORE_ERRL_IN_L3 //Write the error log to L3 memory //useful ONLY for the hb-errl tool saveErrLogEntry ( l_err ); #endif //Try to send the error log if someone is there to receive if (!iv_isSpBaseServices) { // Mark MBOX processing complete on this error _clearFlag(l_pair, MBOX_FLAG); } else if (iv_isSpBaseServices && iv_isMboxEnabled) { sendErrLogToFSP(l_err); // Mark MBOX processing complete on this error _clearFlag(l_pair, MBOX_FLAG); } #ifdef CONFIG_BMC_IPMI if (iv_isIpmiEnabled) { // convert to SEL/eSEL and send to BMC over IPMI sendErrLogToBmc(l_err); // Mark IPMI processing complete on this error _clearFlag(l_pair, IPMI_FLAG); } #endif //Ask the ErrlEntry to process any callouts l_err->processCallout(); //Ask if it is a terminating log if( l_err->isTerminateLog() ) { TRACFCOMP( g_trac_errl, INFO_MRK "Terminating error was committed" " errlmanager is reqesting a shutdown."); INITSERVICE::doShutdown(l_err->plid(), true); TRACDCOMP( g_trac_errl, INFO_MRK"shutdown in progress" ); } // If l_errl has not been fully proccessed delete it // otherwise add to list if (l_pair.second == 0) { delete l_err; l_err = NULL; } else { iv_errlList.push_back(l_pair); } //We are done with the msg msg_free(theMsg); // else go back and wait for a next msg break; } case ERRLOG_COMMITTED_ACK_RESPONSE_TYPE: { //Hostboot must keep track and clean up hostboot error //logs in PNOR after it is committed by FSP. uint32_t l_tmpPlid = theMsg->data[0]>>32; TRACFCOMP( g_trac_errl, INFO_MRK"ack: %.8x", l_tmpPlid); bool didAck = ackErrLogInPnor(l_tmpPlid); if (!didAck) { // couldn't find that errlog in PNOR, look in our // errlMsgList - maybe it's there waiting ErrlListItr_t it = std::find_if(iv_errlList.begin(), iv_errlList.end(), std::bind1st(ptr_fun(&compareEidToPlid) ,l_tmpPlid)); // Check if such errl was found if (it != iv_errlList.end()) { // We found the errlog // Mark PNOR processing complete _clearFlag(*it, PNOR_FLAG); _updateErrlListIter(it); } } msg_free(theMsg); // We didn't have room before in PNOR to save an // error log, so try now since we just ACKed one. ErrlListItr_t it = std::find_if(iv_errlList.begin(), iv_errlList.end(), bind2nd(ptr_fun(_isFlagSet), PNOR_FLAG)); // Check if such errl was found if (it != iv_errlList.end()) { bool l_savedToPnor = saveErrLogToPnor(it->first); // check if we actually saved the msg to PNOR if (l_savedToPnor) { // Mark PNOR processing complete _clearFlag(*it, PNOR_FLAG); _updateErrlListIter(it); } // else, still couldn't save it (for some reason) so // it's still on the list. } break; } case ERRLOG_SHUTDOWN_TYPE: TRACFCOMP( g_trac_errl, INFO_MRK "Shutdown event received" ); //Start shutdown process for error log errlogShutdown(); // Respond that we are done shutting down. msg_respond ( iv_msgQ, theMsg ); TRACFCOMP( g_trac_errl, INFO_MRK "Shutdown event processed" ); break; default: // Default Message TRACFCOMP( g_trac_errl, ERR_MRK "Unexpected message type 0x%08x", theMsg->type ); msg_free(theMsg); break; } // switch } //The errlogMsgHndlr should run all the time. It only //exits when error log message thread is killed. TRACFCOMP( g_trac_errl, EXIT_MRK "Exit ErrlManager::errlogMsgHndlr" ); return; }
void FunctionApproximatorIRFRLS::proj(const MatrixXd& vecs, const MatrixXd& periods, const VectorXd& phases, Eigen::MatrixXd& projected) { projected = vecs * periods.transpose(); projected.rowwise() += phases.transpose(); projected = projected.unaryExpr(ptr_fun(double_cosine)); }
string ZFileDialog::GetSaveFileName(HWND hwnd,bool AutoAddSuffixName,const char* szFilter) { string strFileName=""; char file[256]={0}; OPENFILENAMEEX openfilename; ZeroMemory(&openfilename, sizeof(OPENFILENAMEEX)); if( m_sysinfo.GetOSVersion()==1 || m_sysinfo.GetOSVersion()==2 || m_sysinfo.GetOSVersion()==3 || m_sysinfo.GetOSVersion()==4) openfilename.lStructSize = sizeof(OPENFILENAME); else openfilename.lStructSize = sizeof(OPENFILENAMEEX); openfilename.hInstance =0; openfilename.lpstrFile=file; openfilename.nMaxFile=256; openfilename.lpstrFilter=szFilter; openfilename.Flags=OFN_EXPLORER | OFN_ENABLEHOOK; openfilename.hwndOwner=hwnd; openfilename.lpfnHook=(LPOFNHOOKPROC) m_thunk.Callback(this,&ZFileDialog::OFNHookProc,ZThunk::THISCALL); if(!::GetSaveFileName(&openfilename)) return strFileName; strFileName=file; if(!AutoAddSuffixName) return strFileName; //判断用户填写的文件名是否有后缀 bool IsHaveSuffix=strFileName.find_last_of(".")==-1?false:true; //将const char* Filter拆成数组存放 deque<string> FilterArray; while(*szFilter++) { FilterArray.push_back(szFilter-1); while(*szFilter++); } //如果过滤类型为"*.*",则不进行处理,直接返回 string strFilter=FilterArray[openfilename.nFilterIndex]; strFilter.erase(remove_if(strFilter.begin(),strFilter.end(),ptr_fun(::isspace)),strFilter.end()); if(strFilter=="*.*") return strFileName; string strSuffixName=strFilter.substr(2).c_str(); if(IsHaveSuffix) { //如果用户输入的后缀和过滤器中的后缀一样 if(strFileName.substr(strFileName.find_last_of(".")+1)==strSuffixName) { return strFileName; } else { strFileName+="."; strFileName+=strSuffixName; return strFileName; } } else { strFileName+="."; strFileName+=strSuffixName; return strFileName; } }
Uri_Stats sqstat::FindUriStatsById(vector<SQUID_Connection> conns, string id) { for (vector<SQUID_Connection>::iterator it = conns.begin(); it != conns.end(); ++it) { vector<Uri_Stats>::iterator itu = find_if(it->stats.begin(), it->stats.end(), bind2nd(ptr_fun(StatByID), id)); if (itu != it->stats.end()) return *itu; } Uri_Stats newStats; return newStats; }