Scanner C++ API
enumerator_factory.h
1 /* Copyright 2018 Carnegie Mellon University
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include "scanner/api/enumerator.h"
19 #include "scanner/util/common.h"
20 
21 #include <vector>
22 
23 namespace scanner {
24 namespace internal {
25 
30  public:
31  EnumeratorFactory(const std::string& enumerator_name,
32  const std::string& protobuf_name,
33  EnumeratorConstructor constructor)
34  : name_(enumerator_name),
35  protobuf_name_(protobuf_name),
36  constructor_(constructor) {}
37 
38  const std::string& get_name() const { return name_; }
39 
40  const std::string& protobuf_name() const { return protobuf_name_; }
41 
42  /* @brief Constructs a kernel to be used for processing elements of data.
43  */
44  Enumerator* new_instance(const EnumeratorConfig& config) {
45  return constructor_(config);
46  }
47 
48  private:
49  std::string name_;
50  std::string protobuf_name_;
51  EnumeratorConstructor constructor_;
52 };
53 
54 }
55 }
Interface for enumerating available data from a data source.
Definition: enumerator.h:42
Parameters provided at instantiation of an enumerator.
Definition: enumerator.h:29
Interface for constructing enumerators at runtime.
Definition: enumerator_factory.h:29
Definition: database.cpp:36