blob: d5bca3040d2a11e1edff11fc65275b74c2b8d4ed [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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>
Neale Ranns10e7a9f2017-11-14 08:40:43 -080021#include <memory>
Neale Ranns812ed392017-10-16 04:20:13 -070022#include <ostream>
23#include <string>
Neale Ranns10e7a9f2017-11-14 08:40:43 -080024#include <vector>
Neale Ranns812ed392017-10-16 04:20:13 -070025
26namespace VOM {
27/**
28 * A means to inspect the state VPP has built, in total, and per-client
29 */
30class inspect
31{
32public:
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 */
54 class command_handler
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
73private:
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