Scanner C++ API
source_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/source.h"
19 #include "scanner/util/common.h"
20 
21 #include <vector>
22 
23 namespace scanner {
24 
25 namespace internal {
26 
31  public:
32  SourceFactory(const std::string& name,
33  const std::vector<Column>& output_columns,
34  const std::string& protobuf_name,
35  SourceConstructor constructor)
36  : name_(name),
37  output_columns_(output_columns),
38  protobuf_name_(protobuf_name),
39  constructor_(constructor) {}
40 
41  const std::string& get_name() const { return name_; }
42 
43  const std::vector<Column>& output_columns() const { return output_columns_; }
44 
45  const std::string& protobuf_name() const { return protobuf_name_; }
46 
47  /* @brief Constructs a source to be used for reading elements
48  */
49  Source* new_instance(const SourceConfig& config) {
50  return constructor_(config);
51  }
52 
53  private:
54  std::string name_;
55  std::vector<Column> output_columns_;
56  std::string protobuf_name_;
57  SourceConstructor constructor_;
58 };
59 }
60 }
Parameters provided at instantiation of Source node.
Definition: source.h:29
Interface for constructing Sources at runtime.
Definition: source_factory.h:30
Interface for reading data in a computation graph.
Definition: source.h:43
Definition: database.cpp:36