Ignition Fuel_tools

API Reference

4.4.0
Result.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
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 
18 #ifndef IGNITION_FUEL_TOOLS_RESULT_HH_
19 #define IGNITION_FUEL_TOOLS_RESULT_HH_
20 
21 #include <memory>
22 #include <string>
23 
24 #include "ignition/fuel_tools/Export.hh"
25 
26 #ifdef _WIN32
27 // Disable warning C4251 which is triggered by
28 // std::unique_ptr
29 #pragma warning(push)
30 #pragma warning(disable: 4251)
31 #endif
32 
33 namespace ignition
34 {
35  namespace fuel_tools
36  {
37  // forward declaration
38  class ResultPrivate;
39  class Model;
40 
42  enum class ResultType
43  {
45  UNKNOWN = 0,
46 
48  DELETE,
49 
52 
56 
58  FETCH,
59 
62 
65 
69 
71  UPLOAD,
72 
75 
79 
82 
84  PATCH,
85  };
86 
88  class IGNITION_FUEL_TOOLS_VISIBLE Result
89  {
91  public: Result();
92 
94  public: ~Result();
95 
98  public: explicit Result(const ResultType _type);
99 
102  public: Result(const Result &_result);
103 
106  public: Result(Result &&_result) noexcept; // NOLINT
107 
110  public: Result &operator=(const Result &_result);
111 
115  public: Result &operator=(Result &&_result) noexcept; // NOLINT
116 
119  public: ResultType Type() const;
120 
123  public: virtual operator bool() const;
124 
127  public: virtual std::string ReadableResult() const;
128 
130  private: std::unique_ptr<ResultPrivate> dataPtr;
131  };
132  }
133 }
134 
135 #ifdef _MSC_VER
136 #pragma warning(pop)
137 #endif
138 
139 #endif
Class describing a result of an operation.
Definition: Result.hh:89
Result & operator=(Result &&_result) noexcept
Move assignment operator.
Result(const ResultType _type)
Constructor.
Result & operator=(const Result &_result)
Copy assignment operator.
Result(const Result &_result)
Copy constructor.
Result()
Default constructor.
Result(Result &&_result) noexcept
Move constructor.
virtual std::string ReadableResult() const
Get human readable result string.
ResultType Type() const
Get the type of result.
ResultType
Result type.
Definition: Result.hh:43
@ FETCH_NOT_FOUND
Model not found.
@ DELETE_ERROR
Delete failed. Other errors.
@ UNKNOWN
Uninitialized type.
@ FETCH_ERROR
Fetch failed. Other errors.
@ FETCH_ALREADY_EXISTS
Model already exists.
@ UPLOAD_ERROR
Upload failed. Other errors.
@ UPLOAD_ALREADY_EXISTS
Model already exists.
@ DELETE_NOT_FOUND
Model not found.