logic: indexer commands

* replaced parser arguments by project specific IndexerCommands that know everything the indexer needs to know to do its job
* added different language and project specific indexers that know how to handle a certain kind of indexer command
* refactored FileManager and FileRegister to have less overhead
* removed no-rtti restriction for clang files in lib cxx
* uncommented deprecated interprocess code.

fortune cookie message = Happiness will bring you good luck.
This commit is contained in:
malte_langkabel
2017-02-22 16:42:20 +01:00
parent 650cd8101e
commit 4563cbe90a
101 changed files with 1908 additions and 1120 deletions
+109
View File
@@ -0,0 +1,109 @@
#include "data/indexer/TaskBuildIndex.h"
#include "data/indexer/IndexerFactory.h"
#include "data/indexer/IndexerCommandList.h"
#include "data/indexer/IndexerComposite.h"
#include "data/StorageProvider.h"
#include "component/view/DialogView.h"
#include "utility/file/FileRegister.h"
#include "utility/file/FileRegisterStateData.h"
#include "utility/scheduling/Blackboard.h"
#include "ApplicationStateMonitor.h"
TaskBuildIndex::TaskBuildIndex(
std::shared_ptr<IndexerCommandList> indexerCommandList,
std::shared_ptr<StorageProvider> storageProvider,
std::shared_ptr<FileRegisterStateData> fileRegisterStateData,
DialogView* dialogView
)
: m_indexerCommandList(indexerCommandList)
, m_storageProvider(storageProvider)
, m_fileRegisterStateData(fileRegisterStateData)
, m_dialogView(dialogView)
{
m_indexer = IndexerFactory::getInstance()->createCompositeIndexerForAllRegisteredModules();
}
void TaskBuildIndex::doEnter(std::shared_ptr<Blackboard> blackboard)
{
std::lock_guard<std::mutex> lock(blackboard->getMutex());
int indexerCount = 0;
if (blackboard->get("indexer_count", indexerCount))
{
indexerCount++;
blackboard->set("indexer_count", indexerCount);
}
}
Task::TaskState TaskBuildIndex::doUpdate(std::shared_ptr<Blackboard> blackboard)
{
std::shared_ptr<IndexerCommand> indexerCommand = m_indexerCommandList->consumeCommand();
if (!indexerCommand)
{
return STATE_FAILURE;
}
else
{
ApplicationStateMonitor::getInstance()->addIndexingFile(indexerCommand->getSourceFilePath());
{
std::lock_guard<std::mutex> lock(blackboard->getMutex());
int sourceFileCount = 0;
blackboard->get("source_file_count", sourceFileCount);
int indexedSourceFileCount = 0;
blackboard->get("indexed_source_file_count", indexedSourceFileCount);
m_dialogView->updateIndexingDialog(
indexedSourceFileCount, sourceFileCount, indexerCommand->getSourceFilePath().str()
);
}
// file register only copies the DileRegisterStateData
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(
*(m_fileRegisterStateData.get()), indexerCommand->getIndexedPaths(), indexerCommand->getExcludedPath()
);
std::shared_ptr<IntermediateStorage> storage = m_indexer->index(indexerCommand, fileRegister);
if (storage)
{
// only write back the changes made to FileRegisterStateData if the indexer actually succeeded
m_fileRegisterStateData->inject(fileRegister->getStateData());
m_storageProvider->insert(storage);
std::lock_guard<std::mutex> lock(blackboard->getMutex());
int indexedSourceFileCount = 0;
blackboard->get("indexed_source_file_count", indexedSourceFileCount);
blackboard->set("indexed_source_file_count", indexedSourceFileCount + 1);
}
ApplicationStateMonitor::getInstance()->removeIndexingFile(indexerCommand->getSourceFilePath());
}
return (m_indexer->interrupted() ? STATE_FAILURE : STATE_SUCCESS);
}
void TaskBuildIndex::doExit(std::shared_ptr<Blackboard> blackboard)
{
std::lock_guard<std::mutex> lock(blackboard->getMutex());
int indexerCount = 0;
if (blackboard->get("indexer_count", indexerCount))
{
indexerCount--;
blackboard->set("indexer_count", indexerCount);
}
}
void TaskBuildIndex::doReset(std::shared_ptr<Blackboard> blackboard)
{
}
void TaskBuildIndex::handleMessage(MessageInterruptTasks* message)
{
m_indexer->interrupt();
}