Fix coverity warnings in VOM and VAPI
[vpp.git] / src / vpp-api / vom / cmd.hpp
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_CMD_H__
17 #define __VOM_CMD_H__
18
19 #include <string>
20
21 #include "vom/types.hpp"
22
23 #include <vapi/vapi.hpp>
24
25 namespace VOM {
26 /**
27  * Forward declaration of the connection class
28  */
29 class connection;
30
31 /**
32  * A representation of a method call to VPP
33  */
34 class cmd
35 {
36 public:
37   /**
38    * Default constructor
39    */
40   cmd() {}
41   /**
42    * Virtual destructor
43    */
44   virtual ~cmd() {}
45
46   /**
47    * Issue the command to VPP/HW
48    */
49   virtual rc_t issue(connection& con) = 0;
50
51   /**
52    * Retire/cancel a long running command
53    */
54   virtual void retire(connection& con) = 0;
55
56   /**
57    * Invoked on a Command when the HW queue is disabled to indicate
58    * that the commnad can be considered successful
59    */
60   virtual void succeeded() = 0;
61
62   /**
63    * convert to string format for debug purposes
64    */
65   virtual std::string to_string() const = 0;
66 };
67
68 /**
69  * Free ostream function to print a command
70  */
71 std::ostream& operator<<(std::ostream& os, const cmd& cmd);
72 };
73
74 /*
75  * fd.io coding-style-patch-verification: ON
76  *
77  * Local Variables:
78  * eval: (c-set-style "mozilla")
79  * End:
80  */
81
82 #endif