Scanner C++ API
sink_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/sink.h"
19 #include "scanner/util/common.h"
20 
21 #include <vector>
22 
23 namespace scanner {
24 
25 namespace internal {
26 
30 class SinkFactory {
31  public:
32  SinkFactory(const std::string& name, bool variadic_inputs,
33  const std::vector<Column>& input_columns, bool per_element_output,
34  bool entire_stream_output, const std::string& protobuf_name,
35  const std::string& stream_protobuf_name,
36  SinkConstructor constructor)
37  : name_(name),
38  variadic_inputs_(variadic_inputs),
39  input_columns_(input_columns),
40  per_element_output_(per_element_output),
41  entire_stream_output_(entire_stream_output),
42  protobuf_name_(protobuf_name),
43  stream_protobuf_name_(stream_protobuf_name),
44  constructor_(constructor) {}
45 
46  const std::string& get_name() const { return name_; }
47 
48  const bool variadic_inputs() const { return variadic_inputs_; }
49 
50  const std::vector<Column>& input_columns() const { return input_columns_; }
51 
52  const bool per_element_output() const { return per_element_output_; }
53 
54  const bool entire_stream_output() const { return entire_stream_output_; }
55 
56  const std::string& protobuf_name() const { return protobuf_name_; }
57 
58  const std::string& stream_protobuf_name() const {
59  return stream_protobuf_name_;
60  }
61 
62  /* @brief Constructs a Sink to be used for writing elements
63  */
64  Sink* new_instance(const SinkConfig& config) { return constructor_(config); }
65 
66  private:
67  std::string name_;
68  bool variadic_inputs_;
69  std::vector<Column> input_columns_;
70  bool per_element_output_;
71  bool entire_stream_output_;
72  std::string protobuf_name_;
73  std::string stream_protobuf_name_;
74  SinkConstructor constructor_;
75 };
76 }
77 }
Interface for reading data in a computation graph.
Definition: sink.h:42
Interface for constructing Sinks at runtime.
Definition: sink_factory.h:30
Definition: database.cpp:36
Parameters provided at instantiation of Sink node.
Definition: sink.h:28