• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017 VMware, Inc.
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 #pragma once
18 
19 #include "table_storage.h"
20 
21 namespace ebpf {
22 
23 class TableStorageIteratorImpl {
24  public:
25   typedef std::pair<const std::string, TableDesc> value_type;
26   typedef value_type *pointer;
27   typedef value_type &reference;
28   typedef TableStorageIteratorImpl self_type;
~TableStorageIteratorImpl()29   virtual ~TableStorageIteratorImpl() {}
30   virtual std::unique_ptr<self_type> clone() const = 0;
31   virtual self_type &operator++() = 0;
32   virtual value_type &operator*() const = 0;
33   virtual pointer operator->() const = 0;
34 
35  private:
36 };
37 
38 class TableStorageImpl {
39  public:
~TableStorageImpl()40   virtual ~TableStorageImpl(){};
41   virtual bool Find(const std::string &name, TableStorage::iterator &result) const = 0;
42   virtual bool Insert(const std::string &name, TableDesc &&desc) = 0;
43   virtual bool Delete(const std::string &name) = 0;
44   virtual std::unique_ptr<TableStorageIteratorImpl> begin() = 0;
45   virtual std::unique_ptr<TableStorageIteratorImpl> end() = 0;
46   virtual std::unique_ptr<TableStorageIteratorImpl> lower_bound(const std::string &k) = 0;
47   virtual std::unique_ptr<TableStorageIteratorImpl> upper_bound(const std::string &k) = 0;
48   virtual std::unique_ptr<TableStorageIteratorImpl> erase(const TableStorageIteratorImpl &it) = 0;
49 };
50 
51 }  // namespace ebpf
52