stromx  0.8.0
OperatorException.h
1 /*
2 * Copyright 2011 Matthias Fuchs
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 #ifndef STROMX_RUNTIME_OPERATOREXCEPTI0N_H
18 #define STROMX_RUNTIME_OPERATOREXCEPTI0N_H
19 
20 #include "stromx/runtime/Exception.h"
21 
22 #include "stromx/runtime/OperatorInfo.h"
23 #include "stromx/runtime/Parameter.h"
24 
25 namespace stromx
26 {
27  namespace runtime
28  {
29  class Parameter;
30 
32  class OperatorError : public Exception
33  {
34  public:
36  OperatorError(const OperatorInfo& op, const std::string & message)
37  : Exception(message),
38  m_type(op.type()),
39  m_package(op.package())
40  {}
41 
43  OperatorError(const OperatorInfo& op, const std::string & message, const std::string & name)
44  : Exception(message),
45  m_name(name),
46  m_type(op.type()),
47  m_package(op.package())
48  {}
49 
50  virtual ~OperatorError() throw() {}
51 
53  const std::string & type() const { return m_type; }
54 
56  const std::string & package() const { return m_package; }
57 
59  const std::string & name() const { return m_name; }
60 
62  void setName(const std::string & name) { m_name = name; }
63 
64  private:
65  std::string m_name;
66  const std::string m_type;
67  const std::string m_package;
68  };
69 
72  {
73  public:
74  WrongOperatorState(const OperatorInfo& op, const std::string & message = "WrongOperatorState")
75  : OperatorError(op, message)
76  {}
77  };
78 
81  {
82  public:
83  WrongParameterId(const unsigned int id, const OperatorInfo& op, const std::string & message = "WrongParameterId")
84  : OperatorError(op, message),
85  m_id(id)
86  {}
87 
88  private:
89  unsigned int m_id;
90  };
91 
94  {
95  public:
96  ParameterError(const Parameter& param, const OperatorInfo& op, const std::string & message = "ParameterError")
97  : OperatorError(op, message),
98  m_id(param.id()),
99  m_title(param.title()),
100  m_variant(param.variant())
101  {}
102 
103  virtual ~ParameterError() throw() {}
104 
106  unsigned int id() const { return m_id; }
107 
109  const std::string & title() const { return m_title; }
110 
112  const VariantInterface & variant() const { return m_variant; }
113 
114  private:
115  const unsigned int m_id;
116  const std::string m_title;
117  const VariantHandle & m_variant;
118  };
119 
122  {
123  public:
124  WrongParameterType(const Parameter& param, const OperatorInfo& op, const std::string & message = "WrongParameterType")
125  : ParameterError(param, op, message)
126  {}
127  };
128 
131  {
132  public:
133  WrongParameterValue(const Parameter& param, const OperatorInfo& op, const std::string & message = "WrongParameterValue")
134  : ParameterError(param, op, message)
135  {}
136  };
137 
140  {
141  public:
142  ParameterAccessViolation(const Parameter& param, const OperatorInfo& op, const std::string & message = "ParameterAccessViolation")
143  : ParameterError(param, op, message)
144  {}
145  };
146 
147 
149  class OutputError : public OperatorError
150  {
151  public:
152  OutputError(const unsigned int outputId, const OperatorInfo& op, const std::string & message = "InputError")
153  : OperatorError(op, message),
154  m_outputId(outputId)
155  {}
156 
157  unsigned int outputId() const { return m_outputId; }
158  private:
159  const unsigned int m_outputId;
160  };
161 
163  class InputError : public OperatorError
164  {
165  public:
166  InputError(const unsigned int inputId, const OperatorInfo& op, const std::string & message = "InputError")
167  : OperatorError(op, message),
168  m_inputId(inputId)
169  {}
170 
171  unsigned int inputId() const { return m_inputId; }
172  private:
173  const unsigned int m_inputId;
174  };
175 
177  class WrongInputType : public InputError
178  {
179  public:
180  WrongInputType(const unsigned int inputId, const OperatorInfo& op, const std::string & message = "WrongInputType")
181  : InputError(inputId, op, message)
182  {}
183  };
184 
187  {
188  public:
189  WrongOutputType(const unsigned int outputId, const OperatorInfo& op, const std::string & message = "WrongInputType")
190  : OutputError(outputId, op, message)
191  {}
192  };
193  }
194 }
195 
196 #endif // STROMX_RUNTIME_OPERATOREXCEPTI0N_H
Tried to set a parameter to data of the wrong type.
Definition: OperatorException.h:121
const std::string & type() const
Definition: OperatorException.h:53
const std::string & package() const
Definition: OperatorException.h:56
Definition: VariantHandle.h:34
OperatorError(const OperatorInfo &op, const std::string &message)
Definition: OperatorException.h:36
const std::string & title() const
Definition: OperatorException.h:109
const VariantInterface & variant() const
Definition: OperatorException.h:112
Abstract description of a data variant.
Definition: VariantInterface.h:40
OperatorError(const OperatorInfo &op, const std::string &message, const std::string &name)
Definition: OperatorException.h:43
Tried to set an output to data of the wrong type.
Definition: OperatorException.h:186
General error in connection with an operator input.
Definition: OperatorException.h:163
A parameter with this ID does not exist.
Definition: OperatorException.h:80
General error in connection with an operator output.
Definition: OperatorException.h:149
const VariantHandle & variant() const
Definition: Description.h:136
General error in connection with a specified parameter.
Definition: OperatorException.h:93
Tried to set an input to data of the wrong type.
Definition: OperatorException.h:177
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
const std::string & title() const
Definition: Description.h:130
Abstract stromx exception.
Definition: Exception.h:31
Meta-information about an operator.
Definition: OperatorInfo.h:51
Description of a parameter.
Definition: Parameter.h:34
The current state of the operator does not allow a specific operation.
Definition: OperatorException.h:71
Tried to violate the parameter access mode.
Definition: OperatorException.h:139
Error in connection with a specified operator.
Definition: OperatorException.h:32
unsigned int id() const
Definition: OperatorException.h:106
unsigned int id() const
Definition: Description.h:133
const std::string & name() const
Definition: OperatorException.h:59
void setName(const std::string &name)
Definition: OperatorException.h:62
Tried to set a parameter to a wrong value.
Definition: OperatorException.h:130
virtual const std::string & message() const
Definition: Exception.h:42