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
27#include <string>
28
30#include <ArmarXCore/interface/observers/VariantBase.h>
32
34{
35 class InvalidTypeException : public armarx::InvalidTypeException
36 {
37 public:
39 VariantTypeId typeId2,
40 const std::string& infoString = "")
41 {
42 std::stringstream sstream;
43 sstream << "Type1: " << Variant::typeToString(typeId1)
44 << " Type2: " << Variant::typeToString(typeId2);
45 if (!infoString.empty())
46 {
47 sstream << "\nInfo: " << infoString;
48 }
49 reason = sstream.str();
50 }
51
52 InvalidTypeException(std::string typeId1,
53 std::string typeId2,
54 const std::string& infoString = "")
55 {
56 std::stringstream sstream;
57 sstream << "Type1: " << typeId1 << " Type2: " << typeId2;
58 if (!infoString.empty())
59 {
60 sstream << "\nInfo: " << infoString;
61 }
62 reason = sstream.str();
63 }
64
65 ~InvalidTypeException() noexcept override
66 {
67 }
68
69 std::string
70 ice_id() const override
71 {
72 return "armarx::exceptions::user::InvalidTypeException";
73 }
74 };
75
76 class UnsupportedTypeException : public armarx::UnsupportedTypeException
77 {
78 public:
79 UnsupportedTypeException(VariantTypeId typeId, const std::string& infoString = "")
80 {
81 std::stringstream sstream;
82 sstream << "Unsupported Type: " << Variant::typeToString(typeId);
83 if (!infoString.empty())
84 {
85 sstream << "\nInfo: " << infoString;
86 }
87 reason = sstream.str();
88 }
89
90 UnsupportedTypeException(const std::string& typeId, const std::string& infoString = "")
91 {
92 std::stringstream sstream;
93 sstream << "Unsupported Type: " << typeId;
94 if (!infoString.empty())
95 {
96 sstream << "\nInfo: " << infoString;
97 }
98 reason = sstream.str();
99 }
100
101 ~UnsupportedTypeException() noexcept override
102 {
103 }
104
105 std::string
106 ice_id() const override
107 {
108 return "armarx::exceptions::user::UnsupportedTypeException";
109 }
110 };
111} // namespace armarx::exceptions::user
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
Definition Variant.cpp:848
InvalidTypeException(VariantTypeId typeId1, VariantTypeId typeId2, const std::string &infoString="")
InvalidTypeException(std::string typeId1, std::string typeId2, const std::string &infoString="")
UnsupportedTypeException(const std::string &typeId, const std::string &infoString="")
UnsupportedTypeException(VariantTypeId typeId, const std::string &infoString="")
Ice::Int VariantTypeId
Definition Variant.h:43