souffle  2.0.2-371-g6315b36
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
souffle::profile::EventProcessorSingleton Class Reference

Event Processor Singleton. More...

#include <EventProcessor.h>

Collaboration diagram for souffle::profile::EventProcessorSingleton:
Collaboration graph

Public Member Functions

void process (ProfileDatabase &db, const char *txt,...)
 process a profile event More...
 
void registerEventProcessor (const std::string &keyword, EventProcessor *processor)
 register an event processor with its keyword More...
 

Static Public Member Functions

static EventProcessorSingletoninstance ()
 get instance More...
 

Private Member Functions

std::string escape (const std::string &text)
 Escape escape characters. More...
 
 EventProcessorSingleton ()=default
 

Static Private Member Functions

static std::vector< std::string > split (std::string str, std::string split_str)
 split string More...
 
static std::vector< std::string > splitSignature (std::string str)
 split string separated by semi-colon More...
 

Private Attributes

std::map< std::string, EventProcessor * > registry
 keyword / event processor mapping More...
 

Detailed Description

Event Processor Singleton.

Singleton that is the connection point for events

Definition at line 67 of file EventProcessor.h.

Constructor & Destructor Documentation

◆ EventProcessorSingleton()

souffle::profile::EventProcessorSingleton::EventProcessorSingleton ( )
privatedefault

Member Function Documentation

◆ escape()

std::string souffle::profile::EventProcessorSingleton::escape ( const std::string &  text)
inlineprivate

Escape escape characters.

Remove all escapes, then escape double quotes.

Definition at line 111 of file EventProcessor.h.

116  {
117  // repeat value when splitting so "a b" -> ["a","b"] not ["a","","","","b"]
118  bool repeat = (split_str == " ");
119 
120  std::vector<std::string> elems;
121 
122  std::string temp;
123  std::string hold;
124  for (size_t i = 0; i < str.size(); i++) {
125  if (repeat) {
126  if (str.at(i) == split_str.at(0)) {
127  while (str.at(++i) == split_str.at(0)) {

◆ instance()

static EventProcessorSingleton& souffle::profile::EventProcessorSingleton::instance ( )
inlinestatic

◆ process()

void souffle::profile::EventProcessorSingleton::process ( ProfileDatabase &  db,
const char *  txt,
  ... 
)
inline

process a profile event

Definition at line 81 of file EventProcessor.h.

86  :
87  /** keyword / event processor mapping */
88  std::map<std::string, EventProcessor*> registry;
89 
90  EventProcessorSingleton() = default;
91 
92  /**
93  * Escape escape characters.
94  *
95  * Remove all escapes, then escape double quotes.
96  */
97  std::string escape(const std::string& text) {
98  std::string str(text);

Referenced by souffle::ProfileEventSingleton::makeConfigRecord(), and souffle::ProfileEventSingleton::~ProfileEventSingleton().

◆ registerEventProcessor()

void souffle::profile::EventProcessorSingleton::registerEventProcessor ( const std::string &  keyword,
EventProcessor processor 
)
inline

◆ split()

static std::vector<std::string> souffle::profile::EventProcessorSingleton::split ( std::string  str,
std::string  split_str 
)
inlinestaticprivate

split string

Definition at line 130 of file EventProcessor.h.

134  {
135  temp += str.at(i);
136  hold += str.at(i);
137  for (size_t j = 0; j < hold.size(); j++) {
138  if (hold[j] != split_str[j]) {
139  hold = "";
140  }
141  }
142  if (hold.size() == split_str.size()) {
143  elems.push_back(temp.substr(0, temp.size() - hold.size()));
144  hold = "";
145  temp = "";
146  }
147  }
148  }
149  if (!temp.empty()) {
150  elems.push_back(temp);
151  }
152 
153  return elems;
154  }
155 
156  /** split string separated by semi-colon */
157  static std::vector<std::string> splitSignature(std::string str) {
158  for (size_t i = 0; i < str.size(); i++) {
159  if (i > 0 && str[i] == ';' && str[i - 1] == '\\') {
160  // I'm assuming this isn't a thing that will be naturally found in souffle profiler files
161  str[i - 1] = '\b';
162  str.erase(i--, 1);
163  }
164  }
165  std::vector<std::string> result = split(str, ";");
166  for (auto& i : result) {
167  for (char& j : i) {
168  if (j == '\b') {

◆ splitSignature()

static std::vector<std::string> souffle::profile::EventProcessorSingleton::splitSignature ( std::string  str)
inlinestaticprivate

split string separated by semi-colon

Definition at line 171 of file EventProcessor.h.

180  : public EventProcessor {
181 public:
182  NonRecursiveRuleTimingProcessor() {
183  EventProcessorSingleton::instance().registerEventProcessor("@t-nonrecursive-rule", this);
184  }
185  void process(ProfileDatabase& db, const std::vector<std::string>& signature, va_list& args) override {
186  const std::string& relation = signature[1];
187  const std::string& srcLocator = signature[2];
188  const std::string& rule = signature[3];

Field Documentation

◆ registry

std::map<std::string, EventProcessor*> souffle::profile::EventProcessorSingleton::registry
private

keyword / event processor mapping

Definition at line 102 of file EventProcessor.h.


The documentation for this class was generated from the following file:
souffle::profile::EventProcessorSingleton::process
void process(ProfileDatabase &db, const char *txt,...)
process a profile event
Definition: EventProcessor.h:81
souffle::profile::EventProcessorSingleton::splitSignature
static std::vector< std::string > splitSignature(std::string str)
split string separated by semi-colon
Definition: EventProcessor.h:171
relation
Relation & relation
Definition: Reader.h:130
j
var j
Definition: htmlJsChartistMin.h:15
str
const std::string & str
Definition: json11.h:662
i
size_t i
Definition: json11.h:663
souffle::profile::EventProcessorSingleton::registry
std::map< std::string, EventProcessor * > registry
keyword / event processor mapping
Definition: EventProcessor.h:102
souffle::profile::EventProcessorSingleton::split
static std::vector< std::string > split(std::string str, std::string split_str)
split string
Definition: EventProcessor.h:130
rule
Rule & rule
Definition: Reader.h:85
souffle::profile::EventProcessorSingleton::EventProcessorSingleton
EventProcessorSingleton()=default
souffle::profile::EventProcessorSingleton::registerEventProcessor
void registerEventProcessor(const std::string &keyword, EventProcessor *processor)
register an event processor with its keyword
Definition: EventProcessor.h:76
souffle::profile::EventProcessorSingleton::escape
std::string escape(const std::string &text)
Escape escape characters.
Definition: EventProcessor.h:111
souffle::profile::EventProcessorSingleton::instance
static EventProcessorSingleton & instance()
get instance
Definition: EventProcessor.h:70