// Copyright 2018, University of Freiburg, // Chair of Algorithms and Data Structures. // Authors: Patrick Brosi #ifndef PFAEDLE_TRGRAPH_NORMALIZER_H_ #define PFAEDLE_TRGRAPH_NORMALIZER_H_ #include #include #include #include #include #include namespace pfaedle { namespace trgraph { typedef std::pair ReplRule; typedef std::vector ReplRules; typedef std::pair ReplRuleComp; typedef std::vector ReplRulesComp; /* * A class for normalizing station names */ class Normalizer { public: Normalizer() {} explicit Normalizer(const ReplRules& rules); // copy constructor Normalizer(const Normalizer& other); // assignment op Normalizer& operator=(Normalizer other); // Normalize sn, not thread safe std::string norm(const std::string& sn) const; // Normalize sn, thread safe std::string normTS(const std::string& sn) const; // Normalize sn based on the rules of this normalizer, uses the thread safe // version of norm() internally std::string operator()(std::string sn) const; bool operator==(const Normalizer& b) const; private: ReplRulesComp _rules; ReplRules _rulesOrig; mutable std::unordered_map _cache; mutable std::mutex _mutex; void buildRules(const ReplRules& rules); }; } // namespace trgraph } // namespace pfaedle #endif // PFAEDLE_TRGRAPH_NORMALIZER_H_