FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
inspect.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
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 #ifndef __VOM_INSPECT_H__
17 #define __VOM_INSPECT_H__
18 
19 #include <deque>
20 #include <map>
21 #include <memory>
22 #include <ostream>
23 #include <string>
24 #include <vector>
25 
26 namespace VOM {
27 /**
28  * A means to inspect the state VPP has built, in total, and per-client
29  */
30 class inspect
31 {
32 public:
33  /**
34  * Constructor
35  */
36  inspect() = default;
37 
38  /**
39  * Destructor to tidyup socket resources
40  */
41  ~inspect() = default;
42 
43  /**
44  * handle input from the requester
45  *
46  * @param input command
47  * @param output output
48  */
49  void handle_input(const std::string& input, std::ostream& output);
50 
51  /**
52  * inspect command handler Handler
53  */
55  {
56  public:
57  command_handler() = default;
58  virtual ~command_handler() = default;
59 
60  /**
61  * Show each object
62  */
63  virtual void show(std::ostream& os) = 0;
64  };
65 
66  /**
67  * Register a command handler for inspection
68  */
69  static void register_handler(const std::vector<std::string>& cmds,
70  const std::string& help,
71  command_handler* ch);
72 
73 private:
74  /**
75  * command handler list
76  */
77  static std::unique_ptr<std::map<std::string, command_handler*>>
78  m_cmd_handlers;
79  /**
80  * help handler list
81  */
82  static std::unique_ptr<
83  std::deque<std::pair<std::vector<std::string>, std::string>>>
84  m_help_handlers;
85 };
86 };
87 
88 /*
89  * fd.io coding-style-patch-verification: ON
90  *
91  * Local Variables:
92  * eval: (c-set-style "mozilla")
93  * End:
94  */
95 
96 #endif
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
Definition: inspect.cpp:85
~inspect()=default
Destructor to tidyup socket resources.
A means to inspect the state VPP has built, in total, and per-client.
Definition: inspect.hpp:30
void handle_input(const std::string &input, std::ostream &output)
handle input from the requester
Definition: inspect.cpp:32
inspect command handler Handler
Definition: inspect.hpp:54
virtual void show(std::ostream &os)=0
Show each object.
virtual ~command_handler()=default
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
inspect()=default
Constructor.