17 #ifndef SDFORMAT_TYPES_HH_ 18 #define SDFORMAT_TYPES_HH_ 27 #include <sdf/sdf_config.h> 31 #if defined(__GNUC__) || defined(__clang__) 32 #define SDF_DEPRECATED(version) __attribute__((deprecated)) 33 #define SDF_FORCEINLINE __attribute__((always_inline)) 34 #elif defined(_MSC_VER) 35 #define SDF_DEPRECATED(version) 36 #define SDF_FORCEINLINE __forceinline 38 #define SDF_DEPRECATED(version) 39 #define SDF_FORCEINLINE 43 # define SDF_SUPPRESS_DEPRECATED_BEGIN \ 44 _Pragma("GCC diagnostic push") \ 45 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 46 # define SDF_SUPPRESS_DEPRECATED_END _Pragma("GCC diagnostic pop") 47 #elif defined(__clang__) 48 # define SDF_SUPPRESS_DEPRECATED_BEGIN \ 49 _Pragma("clang diagnostic push") \ 50 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") 51 # define SDF_SUPPRESS_DEPRECATED_END _Pragma("clang diagnostic pop") 53 # define SDF_SUPPRESS_DEPRECATED_BEGIN 54 # define SDF_SUPPRESS_DEPRECATED_END 60 inline namespace SDF_VERSION_NAMESPACE {
68 std::vector<std::string>
split(
const std::string &_str,
69 const std::string &_splitter);
75 std::string
trim(
const char *_in);
82 inline bool equal(
const T &_a,
const T &_b,
83 const T &_epsilon = 1e-6f)
85 return std::fabs(_a - _b) <= _epsilon;
100 public:
Color(
float _r = 0.0f,
float _g = 0.0f,
102 : r(_r), g(_g), b(_b), a(_a)
112 _out << _pt.
r <<
" " << _pt.
g <<
" " << _pt.
b <<
" " << _pt.
a;
119 public:
friend std::istream &operator>> (std::istream &_in,
Color &_pt)
122 _in.setf(std::ios_base::skipws);
123 _in >> _pt.
r >> _pt.
g >> _pt.
b >> _pt.
a;
130 public:
bool operator ==(
const Color &_clr)
const 132 return equal(this->r, _clr.
r) &&
164 public:
Time(int32_t _sec, int32_t _nsec)
165 : sec(_sec), nsec(_nsec)
176 _out << _time.
sec <<
" " << _time.
nsec;
188 _in.setf(std::ios_base::skipws);
189 _in >> _time.
sec >> _time.
nsec;
196 public:
bool operator ==(
const Time &_time)
const 198 return this->sec == _time.
sec && this->nsec == _time.
nsec;
friend std::ostream & operator<<(std::ostream &_out, const Time &_time)
Stream insertion operator.
Definition: Types.hh:173
Time()
Constructor.
Definition: Types.hh:156
SDFORMAT_VISIBLE std::vector< std::string > split(const std::string &_str, const std::string &_splitter)
Split a string using the delimiter in splitter.
friend std::istream & operator>>(std::istream &_in, Time &_time)
Stream extraction operator.
Definition: Types.hh:184
float g
Green value.
Definition: Types.hh:142
Defines a color.
Definition: Types.hh:92
std::string SDFORMAT_VISIBLE lowercase(const std::string &_in)
Transforms a string to its lowercase equivalent.
double mass
Definition: Types.hh:211
int32_t sec
Seconds.
Definition: Types.hh:202
float a
Alpha value.
Definition: Types.hh:148
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
float r
Red value.
Definition: Types.hh:139
bool equal(const T &_a, const T &_b, const T &_epsilon=1e-6f)
check if two values are equal, within a tolerance
Definition: Types.hh:82
A Time class, can be used to hold wall- or sim-time.
Definition: Types.hh:153
A class for inertial information about a link.
Definition: Types.hh:209
namespace for Simulation Description Format parser
Definition: Actor.hh:32
int32_t nsec
Nanoseconds.
Definition: Types.hh:205
Color(float _r=0.0f, float _g=0.0f, float _b=0.0f, float _a=1.0f)
Constructor.
Definition: Types.hh:100
SDFORMAT_VISIBLE std::string trim(const char *_in)
Trim leading and trailing whitespace from a string.
#define SDF_DEPRECATED(version)
Definition: Types.hh:38
float b
Blue value.
Definition: Types.hh:145
std::ostream & operator<<(std::ostream &os, ParamStreamer< T > s)
Definition: Param.hh:75
Time(int32_t _sec, int32_t _nsec)
Constructor.
Definition: Types.hh:164