• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIBTEXTCLASSIFIER_UTILS_GRAMMAR_CALLBACK_DELEGATE_H_
18 #define LIBTEXTCLASSIFIER_UTILS_GRAMMAR_CALLBACK_DELEGATE_H_
19 
20 #include "utils/base/integral_types.h"
21 #include "utils/grammar/match.h"
22 #include "utils/grammar/rules_generated.h"
23 #include "utils/grammar/types.h"
24 
25 namespace libtextclassifier3::grammar {
26 
27 class Matcher;
28 
29 // CallbackDelegate is an interface and default implementation used by the
30 // grammar matcher to dispatch rule matches.
31 class CallbackDelegate {
32  public:
33   virtual ~CallbackDelegate() = default;
34 
35   // This is called by the matcher whenever it finds a match for a rule to
36   // which a  callback is attached.
MatchFound(const Match * match,const CallbackId callback_id,const int64 callback_param,Matcher * matcher)37   virtual void MatchFound(const Match* match, const CallbackId callback_id,
38                           const int64 callback_param, Matcher* matcher) {}
39 };
40 
41 }  // namespace libtextclassifier3::grammar
42 
43 #endif  // LIBTEXTCLASSIFIER_UTILS_GRAMMAR_CALLBACK_DELEGATE_H_
44