1
#pragma once
2

            
3
#include "envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.h"
4
#include "envoy/extensions/matching/common_inputs/network/v3/network_inputs.pb.validate.h"
5
#include "envoy/matcher/matcher.h"
6
#include "envoy/network/filter.h"
7
#include "envoy/registry/registry.h"
8

            
9
#include "source/common/network/utility.h"
10

            
11
namespace Envoy {
12
namespace Network {
13
namespace Matching {
14

            
15
template <class InputType, class ProtoType, class MatchingDataType>
16
class BaseFactory : public Matcher::DataInputFactory<MatchingDataType> {
17
protected:
18
  explicit BaseFactory(const std::string& name) : name_(name) {}
19

            
20
public:
21
  std::string name() const override { return "envoy.matching.inputs." + name_; }
22

            
23
  Matcher::DataInputFactoryCb<MatchingDataType>
24
  createDataInputFactoryCb(const Protobuf::Message&, ProtobufMessage::ValidationVisitor&) override {
25
    return []() { return std::make_unique<InputType>(); };
26
  };
27
  ProtobufTypes::MessagePtr createEmptyConfigProto() override {
28
    return std::make_unique<ProtoType>();
29
  }
30

            
31
private:
32
  const std::string name_;
33
};
34

            
35
} // namespace Matching
36
} // namespace Network
37
} // namespace Envoy