|
|
|
@@ -4,11 +4,10 @@
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
#include "data/indexer/IndexerBase.h"
|
|
|
|
|
#include "data/parser/ParserClientImpl.h"
|
|
|
|
|
#include "utility/file/FileRegister.h"
|
|
|
|
|
#include "data/indexer/IndexerCommand.h"
|
|
|
|
|
#include "utility/logging/logging.h"
|
|
|
|
|
|
|
|
|
|
template <typename IndexerCommandType, typename ParserType>
|
|
|
|
|
template <typename IndexerCommandType>
|
|
|
|
|
class Indexer
|
|
|
|
|
: public IndexerBase
|
|
|
|
|
{
|
|
|
|
@@ -20,21 +19,25 @@ public:
|
|
|
|
|
virtual std::shared_ptr<IntermediateStorage> index(
|
|
|
|
|
std::shared_ptr<IndexerCommand> indexerCommand,
|
|
|
|
|
std::shared_ptr<FileRegister> fileRegister);
|
|
|
|
|
|
|
|
|
|
virtual std::shared_ptr<IntermediateStorage> doIndex(
|
|
|
|
|
std::shared_ptr<IndexerCommandType> indexerCommand,
|
|
|
|
|
std::shared_ptr<FileRegister> fileRegister) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename IndexerCommandType, typename ParserType>
|
|
|
|
|
Indexer<IndexerCommandType, ParserType>::~Indexer()
|
|
|
|
|
template <typename IndexerCommandType>
|
|
|
|
|
Indexer<IndexerCommandType>::~Indexer()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename IndexerCommandType, typename ParserType>
|
|
|
|
|
std::string Indexer<IndexerCommandType, ParserType>::getKindString() const
|
|
|
|
|
template <typename IndexerCommandType>
|
|
|
|
|
std::string Indexer<IndexerCommandType>::getKindString() const
|
|
|
|
|
{
|
|
|
|
|
return IndexerCommandType::getIndexerKindString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename IndexerCommandType, typename ParserType>
|
|
|
|
|
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::index(
|
|
|
|
|
template <typename IndexerCommandType>
|
|
|
|
|
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType>::index(
|
|
|
|
|
std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<IndexerCommandType> castedCommand = std::dynamic_pointer_cast<IndexerCommandType>(indexerCommand);
|
|
|
|
@@ -46,33 +49,7 @@ std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::in
|
|
|
|
|
return std::shared_ptr<IntermediateStorage>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ParserType> parser = std::make_shared<ParserType>(parserClient, fileRegister);
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
|
|
|
|
parserClient->setStorage(storage);
|
|
|
|
|
|
|
|
|
|
parser->buildIndex(castedCommand);
|
|
|
|
|
|
|
|
|
|
parserClient->resetStorage();
|
|
|
|
|
|
|
|
|
|
if (parserClient->hasFatalErrors() || indexerCommand->preprocessorOnly())
|
|
|
|
|
{
|
|
|
|
|
storage->setAllFilesIncomplete();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
storage->setFilesWithErrorsIncomplete();
|
|
|
|
|
fileRegister->markIndexingFilesIndexed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (interrupted())
|
|
|
|
|
{
|
|
|
|
|
return std::shared_ptr<IntermediateStorage>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return storage;
|
|
|
|
|
return doIndex(castedCommand, fileRegister);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // INDEXER_H
|
|
|
|
|