本文整理汇总了C++中ErrorLogger::addError方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorLogger::addError方法的具体用法?C++ ErrorLogger::addError怎么用?C++ ErrorLogger::addError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorLogger
的用法示例。
在下文中一共展示了ErrorLogger::addError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parsXml
Application* XmlAppLoader::parsXml(const char* szFile)
{
app.clear();
ErrorLogger* logger = ErrorLogger::Instance();
TiXmlDocument doc(szFile);
if(!doc.LoadFile())
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" at line "\
<<doc.ErrorRow()<<": ";
err<<doc.ErrorDesc();
logger->addError(err);
return NULL;
}
/* retrieving root element */
TiXmlElement *root = doc.RootElement();
if(!root)
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" . ";
err<<"No root element.";
logger->addError(err);
return NULL;
}
if(!compareString(root->Value(), "application"))
{
//OSTRINGSTREAM err;
//err<<"File "<<szFile<<" has no tag <application>.";
//logger->addError(err);
return NULL;
}
/* retrieving name */
TiXmlElement* name = (TiXmlElement*) root->FirstChild("name");
if(!name || !name->GetText())
{
OSTRINGSTREAM err;
err<<"Module from "<<szFile<<" has no name.";
logger->addError(err);
//return NULL;
}
app.setXmlFile(szFile);
if(name)
{
string strname = name->GetText();
for(unsigned int i=0; i<strname.size(); i++)
if(strname[i] == ' ')
strname[i] = '_';
app.setName(strname.c_str());
}
/* retrieving description */
TiXmlElement* desc;
if((desc = (TiXmlElement*) root->FirstChild("description")))
app.setDescription(desc->GetText());
/* retrieving version */
TiXmlElement* ver;
if((ver = (TiXmlElement*) root->FirstChild("version")))
app.setVersion(ver->GetText());
/*
* TODO: setting prefix of the main application is inactivated.
* Check this should be supported in future or not!
*/
/*
//retrieving application prefix
TiXmlElement* pref;
if((pref = (TiXmlElement*) root->FirstChild("prefix")))
app.setPrefix(pref->GetText());
*/
/* retrieving authors information*/
TiXmlElement* authors;
if((authors = (TiXmlElement*) root->FirstChild("authors")))
for(TiXmlElement* ath = authors->FirstChildElement(); ath;
ath = ath->NextSiblingElement())
{
if(compareString(ath->Value(), "author"))
{
Author author;
if(ath->GetText())
author.setName(ath->GetText());
if(ath->Attribute("email"))
author.setEmail(ath->Attribute("email"));
app.addAuthor(author);
}
else
{
OSTRINGSTREAM war;
war<<"Unrecognized tag from "<<szFile<<" at line "\
<<ath->Row()<<".";
logger->addWarning(war);
}
//.........这里部分代码省略.........
示例2: serialXml
//.........这里部分代码省略.........
}
// iterate over connections
{
int nConns=app->connectionCount();
for (int connCt=0; connCt<nConns; ++connCt)
{
TiXmlElement *newConn=new TiXmlElement("connection");
Connection curConn=app->getConnectionAt(connCt);
if(strlen(curConn.getId()))
newConn->SetAttribute("id", curConn.getId());
if(curConn.isPersistent())
newConn->SetAttribute("persist", "true");
TiXmlElement *from = new TiXmlElement("from");
if (curConn.isExternalFrom())
from->SetAttribute("external", "true");
from->LinkEndChild(new TiXmlText(curConn.from()));
newConn->LinkEndChild(from);
TiXmlElement *to = new TiXmlElement("to");
if (curConn.isExternalTo())
to->SetAttribute("external", "true");
to->LinkEndChild(new TiXmlText(curConn.to()));
newConn->LinkEndChild(to);
TiXmlElement *protocol = new TiXmlElement("protocol");
protocol->LinkEndChild(new TiXmlText(curConn.carrier()));
newConn->LinkEndChild(protocol);
GraphicModel model = curConn.getModelBase();
OSTRINGSTREAM txt;
if(model.points.size()>0)
{
txt<<"(Pos ";
for(unsigned int i=0; i<model.points.size(); i++)
txt<<"((x "<<model.points[i].x<<") "<<"(y "<<model.points[i].y<<")) ";
txt<<" )";
TiXmlElement *geometry=new TiXmlElement("geometry");
geometry->LinkEndChild(new TiXmlText(txt.str().c_str()));
newConn->LinkEndChild(geometry);
}
root->LinkEndChild(newConn);
}
}
// iterate over arbitrators
for(int i=0; i<app->arbitratorCount(); i++)
{
Arbitrator& arb = app->getArbitratorAt(i);
TiXmlElement *newArb = new TiXmlElement("arbitrator");
TiXmlElement *port = new TiXmlElement("port");
port->LinkEndChild(new TiXmlText(arb.getPort()));
newArb->LinkEndChild(port);
std::map<string, string> &rules = arb.getRuleMap();
for(std::map<string, string>::iterator it=rules.begin(); it!=rules.end(); ++it)
{
TiXmlElement *rule = new TiXmlElement("rule");
rule->SetAttribute("connection", it->first.c_str());
rule->LinkEndChild(new TiXmlText(it->second.c_str()));
newArb->LinkEndChild(rule);
}
GraphicModel model = arb.getModelBase();
OSTRINGSTREAM txt;
if(model.points.size()>0)
{
txt<<"(Pos ";
for(unsigned int i=0; i<model.points.size(); i++)
txt<<"((x "<<model.points[i].x<<") "<<"(y "<<model.points[i].y<<")) ";
txt<<" )";
TiXmlElement *geometry=new TiXmlElement("geometry");
geometry->LinkEndChild(new TiXmlText(txt.str().c_str()));
newArb->LinkEndChild(geometry);
}
root->LinkEndChild(newArb);
}
bool ok=doc.SaveFile(app->getXmlFile());
if (!ok)
{
OSTRINGSTREAM err;
err<<"tinyXml error for file " << app->getXmlFile();
if (doc.Error())
err <<" at line " << doc.ErrorRow() << ", column " << doc.ErrorCol() << ": " << doc.ErrorDesc();
logger->addError(err);
err <<"\n";
return false;
}
else return true;
}
示例3: parsXml
Module* XmlModLoader::parsXml(const char* szFile)
{
module.clear();
ErrorLogger* logger = ErrorLogger::Instance();
TiXmlDocument doc(szFile);
if(!doc.LoadFile())
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" at line "\
<<doc.ErrorRow()<<": ";
err<<doc.ErrorDesc();
logger->addError(err);
return nullptr;
}
/* retrieving root module */
TiXmlElement *root = doc.RootElement();
if(!root)
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" . ";
err<<"No root element.";
logger->addError(err);
return nullptr;
}
if(!compareString(root->Value(), "module"))
{
/*
OSTRINGSTREAM msg;
msg<<szFile<<" is not a module descriptor file.";
logger->addWarning(msg);
*/
return nullptr;
}
/* retrieving name */
auto* name = (TiXmlElement*) root->FirstChild("name");
if(!name || !name->GetText())
{
OSTRINGSTREAM err;
err<<"Module from "<<szFile<<" has no name.";
logger->addError(err);
//return NULL;
}
for(TiXmlElement* var = root->FirstChildElement("var"); var; var = var->NextSiblingElement())
{
if(var->Attribute("name") && var->GetText())
{
parser->addVariable(var->Attribute("name"), var->GetText());
}
}
module.setXmlFile(szFile);
if(name)
module.setName(parser->parseText(name->GetText()).c_str());
/* retrieving description */
TiXmlElement* desc;
if((desc = (TiXmlElement*) root->FirstChild("description")))
module.setDescription(parser->parseText(desc->GetText()).c_str());
/* retrieving version */
TiXmlElement* ver;
if((ver = (TiXmlElement*) root->FirstChild("version")))
module.setVersion(parser->parseText(ver->GetText()).c_str());
/* retrieving parameter */
TiXmlElement* arguments;
if((arguments = (TiXmlElement*) root->FirstChild("arguments")))
for(TiXmlElement* param = arguments->FirstChildElement(); param;
param = param->NextSiblingElement())
{
if(compareString(param->Value(), "param"))
{
if(param->GetText())
{
bool brequired = false;
if(compareString(param->Attribute("required"), "yes"))
brequired = true;
Argument arg(parser->parseText(param->GetText()).c_str(),
brequired,
param->Attribute("desc"));
arg.setDefault(param->Attribute("default"));
module.addArgument(arg);
}
}
else
if(compareString(param->Value(), "switch"))
{
if(param->GetText())
{
bool brequired = false;
if(compareString(param->Attribute("required"), "yes"))
brequired = true;
Argument arg(parser->parseText(param->GetText()).c_str(),
//.........这里部分代码省略.........
示例4: if
//.........这里部分代码省略.........
trimString(strPath);
if (!isAbsolute(strPath.c_str()))
strPath=inipath+strPath;
addModules(strPath.c_str());
}
}
if(config.check("respath"))
{
string strPath;
stringstream resPaths(config.find("respath").asString().c_str());
while (getline(resPaths, strPath, ';'))
{
trimString(strPath);
if (!isAbsolute(strPath.c_str()))
strPath=inipath+strPath;
addResources(strPath.c_str());
}
}
ErrorLogger* logger = ErrorLogger::Instance();
if(config.check("apppath"))
{
string strPath;
stringstream appPaths(config.find("apppath").asString().c_str());
while (getline(appPaths, strPath, ';'))
{
trimString(strPath);
if (!isAbsolute(strPath.c_str()))
strPath=inipath+strPath;
if(config.find("load_subfolders").asString() == "yes")
{
if(!loadRecursiveApplications(strPath.c_str()))
logger->addError("Cannot load the applications from " + strPath);
}
else
addApplications(strPath.c_str());
}
}
reportErrors();
#ifdef WITH_READLINE
updateAppNames(&appnames);
#endif
#if defined(WIN32)
ACE_OS::signal(SIGINT, (ACE_SignalHandler) YConsoleManager::onSignal);
ACE_OS::signal(SIGBREAK, (ACE_SignalHandler) YConsoleManager::onSignal);
ACE_OS::signal(SIGTERM, (ACE_SignalHandler) YConsoleManager::onSignal);
#else
struct sigaction new_action, old_action;
/* Set up the structure to specify the new action. */
new_action.sa_handler = YConsoleManager::onSignal;
sigemptyset (&new_action.sa_mask);
new_action.sa_flags = 0;
sigaction (SIGINT, NULL, &old_action);
if (old_action.sa_handler != SIG_IGN)
sigaction (SIGINT, &new_action, NULL);
sigaction (SIGHUP, NULL, &old_action);
if (old_action.sa_handler != SIG_IGN)
sigaction (SIGHUP, &new_action, NULL);
sigaction (SIGTERM, NULL, &old_action);
示例5: parsXml
bool XmlResLoader::parsXml(const char* szFile)
{
computers.clear();
ErrorLogger* logger = ErrorLogger::Instance();
TiXmlDocument doc(szFile);
if(!doc.LoadFile())
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" at line "\
<<doc.ErrorRow()<<": ";
err<<doc.ErrorDesc();
logger->addError(err);
return false;
}
/* retrieving root module */
TiXmlElement *root = doc.RootElement();
if(!root)
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" . ";
err<<"No root element.";
logger->addError(err);
return false;
}
if(!compareString(root->Value(), "resources"))
{
/*
OSTRINGSTREAM msg;
msg<<szFile<<" is not a resource descriptor file.";
logger->addWarning(msg);
*/
return false;
}
/* retrieving all computers descriptions */
for(TiXmlElement* restag = root->FirstChildElement();
restag; restag = restag->NextSiblingElement())
{
/* retrieving a computer resource */
if(compareString(restag->Value(), "computer"))
{
Computer computer;
computer.setXmlFile(szFile);
for(TiXmlElement* comptag = restag->FirstChildElement();
comptag; comptag = comptag->NextSiblingElement())
{
/* retrieving name */
if(compareString(comptag->Value(), "name"))
computer.setName(comptag->GetText());
/* retrieving description */
if(compareString(comptag->Value(), "description"))
computer.setDescription(comptag->GetText());
/* retrieving disablility */
if(compareString(comptag->Value(), "disable"))
{
if(compareString(comptag->GetText(), "yes"))
computer.setDisable(true);
}
// platform
if(compareString(comptag->Value(), "platform"))
{
Platform os;
TiXmlElement* element;
if((element = (TiXmlElement*) comptag->FirstChild("name")))
os.setName(element->GetText());
else
{
OSTRINGSTREAM war;
war<<"Platform from "<<szFile<<" at line "\
<<comptag->Row()<<" has no name.";
logger->addWarning(war);
}
if((element = (TiXmlElement*) comptag->FirstChild("distribution")))
os.setDistribution(element->GetText());
if((element = (TiXmlElement*) comptag->FirstChild("release")))
os.setRelease(element->GetText());
computer.setPlatform(os);
} // end of platform tag
// memory
if(compareString(comptag->Value(), "memory"))
{
Memory mem;
TiXmlElement* element;
if((element = (TiXmlElement*) comptag->FirstChild("total_space")))
mem.setTotalSpace((Capacity)atol(element->GetText()));
computer.setMemory(mem);
} // end of memory tag
// storage
//.........这里部分代码省略.........
示例6: validate
bool Arbitrator::validate(void)
{
ErrorLogger* logger = ErrorLogger::Instance();
if(!trainWeights())
return false;
#ifdef WITH_YARPMATH
//#if (GSL_MAJOR_VERSION >= 1 && GSL_MINOR_VERSION >= 14)
int n = alphas.size();
if(n == 0)
return true;
yarp::sig::Matrix A(n, n);
std::map<std::string, std::map<std::string, double> >::iterator itr; // iterating over rows
std::map<std::string, std::map<std::string, double> >::iterator jtr; // iterating over cols
int row = 0;
for(itr=alphas.begin(); itr!=alphas.end(); itr++)
{
std::map<std::string, double>& w = itr->second;
int col = 0;
for(jtr=alphas.begin(); jtr!=alphas.end(); jtr++)
{
std::string opnd = jtr->first;
if(w.find(opnd) != w.end())
A(row,col) = w[opnd];
else
A(row,col) = 0.0;
col++;
}
row++;
}
//printf("%s\n\n", A.toString(1).c_str());
yarp::sig::Vector real;
yarp::sig::Vector img;
yarp::math::eingenValues(A, real, img);
bool bStable = true;
for(size_t i=0; i<real.size(); i++)
{
if((float)fabs(real[i]) >= 1.0)
{
bStable = false;
logger->addError("Inconsistency in logical expressions. This will result an unstable arbitration system!");
break;
}
}
return bStable;
/*
gsl_vector_complex *eval = gsl_vector_complex_alloc(n);
gsl_matrix_complex *evec = gsl_matrix_complex_alloc(n, n);
gsl_eigen_nonsymmv_workspace * w = gsl_eigen_nonsymmv_alloc(n);
gsl_eigen_nonsymmv ((gsl_matrix *)A.getGslMatrix(), eval, evec, w);
bool bStable = true;
for(int i=0; i<n; i++)
{
gsl_complex eval_i = gsl_vector_complex_get (eval, i);
if((float)fabs(GSL_REAL(eval_i)) >= 1.0)
{
bStable = false;
logger->addError("Inconsistency in logical expressions. This will result an unstable arbitration system!");
break;
}
//printf ("eigenvalue = %.2f + %.2fi\n", GSL_REAL(eval_i), GSL_IMAG(eval_i));
}
gsl_eigen_nonsymmv_free(w);
gsl_vector_complex_free(eval);
gsl_matrix_complex_free(evec);
return bStable;
*/
//#else //GSL_VERSION
// logger->addWarning("The version of GNU Scientific Library (GSL) used in libYarpMath is insufficient (GSL_VERSION < 1.14). Your compact logical expression might result an unstable arbitration system!");
// return true;
//#endif //GSL_VERSION
#else //WITH_YARPMATH
logger->addWarning("Yarpmanager is compiled without libYarpMath. Your compact logical expression might result an unstable arbitration system!");
return true;
#endif //WITH_YARPMATH
}
示例7: startModule
void Ready::startModule(void)
{
ErrorLogger* logger = ErrorLogger::Instance();
// wait for priority ports if auto connecte is enabled
if(executable->autoConnect())
{
bAborted = false;
while(!checkPriorityPorts())
{
yarp::os::Time::delay(1.0);
if(bAborted) return;
}
}
// finding maximum resource-waiting timeout
ResourceIterator itr;
double maxTimeout = 0;
for(itr=executable->getResources().begin();
itr!=executable->getResources().end(); itr++)
{
if((*itr).getTimeout() > maxTimeout)
maxTimeout = (*itr).getTimeout();
}
// waiting for resources
double base = yarp::os::Time::now();
while(!checkResources())
{
if(bAborted) return;
if(timeout(base, maxTimeout))
{
OSTRINGSTREAM msg;
msg<<"cannot run "<<executable->getCommand()<<" on "<<executable->getHost();
msg<<" : Timeout while waiting for some resources.";
logger->addError(msg);
castEvent(EventFactory::startModuleEventFailed);
executable->getEvent()->onExecutableDied(executable);
return;
}
}
if(!executable->getBroker()->start())
{
OSTRINGSTREAM msg;
msg<<"cannot run "<<executable->getCommand()<<" on "<<executable->getHost();
if(executable->getBroker()->error())
msg<<" : "<<executable->getBroker()->error();
logger->addError(msg);
castEvent(EventFactory::startModuleEventFailed);
executable->getEvent()->onExecutableDied(executable);
}
else
{
castEvent(EventFactory::startModuleEventOk);
executable->getEvent()->onExecutableStart(executable);
}
}
示例8: checkExpression
bool BinaryExpParser::checkExpression(std::string& strexp)
{
ErrorLogger* logger = ErrorLogger::Instance();
if(std::count(strexp.begin(), strexp.end(), '(') !=
std::count(strexp.begin(), strexp.end(), ')'))
{
logger->addError("Incorrect expression format! (parentheses do not match)");
return false;
}
if(std::count(strexp.begin(), strexp.end(), IMPLY) != 1 )
{
logger->addError("Incorrect expression format! (no implication ':' found)");
return false;
}
// erassing all the sapces
strexp.erase(std::remove_if(strexp.begin(), strexp.end(), ::isspace), strexp.end());
if(!strexp.size())
{
logger->addError("Empty expression!");
return false;
}
// making a copy of strexp and checking more
string dummy = strexp;
// removing all pranteses
dummy.erase(std::remove_if(dummy.begin(), dummy.end(), isParentheses), dummy.end());
leftOpr = dummy.substr(0, dummy.find(IMPLY));
if(!leftOpr.size())
{
logger->addError("Missing operand before ':'");
return false;
}
if(dummy.find(IMPLY) == (dummy.size()-1))
{
logger->addError("Missing operands after ':'");
return false;
}
dummy.erase(0, dummy.find(IMPLY)+1);
if(dummy.find(leftOpr) != string::npos)
{
std::string msg;
msg = "recursive assignment of operand '" + leftOpr + "'";
logger->addError(msg.c_str());
return false;
}
// checking '~'
size_t n = dummy.find(EXPNOT);
while(n != string::npos)
{
OSTRINGSTREAM msg;
bool bError = ((n+1) == dummy.length()); // empty operand after ~
if((n+1) < dummy.length())
{
bError |= (dummy[n+1] == EXPAND); // operator & after ~
bError |= (dummy[n+1] == EXPOR); // operand | after ~
}
if(n != 0)
bError |= (dummy[n-1] != EXPAND) && (dummy[n-1] != EXPOR); // an operand before ~
if(bError)
{
msg<<"Incorrect expression format of '~' at "<<(int)n;
logger->addError(msg.str().c_str());
return false;
}
n = dummy.find(EXPNOT, n+1);
}
// checking '| &'
n = dummy.find_first_of("&|");
while(n != string::npos)
{
OSTRINGSTREAM msg;
bool bError = ((n+1) == dummy.length()); // empty operand after & or |
if((n+1) < dummy.length())
{
bError |= (dummy[n+1] == EXPAND); // operator & after & or |
bError |= (dummy[n+1] == EXPOR); // operand | after & or |
}
bError |= (n == 0); // empty operand before & or |
if(n != 0)
{
bError |= (dummy[n-1] == EXPAND); // operator & before & or |
bError |= (dummy[n-1] == EXPOR); // operand | before & or |
bError |= (dummy[n-1] == EXPOR); // operand ~ before & or |
}
if(bError)
{
msg<<"Incorrect expression format of '&' or '|' at "<<(int)n;
logger->addError(msg.str().c_str());
return false;
}
n = dummy.find_first_of("&|", n+1);
}
// at the end
strexp.erase(0, strexp.find(IMPLY)+1);
//.........这里部分代码省略.........