removed extra function call overhead again
This commit is contained in:
+1
-12
@@ -699,17 +699,6 @@ static result_t readConfigFiles(const string path, const string extension, Messa
|
|||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method for logging loading of a configuration file.
|
|
||||||
* @param messages the @a MessageMap instance.
|
|
||||||
* @param address the address for which the file was loaded.
|
|
||||||
* @param file the name of the loaded file.
|
|
||||||
*/
|
|
||||||
void logFileLoaded(MessageMap* messages, const unsigned char address, string file)
|
|
||||||
{
|
|
||||||
messages->addLoadedFile(address, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for immediate reading of a @a Message from the bus.
|
* Helper method for immediate reading of a @a Message from the bus.
|
||||||
* @param message the @a Message to read.
|
* @param message the @a Message to read.
|
||||||
@@ -738,7 +727,7 @@ void executeInstructions(MessageMap* messages, bool verbose)
|
|||||||
logError(lf_main, "error resolving conditions: %s, %s", getResultCode(result), messages->getLastError().c_str());
|
logError(lf_main, "error resolving conditions: %s, %s", getResultCode(result), messages->getLastError().c_str());
|
||||||
}
|
}
|
||||||
ostringstream log;
|
ostringstream log;
|
||||||
result = messages->executeInstructions(log, logFileLoaded, readMessage);
|
result = messages->executeInstructions(log, readMessage);
|
||||||
if (result != RESULT_OK) {
|
if (result != RESULT_OK) {
|
||||||
logError(lf_main, "error executing instructions: %s, %s, %s", getResultCode(result), messages->getLastError().c_str(), log.str().c_str());
|
logError(lf_main, "error executing instructions: %s, %s, %s", getResultCode(result), messages->getLastError().c_str(), log.str().c_str());
|
||||||
} else if (verbose && log.tellp() > 0) {
|
} else if (verbose && log.tellp() > 0) {
|
||||||
|
|||||||
@@ -1399,7 +1399,7 @@ string Instruction::getDestination()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string filename)) {
|
result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log) {
|
||||||
result_t result = messages->readFromFile(m_filename, false, m_defaultDest, m_defaultCircuit, m_defaultSuffix);
|
result_t result = messages->readFromFile(m_filename, false, m_defaultDest, m_defaultCircuit, m_defaultSuffix);
|
||||||
if (log.tellp()>0) {
|
if (log.tellp()>0) {
|
||||||
log << ", ";
|
log << ", ";
|
||||||
@@ -1409,7 +1409,7 @@ result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log, void
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
log << (isSingleton() ? "loaded " : "included ") << m_filename << " for \"" << getDestination() << "\"";
|
log << (isSingleton() ? "loaded " : "included ") << m_filename << " for \"" << getDestination() << "\"";
|
||||||
if (isSingleton() && loadInfoFunc!=NULL && !m_defaultDest.empty()) {
|
if (isSingleton() && !m_defaultDest.empty()) {
|
||||||
result_t temp;
|
result_t temp;
|
||||||
unsigned char address = (unsigned char)parseInt(m_defaultDest.c_str(), 16, 0, 0xff, temp);
|
unsigned char address = (unsigned char)parseInt(m_defaultDest.c_str(), 16, 0, 0xff, temp);
|
||||||
if (temp==RESULT_OK) {
|
if (temp==RESULT_OK) {
|
||||||
@@ -1420,7 +1420,7 @@ result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log, void
|
|||||||
} else {
|
} else {
|
||||||
filename = m_filename.substr(pos+1);
|
filename = m_filename.substr(pos+1);
|
||||||
}
|
}
|
||||||
(*loadInfoFunc)(messages, address, filename);
|
messages->addLoadedFile(address, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1696,7 +1696,7 @@ result_t MessageMap::resolveCondition(Condition* condition, void (*readMessageFu
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result_t MessageMap::executeInstructions(ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string file), void (*readMessageFunc)(Message* message))
|
result_t MessageMap::executeInstructions(ostringstream& log, void (*readMessageFunc)(Message* message))
|
||||||
{
|
{
|
||||||
m_lastError = "";
|
m_lastError = "";
|
||||||
result_t overallResult = RESULT_OK;
|
result_t overallResult = RESULT_OK;
|
||||||
@@ -1725,7 +1725,7 @@ result_t MessageMap::executeInstructions(ostringstream& log, void (*loadInfoFunc
|
|||||||
if (instruction->isSingleton()) {
|
if (instruction->isSingleton()) {
|
||||||
removeSingletons = true;
|
removeSingletons = true;
|
||||||
}
|
}
|
||||||
result_t result = instruction->execute(this, log, loadInfoFunc);
|
result_t result = instruction->execute(this, log);
|
||||||
if (result!=RESULT_OK) {
|
if (result!=RESULT_OK) {
|
||||||
overallResult = result;
|
overallResult = result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1010,10 +1010,9 @@ public:
|
|||||||
* Execute the instruction.
|
* Execute the instruction.
|
||||||
* @param messages the @a MessageMap.
|
* @param messages the @a MessageMap.
|
||||||
* @param log the @a ostringstream to log success messages to (if necessary).
|
* @param log the @a ostringstream to log success messages to (if necessary).
|
||||||
* @param loadInfoFunc the function to call for successful loading of a file for a certain address, or NULL.
|
|
||||||
* @return @a RESULT_OK on success, or an error code.
|
* @return @a RESULT_OK on success, or an error code.
|
||||||
*/
|
*/
|
||||||
virtual result_t execute(MessageMap* messages, ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string filename)=NULL) = 0;
|
virtual result_t execute(MessageMap* messages, ostringstream& log) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -1062,7 +1061,7 @@ public:
|
|||||||
virtual ~LoadInstruction() { }
|
virtual ~LoadInstruction() { }
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
virtual result_t execute(MessageMap* messages, ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string filename)=NULL);
|
virtual result_t execute(MessageMap* messages, ostringstream& log);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -1150,12 +1149,11 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Run all executable @a Instruction instances.
|
* Run all executable @a Instruction instances.
|
||||||
* @param log the @a ostringstream to log success messages to (if necessary).
|
* @param log the @a ostringstream to log success messages to (if necessary).
|
||||||
* @param loadInfoFunc the function to call for successful loading of a file for a participant, or NULL.
|
|
||||||
* @param readMessageFunc the function to call for immediate reading of a
|
* @param readMessageFunc the function to call for immediate reading of a
|
||||||
* @a Message values from the bus required for singleton instructions, or NULL.
|
* @a Message values from the bus required for singleton instructions, or NULL.
|
||||||
* @return @a RESULT_OK on success, or an error code.
|
* @return @a RESULT_OK on success, or an error code.
|
||||||
*/
|
*/
|
||||||
result_t executeInstructions(ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string file)=NULL, void (*readMessageFunc)(Message* message)=NULL);
|
result_t executeInstructions(ostringstream& log, void (*readMessageFunc)(Message* message)=NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a loaded file to a participant.
|
* Add a loaded file to a participant.
|
||||||
|
|||||||
Reference in New Issue
Block a user