source: icGREP/icgrep-devel/icgrep/grep_engine.h @ 5735

Last change on this file since 5735 was 5735, checked in by cameron, 2 years ago

Incremental object caching; multithreaded print

File size: 2.3 KB
RevLine 
[4324]1/*
[5476]2 *  Copyright (c) 2017 International Characters.
[4324]3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
[5476]6#ifndef GREP_ENGINE_H
7#define GREP_ENGINE_H
8#include <grep_interface.h>
[5704]9#include <kernels/streamset.h>
[5695]10#include <toolchain/grep_pipeline.h>
[5267]11#include <string>       // for string
12#include <vector>
[5695]13#include <sstream>
14#include <mutex>
[5464]15
[5267]16namespace re { class CC; }
17namespace re { class RE; }
[5473]18namespace llvm { namespace cl { class OptionCategory; } }
[5474]19class Driver;
[4324]20
[5474]21
[5473]22namespace grep {
23
[5406]24class GrepEngine {
[4659]25public:
[4324]26
[5703]27    GrepEngine();
[5698]28    virtual ~GrepEngine();
[5695]29   
[5703]30    void initFileResult(std::vector<std::string> & filenames);
[5698]31    virtual void grepCodeGen(std::vector<re::RE *> REs);
[5703]32    bool searchAllFiles();
[5735]33    void * DoGrepThreadMethod();
34
[5700]35protected:
[5704]36    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> grepPipeline(std::vector<re::RE *> & REs, parabix::StreamSetBuffer * ByteStream);
37
38    virtual uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx);
[5700]39    std::string linePrefix(std::string fileName);
[5707]40    int32_t openFile(const std::string & fileName, std::stringstream * msgstrm);
[5703]41
[5474]42    Driver * mGrepDriver;
[5695]43
[5735]44    enum class FileStatus {Pending, InGrep, GrepComplete, Printing, PrintComplete};
45    std::mutex count_mutex;
46    size_t mNextFileToGrep;
47    size_t mNextFileToPrint;
[5695]48    std::vector<std::string> inputFiles;
[5707]49    std::vector<std::unique_ptr<std::stringstream>> mResultStrs;
[5735]50    std::vector<FileStatus> mFileStatus;
51    bool grepMatchFound;
[5695]52   
[5700]53    std::string mFileSuffix;
[5704]54    bool mMoveMatchesToEOL;
[5735]55    pthread_t mEngineThread;
[4324]56};
57
[5703]58class EmitMatchesEngine : public GrepEngine {
[5698]59public:
[5703]60    EmitMatchesEngine();
[5698]61    void grepCodeGen(std::vector<re::RE *> REs) override;
[5700]62private:
63    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
[5698]64};
65
[5703]66class CountOnlyEngine : public GrepEngine {
[5700]67public:
[5703]68    CountOnlyEngine();
[5700]69private:
70    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
[5703]71};
72
73class MatchOnlyEngine : public GrepEngine {
74public:
75    MatchOnlyEngine(bool showFilesWithoutMatch);
76private:
77    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
[5704]78    unsigned mRequiredCount;
[5700]79};
[5704]80
81class QuietModeEngine : public GrepEngine {
82public:
83    QuietModeEngine();
84};
85
[5473]86}
[5033]87
[4324]88#endif
Note: See TracBrowser for help on using the repository browser.