InvalidTypeException.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX::Core
19 * @author Kai Welke
20 * @date 2011 Humanoids Group, HIS, KIT
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #pragma once
26 
28 #include <ArmarXCore/interface/observers/VariantBase.h>
30 
31 #include <string>
32 
34 {
35  class InvalidTypeException: public armarx::InvalidTypeException
36  {
37  public:
38 
39  InvalidTypeException(VariantTypeId typeId1, VariantTypeId typeId2, const std::string& infoString = "")
40  {
41  std::stringstream sstream;
42  sstream << "Type1: " << Variant::typeToString(typeId1) << " Type2: " << Variant::typeToString(typeId2);
43  if (!infoString.empty())
44  {
45  sstream << "\nInfo: " << infoString;
46  }
47  reason = sstream.str();
48  }
49  InvalidTypeException(std::string typeId1, std::string typeId2, const std::string& infoString = "")
50  {
51  std::stringstream sstream;
52  sstream << "Type1: " << typeId1 << " Type2: " << typeId2;
53  if (!infoString.empty())
54  {
55  sstream << "\nInfo: " << infoString;
56  }
57  reason = sstream.str();
58  }
59 
60  ~InvalidTypeException() noexcept override { }
61 
62  std::string ice_id() const override
63  {
64  return "armarx::exceptions::user::InvalidTypeException";
65  }
66  };
67  class UnsupportedTypeException: public armarx::UnsupportedTypeException
68  {
69  public:
70  UnsupportedTypeException(VariantTypeId typeId, const std::string& infoString = "")
71  {
72  std::stringstream sstream;
73  sstream << "Unsupported Type: " << Variant::typeToString(typeId);
74  if (!infoString.empty())
75  {
76  sstream << "\nInfo: " << infoString;
77  }
78  reason = sstream.str();
79  }
80  UnsupportedTypeException(const std::string& typeId, const std::string& infoString = "")
81  {
82  std::stringstream sstream;
83  sstream << "Unsupported Type: " << typeId;
84  if (!infoString.empty())
85  {
86  sstream << "\nInfo: " << infoString;
87  }
88  reason = sstream.str();
89  }
90 
91  ~UnsupportedTypeException() noexcept override { }
92 
93  std::string ice_id() const override
94  {
95  return "armarx::exceptions::user::UnsupportedTypeException";
96  }
97  };
98 }
armarx::exceptions::user::InvalidTypeException::InvalidTypeException
InvalidTypeException(std::string typeId1, std::string typeId2, const std::string &infoString="")
Definition: InvalidTypeException.h:49
armarx::exceptions::user::InvalidTypeException::InvalidTypeException
InvalidTypeException(VariantTypeId typeId1, VariantTypeId typeId2, const std::string &infoString="")
Definition: InvalidTypeException.h:39
armarx::exceptions::user::UnsupportedTypeException::UnsupportedTypeException
UnsupportedTypeException(const std::string &typeId, const std::string &infoString="")
Definition: InvalidTypeException.h:80
armarx::exceptions::user::UnsupportedTypeException::~UnsupportedTypeException
~UnsupportedTypeException() noexcept override
Definition: InvalidTypeException.h:91
armarx::exceptions::user::InvalidTypeException
Definition: InvalidTypeException.h:35
armarx::exceptions::user::InvalidTypeException::~InvalidTypeException
~InvalidTypeException() noexcept override
Definition: InvalidTypeException.h:60
armarx::exceptions::user::UnsupportedTypeException::ice_id
std::string ice_id() const override
Definition: InvalidTypeException.h:93
armarx::Variant::typeToString
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
Definition: Variant.cpp:732
armarx::exceptions::user::UnsupportedTypeException
Definition: InvalidTypeException.h:67
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:44
armarx::exceptions::user::InvalidTypeException::ice_id
std::string ice_id() const override
Definition: InvalidTypeException.h:62
armarx::exceptions::user::UnsupportedTypeException::UnsupportedTypeException
UnsupportedTypeException(VariantTypeId typeId, const std::string &infoString="")
Definition: InvalidTypeException.h:70
armarx::exceptions::user
Definition: NotImplementedYetException.h:32
Variant.h
Exception.h