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

Last change on this file since 5814 was 5804, checked in by cameron, 17 months ago

Fixes

File size: 2.4 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>
[5804]11#include <cc/multiplex_CCs.h>
[5771]12#include <string>
[5267]13#include <vector>
[5695]14#include <sstream>
[5761]15#include <atomic>
[5464]16
[5267]17namespace re { class CC; }
18namespace re { class RE; }
[5473]19namespace llvm { namespace cl { class OptionCategory; } }
[5474]20class Driver;
[4324]21
[5474]22
[5473]23namespace grep {
24
[5406]25class GrepEngine {
[5761]26    enum class FileStatus {Pending, GrepComplete, PrintComplete};
[4659]27public:
[4324]28
[5703]29    GrepEngine();
[5698]30    virtual ~GrepEngine();
[5695]31   
[5703]32    void initFileResult(std::vector<std::string> & filenames);
[5698]33    virtual void grepCodeGen(std::vector<re::RE *> REs);
[5703]34    bool searchAllFiles();
[5735]35    void * DoGrepThreadMethod();
36
[5700]37protected:
[5704]38    std::pair<parabix::StreamSetBuffer *, parabix::StreamSetBuffer *> grepPipeline(std::vector<re::RE *> & REs, parabix::StreamSetBuffer * ByteStream);
39
40    virtual uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx);
[5700]41    std::string linePrefix(std::string fileName);
[5771]42    int32_t openFile(const std::string & fileName, std::ostringstream & msgstrm);
[5703]43
[5474]44    Driver * mGrepDriver;
[5695]45
[5761]46    std::atomic<unsigned> mNextFileToGrep;
47    std::atomic<unsigned> mNextFileToPrint;
[5695]48    std::vector<std::string> inputFiles;
[5771]49    std::vector<std::ostringstream> mResultStrs;
[5735]50    std::vector<FileStatus> mFileStatus;
[5771]51    bool grepMatchFound;
[5761]52
[5804]53    std::unique_ptr<cc::MultiplexedAlphabet> mpx;
[5700]54    std::string mFileSuffix;
[5704]55    bool mMoveMatchesToEOL;
[5735]56    pthread_t mEngineThread;
[4324]57};
58
[5703]59class EmitMatchesEngine : public GrepEngine {
[5698]60public:
[5703]61    EmitMatchesEngine();
[5698]62    void grepCodeGen(std::vector<re::RE *> REs) override;
[5700]63private:
64    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
[5698]65};
66
[5703]67class CountOnlyEngine : public GrepEngine {
[5700]68public:
[5703]69    CountOnlyEngine();
[5700]70private:
71    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
[5703]72};
73
74class MatchOnlyEngine : public GrepEngine {
75public:
76    MatchOnlyEngine(bool showFilesWithoutMatch);
77private:
78    uint64_t doGrep(const std::string & fileName, const uint32_t fileIdx) override;
[5704]79    unsigned mRequiredCount;
[5700]80};
[5704]81
82class QuietModeEngine : public GrepEngine {
83public:
84    QuietModeEngine();
85};
86
[5473]87}
[5033]88
[4324]89#endif
Note: See TracBrowser for help on using the repository browser.