printable.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018, University of Edinburgh
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without specific
15 // prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
30 #ifndef EXOTICA_CORE_PRINTABLE_H_
31 #define EXOTICA_CORE_PRINTABLE_H_
32 
33 #include <iomanip>
34 #include <iostream>
35 #include <map>
36 #include <vector>
37 
38 #include <Eigen/Geometry>
39 #include <kdl/frames.hpp>
40 
42 #ifndef __PRETTY_FUNCTION__
43 #define __PRETTY_FUNCTION__ __func__
44 #endif
45 
46 #ifdef EXOTICA_CORE_DEBUG_MODE
47 #define CHECK_EXECUTION std::cout << "\033[1;32m[EXOTica]:\033[0m Ok in " << __FILE__ << " at line " << __LINE__ << " within function " << __PRETTY_FUNCTION__ << ".\n";
48 #define INDICATE_FAILURE std::cerr << "\033[1;32m[EXOTica]:\033[0m \033[1;31mFailed in " << __FILE__ << " at line " << __LINE__ << " within function " << __PRETTY_FUNCTION__ << ".\033[0m\n";
49 #define WARNING(x) std::cout << "\033[1;32m[EXOTica]:\033[0m \033[33mWarning in " << __PRETTY_FUNCTION__ << ": " << x << "\033[0m\n";
50 #define ERROR(x) std::cerr << "\033[1;32m[EXOTica]:\033[0m \033[1;31mFailed in " << __FILE__ << " at line " << __LINE__ << " within function " << __PRETTY_FUNCTION__ << ".\n" \
51  << x << "\033[0m\n"; // With endline
52 #define INFO(x) std::clog << "\033[1;32m[EXOTica]:\033[0m Info in " << __PRETTY_FUNCTION__ << ": " << x << "\n"; // With endline
53 #else
54 #define CHECK_EXECUTION // No operation
55 #define INDICATE_FAILURE std::cerr << "\033[1;32m[EXOTica]:\033[0m \033[1;31mFailed in " << __FILE__ << " at line " << __LINE__ << " within function " << __PRETTY_FUNCTION__ << ".\033[0m\n";
56 #define WARNING(x) std::cout << "\033[1;32m[EXOTica]:\033[0m \033[33mWarning in " << __PRETTY_FUNCTION__ << ": " << x << "\033[0m\n";
57 #define ERROR(x) std::cerr << "\033[1;32m[EXOTica]:\033[0m \033[1;31mFailed in " << __FILE__ << " at line " << __LINE__ << " within function " << __PRETTY_FUNCTION__ << ".\n" \
58  << x << "\033[0m\n"; // With endline
59 #define INFO(x)
60 #endif
61 #define HIGHLIGHT(x) std::cout << "\033[1;32m[EXOTica]:\033[0m \033[36m" << x << "\033[0m\n";
62 #define HIGHLIGHT_NAMED(name, x) std::cout << "\033[1;32m[EXOTica]:\033[0m \033[35m[" << name << "]\033[0m \033[36m" << x << "\033[0m\n";
63 #define WARNING_NAMED(name, x) std::cout << "\033[1;32m[EXOTica]:\033[0m \033[35m[" << name << "]\033[0m \033[33m" << x << "\033[0m\n";
64 #define INFO_NAMED(name, x) std::cout << "\033[1;32m[EXOTica]:\033[0m \033[35m[" << name << "]\033[0m " << x << "\n";
65 #define INFO_PLAIN(x) std::cout << x << "\n";
66 
67 namespace exotica
68 {
69 class Printable
70 {
71 public:
72  virtual void Print(std::ostream& os) const = 0;
73 };
74 
75 std::ostream& operator<<(std::ostream& os, const Printable& s);
76 
77 template <typename T>
78 std::ostream& operator<<(std::ostream& os, const std::vector<T>& s)
79 {
80  for (auto& p : s) os << p << "\n";
81  return os;
82 }
83 
84 template <typename I, typename T>
85 std::ostream& operator<<(std::ostream& os, const std::map<I, T>& s)
86 {
87  for (auto& p : s) os << p.first << ": " << p.second << "\n";
88  return os;
89 }
90 
91 std::string ToString(const KDL::Frame& s);
92 
93 std::string ToString(const Eigen::Isometry3d& s);
94 
95 void PrintDimensions(const std::string& name, const Eigen::Ref<const Eigen::MatrixXd> m);
96 } // namespace exotica
97 
98 #endif // EXOTICA_CORE_PRINTABLE_H_
s
XmlRpcServer s
exotica
Definition: collision_scene.h:46
exotica::Printable
Definition: printable.h:69
exotica::ToString
std::string ToString(const KDL::Frame &s)
Definition: printable.cpp:40
exotica::Printable::Print
virtual void Print(std::ostream &os) const =0
exotica::PrintDimensions
void PrintDimensions(const std::string &name, const Eigen::Ref< const Eigen::MatrixXd > m)
Definition: printable.cpp:53
exotica::operator<<
std::ostream & operator<<(std::ostream &os, const Printable &s)
Definition: printable.cpp:34


exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Fri Aug 2 2024 08:43:02