optimized
This commit is contained in:
+26
-25
@@ -931,7 +931,7 @@ void Message::decode(bool leadingSeparator, OutputFormat outputFormat, ostringst
|
||||
if (leadingSeparator) {
|
||||
*output << ",";
|
||||
}
|
||||
*output << "\n \"" << getName() << "\": {"
|
||||
*output << "\n \"" << getName() << "\": {" // TODO include read/write/passive for overlapping names
|
||||
<< "\n \"lastup\": " << setw(0) << dec << static_cast<unsigned>(getLastUpdateTime());
|
||||
if (getLastUpdateTime() != 0) {
|
||||
*output << ",\n \"zz\": \"" << setfill('0') << setw(2) << hex << static_cast<unsigned>(getDstAddress()) << "\"";
|
||||
@@ -1626,31 +1626,31 @@ result_t Instruction::create(const string& contextPath, const string& type,
|
||||
return RESULT_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
string Instruction::getDestination() const {
|
||||
void Instruction::getDestination(ostringstream* ostream) const {
|
||||
// ZZ.circuit[.suffix]
|
||||
string ret;
|
||||
bool empty = true;
|
||||
auto it = m_defaults.find("zz");
|
||||
if (it != m_defaults.end() && !it->second.empty()) {
|
||||
ret = it->second;
|
||||
*ostream << it->second;
|
||||
empty = false;
|
||||
}
|
||||
it = m_defaults.find("circuit");
|
||||
string circuit = it == m_defaults.end() ? "" : it->second;
|
||||
it = m_defaults.find("suffix");
|
||||
string suffix = it == m_defaults.end() ? "" : it->second;
|
||||
if (!circuit.empty() || !suffix.empty()) {
|
||||
if (!ret.empty()) {
|
||||
ret += ".";
|
||||
if (!empty) {
|
||||
*ostream << ".";
|
||||
}
|
||||
if (circuit.empty()) {
|
||||
ret += "*";
|
||||
*ostream << "*";
|
||||
} else {
|
||||
ret += circuit;
|
||||
*ostream << circuit;
|
||||
}
|
||||
if (!suffix.empty()) {
|
||||
ret += suffix;
|
||||
*ostream << suffix;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1661,14 +1661,17 @@ result_t LoadInstruction::execute(MessageMap* messages, ostringstream* log) {
|
||||
*log << ", ";
|
||||
}
|
||||
if (result != RESULT_OK) {
|
||||
*log << "error " << (isSingleton() ? "loading \"" : "including \"") << m_filename << "\" for \""
|
||||
<< getDestination() << "\": " << getResultCode(result);
|
||||
*log << "error " << (isSingleton() ? "loading \"" : "including \"") << m_filename << "\" for \"";
|
||||
getDestination(log);
|
||||
*log << "\": " << getResultCode(result);
|
||||
if (!errorDescription.empty()) {
|
||||
*log << " " << errorDescription;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
*log << (isSingleton() ? "loaded \"" : "included \"") << m_filename << "\" for \"" << getDestination() << "\"";
|
||||
*log << (isSingleton() ? "loaded \"" : "included \"") << m_filename << "\" for \"";
|
||||
getDestination(log);
|
||||
*log << "\"";
|
||||
if (isSingleton() && !m_defaults["zz"].empty()) {
|
||||
result_t temp;
|
||||
symbol_t address = (symbol_t)parseInt(m_defaults["zz"].c_str(), 16, 0, 0xff, &temp);
|
||||
@@ -1678,7 +1681,7 @@ result_t LoadInstruction::execute(MessageMap* messages, ostringstream* log) {
|
||||
ostringstream out;
|
||||
m_condition->dump(true, &out);
|
||||
comment = out.str();
|
||||
*log << " ("+comment+")";
|
||||
*log << " (" << comment << ")";
|
||||
}
|
||||
messages->addLoadedFile(address, m_filename, comment);
|
||||
}
|
||||
@@ -2228,8 +2231,9 @@ result_t MessageMap::executeInstructions(void (*readMessageFunc)(Message* messag
|
||||
&errorDescription);
|
||||
if (result != RESULT_OK) {
|
||||
overallResult = result;
|
||||
*log << "error resolving condition for \"" << instruction->getDestination() << "\": "
|
||||
<< getResultCode(result);
|
||||
*log << "error resolving condition for \"";
|
||||
instruction->getDestination(log);
|
||||
*log << "\": " << getResultCode(result);
|
||||
if (!errorDescription.empty()) {
|
||||
*log << " " << errorDescription;
|
||||
}
|
||||
@@ -2364,11 +2368,9 @@ Message* MessageMap::find(const string& circuit, const string& name, const strin
|
||||
return NULL;
|
||||
}
|
||||
|
||||
deque<Message*> MessageMap::findAll(const string& circuit, const string& name, const string& levels,
|
||||
bool completeMatch, bool withRead, bool withWrite, bool withPassive,
|
||||
bool includeEmptyLevel, bool onlyAvailable,
|
||||
time_t since, time_t until) const {
|
||||
deque<Message*> ret;
|
||||
void MessageMap::findAll(const string& circuit, const string& name, const string& levels,
|
||||
bool completeMatch, bool withRead, bool withWrite, bool withPassive, bool includeEmptyLevel, bool onlyAvailable,
|
||||
time_t since, time_t until, deque<Message*>* messages) const {
|
||||
string lcircuit = circuit;
|
||||
FileReader::tolower(&lcircuit);
|
||||
string lname = name;
|
||||
@@ -2422,12 +2424,10 @@ deque<Message*> MessageMap::findAll(const string& circuit, const string& name, c
|
||||
}
|
||||
}
|
||||
if (!onlyAvailable || message->isAvailable()) {
|
||||
ret.push_back(message);
|
||||
messages->push_back(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Message* MessageMap::find(const MasterSymbolString& master, bool anyDestination,
|
||||
@@ -2510,7 +2510,8 @@ void MessageMap::invalidateCache(Message* message) {
|
||||
message->m_lastUpdateTime = 0;
|
||||
string circuit = message->getCircuit();
|
||||
string name = message->getName();
|
||||
deque<Message*> messages = findAll(circuit, name, "*", true, true, true, true);
|
||||
deque<Message*> messages;
|
||||
findAll(circuit, name, "*", true, true, true, true, true, true, 0, 0, &messages);
|
||||
for (auto checkMessage : messages) {
|
||||
if (checkMessage != message) {
|
||||
checkMessage->m_lastUpdateTime = 0;
|
||||
|
||||
Reference in New Issue
Block a user